added libtomcrypt-1.03

This commit is contained in:
Tom St Denis
2005-06-09 00:08:13 +00:00
committed by Steffen Jaeckel
parent 65c1317eee
commit 3964a6523a
285 changed files with 5920 additions and 2287 deletions
+4
View File
@@ -36,3 +36,7 @@ int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, s
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -36,3 +36,7 @@ int ctr_done(symmetric_CTR *ctr)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+5 -1
View File
@@ -60,7 +60,7 @@ int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, s
/* is the pad empty? */
if (ctr->padlen == ctr->blocklen) {
/* increment counter */
if (ctr->mode == 0) {
if (ctr->mode == CTR_COUNTER_LITTLE_ENDIAN) {
/* little-endian */
for (x = 0; x < ctr->blocklen; x++) {
ctr->ctr[x] = (ctr->ctr[x] + (unsigned char)1) & (unsigned char)255;
@@ -102,3 +102,7 @@ int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, s
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -39,3 +39,7 @@ int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -52,3 +52,7 @@ int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+14 -6
View File
@@ -21,19 +21,23 @@
/**
Initialize a CTR context
@param cipher The index of the cipher desired
@param count The initial vector
@param IV The initial vector
@param key The secret key
@param keylen The length of the secret key (octets)
@param num_rounds Number of rounds in the cipher desired (0 for default)
@param ctr_mode The counter mode (CTR_COUNTER_LITTLE_ENDIAN or CTR_COUNTER_BIG_ENDIAN)
@param ctr The CTR state to initialize
@return CRYPT_OK if successful
*/
int ctr_start(int cipher, const unsigned char *count, const unsigned char *key, int keylen,
int num_rounds, symmetric_CTR *ctr)
int ctr_start( int cipher,
const unsigned char *IV,
const unsigned char *key, int keylen,
int num_rounds, int ctr_mode,
symmetric_CTR *ctr)
{
int x, err;
LTC_ARGCHK(count != NULL);
LTC_ARGCHK(IV != NULL);
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(ctr != NULL);
@@ -51,12 +55,16 @@ int ctr_start(int cipher, const unsigned char *count, const unsigned char *key,
ctr->blocklen = cipher_descriptor[cipher].block_length;
ctr->cipher = cipher;
ctr->padlen = 0;
ctr->mode = 0;
ctr->mode = ctr_mode;
for (x = 0; x < ctr->blocklen; x++) {
ctr->ctr[x] = count[x];
ctr->ctr[x] = IV[x];
}
cipher_descriptor[ctr->cipher].ecb_encrypt(ctr->ctr, ctr->pad, &ctr->key);
return CRYPT_OK;
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */