Mercurial > dropbear
diff libtomcrypt/src/ciphers/rc2.c @ 435:337c45621e81
merge of 'a9b0496634cdd25647b65e585cc3240f3fa699ee'
and 'c22be8b8f570b48e9662dac32c7b3e7148a42206'
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 22 Feb 2007 14:53:49 +0000 |
parents | 0cbe8f6dbf9e |
children | f849a5ca2efc |
line wrap: on
line diff
--- a/libtomcrypt/src/ciphers/rc2.c Thu Feb 22 14:52:46 2007 +0000 +++ b/libtomcrypt/src/ciphers/rc2.c Thu Feb 22 14:53:49 2007 +0000 @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. * - * Tom St Denis, [email protected], http://libtomcrypt.org + * Tom St Denis, [email protected], http://libtomcrypt.com */ /**********************************************************************\ * To commemorate the 1996 RSA Data Security Conference, the following * @@ -36,7 +36,7 @@ &rc2_test, &rc2_done, &rc2_keysize, - NULL, NULL, NULL, NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /* 256-entry permutation table, probably derived somehow from pi */ @@ -125,13 +125,14 @@ @param pt The input plaintext (8 bytes) @param ct The output ciphertext (8 bytes) @param skey The key as scheduled + @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static void _rc2_ecb_encrypt( const unsigned char *pt, +static int _rc2_ecb_encrypt( const unsigned char *pt, unsigned char *ct, symmetric_key *skey) #else -void rc2_ecb_encrypt( const unsigned char *pt, +int rc2_ecb_encrypt( const unsigned char *pt, unsigned char *ct, symmetric_key *skey) #endif @@ -179,15 +180,18 @@ ct[5] = (unsigned char)(x54 >> 8); ct[6] = (unsigned char)x76; ct[7] = (unsigned char)(x76 >> 8); + + return CRYPT_OK; } #ifdef LTC_CLEAN_STACK -void rc2_ecb_encrypt( const unsigned char *pt, +int rc2_ecb_encrypt( const unsigned char *pt, unsigned char *ct, symmetric_key *skey) { - _rc2_ecb_encrypt(pt, ct, skey); + int err = _rc2_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 5); + return err; } #endif @@ -199,13 +203,14 @@ @param ct The input ciphertext (8 bytes) @param pt The output plaintext (8 bytes) @param skey The key as scheduled + @return CRYPT_OK if successful */ #ifdef LTC_CLEAN_STACK -static void _rc2_ecb_decrypt( const unsigned char *ct, +static int _rc2_ecb_decrypt( const unsigned char *ct, unsigned char *pt, symmetric_key *skey) #else -void rc2_ecb_decrypt( const unsigned char *ct, +int rc2_ecb_decrypt( const unsigned char *ct, unsigned char *pt, symmetric_key *skey) #endif @@ -254,15 +259,18 @@ pt[5] = (unsigned char)(x54 >> 8); pt[6] = (unsigned char)x76; pt[7] = (unsigned char)(x76 >> 8); + + return CRYPT_OK; } #ifdef LTC_CLEAN_STACK -void rc2_ecb_decrypt( const unsigned char *ct, +int rc2_ecb_decrypt( const unsigned char *ct, unsigned char *pt, symmetric_key *skey) { - _rc2_ecb_decrypt(ct, pt, skey); + int err = _rc2_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 4 + sizeof(int)); + return err; } #endif @@ -307,7 +315,7 @@ rc2_ecb_encrypt(tests[x].pt, tmp[0], &skey); rc2_ecb_decrypt(tmp[0], tmp[1], &skey); - if (memcmp(tmp[0], tests[x].ct, 8) != 0 || memcmp(tmp[1], tests[x].pt, 8) != 0) { + if (XMEMCMP(tmp[0], tests[x].ct, 8) != 0 || XMEMCMP(tmp[1], tests[x].pt, 8) != 0) { return CRYPT_FAIL_TESTVECTOR; } @@ -350,5 +358,5 @@ /* $Source: /cvs/libtom/libtomcrypt/src/ciphers/rc2.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2005/05/05 14:35:58 $ */ +/* $Revision: 1.12 $ */ +/* $Date: 2006/11/08 23:01:06 $ */