mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
* algorithms.h, cast5.c, cipher.c, idea-stub.c, twofish.c, blowfish.c,
des.c, rijndael.c: Consistently use const for input buffers.
This commit is contained in:
parent
ca6dcb7258
commit
b15cc684b8
@ -1,3 +1,9 @@
|
||||
2004-10-12 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* algorithms.h, cast5.c, cipher.c, idea-stub.c, twofish.c,
|
||||
blowfish.c, des.c, rijndael.c: Consistently use const for input
|
||||
buffers.
|
||||
|
||||
2004-09-23 Werner Koch <wk@g10code.com>
|
||||
|
||||
* rsa.c (rsa_generate): Return the dummy list of factors only if
|
||||
|
@ -79,55 +79,53 @@ sha512_get_info (int algo, size_t *contextsize,
|
||||
|
||||
const char *
|
||||
des_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
|
||||
);
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, const byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, const byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, const byte *inbuf )
|
||||
);
|
||||
|
||||
const char *
|
||||
cast5_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
|
||||
);
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, const byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, const byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, const byte *inbuf )
|
||||
);
|
||||
|
||||
|
||||
const char *
|
||||
blowfish_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
|
||||
int (**setkeyf)(void *c, const byte *key, unsigned keylen),
|
||||
void (**encryptf)(void *c, byte *outbuf, const byte *inbuf),
|
||||
void (**decryptf)(void *c, byte *outbuf, const byte *inbuf)
|
||||
);
|
||||
|
||||
const char *
|
||||
twofish_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
|
||||
);
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, const byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, const byte *inbuf),
|
||||
void (**decryptf)( void *c, byte *outbuf, const byte *inbuf )
|
||||
);
|
||||
|
||||
/* this is just a kludge for the time we have not yet changed the cipher
|
||||
* stuff to the scheme we use for random and digests */
|
||||
const char *
|
||||
rijndael_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
|
||||
);
|
||||
int (**setkeyf)( void *c, const byte *key, unsigned keylen),
|
||||
void (**encryptf)(void *c, byte *outbuf, const byte *inbuf),
|
||||
void (**decryptf)(void *c, byte *outbuf, const byte *inbuf)
|
||||
);
|
||||
|
||||
const char *
|
||||
idea_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**setkeyf)( void *c, byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
|
||||
int (**setkeyf)( void *c, const byte *key, unsigned keylen ),
|
||||
void (**encryptf)( void *c, byte *outbuf, const byte *inbuf ),
|
||||
void (**decryptf)( void *c, byte *outbuf, const byte *inbuf )
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif /*GNUPG_ALGORITHMS_H*/
|
||||
|
@ -54,10 +54,7 @@ typedef struct {
|
||||
u32 p[BLOWFISH_ROUNDS+2];
|
||||
} BLOWFISH_context;
|
||||
|
||||
static int bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen );
|
||||
static void encrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf );
|
||||
static void decrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf );
|
||||
|
||||
static int bf_setkey( void *c, const byte *key, unsigned keylen );
|
||||
|
||||
/* precomputed S boxes */
|
||||
static const u32 ks0[256] = {
|
||||
@ -424,7 +421,7 @@ decrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
|
||||
#undef R
|
||||
|
||||
static void
|
||||
do_encrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
|
||||
do_encrypt_block( BLOWFISH_context *bc, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
u32 d1, d2;
|
||||
|
||||
@ -442,14 +439,14 @@ do_encrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
|
||||
}
|
||||
|
||||
static void
|
||||
encrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
|
||||
encrypt_block( void *bc, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
do_encrypt_block (bc, outbuf, inbuf);
|
||||
burn_stack (64);
|
||||
}
|
||||
|
||||
static void
|
||||
do_decrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
|
||||
do_decrypt_block( BLOWFISH_context *bc, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
u32 d1, d2;
|
||||
|
||||
@ -467,7 +464,7 @@ do_decrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
|
||||
}
|
||||
|
||||
static void
|
||||
decrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
|
||||
decrypt_block( void *bc, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
do_decrypt_block (bc, outbuf, inbuf);
|
||||
burn_stack (64);
|
||||
@ -504,7 +501,7 @@ selftest(void)
|
||||
|
||||
|
||||
static int
|
||||
do_bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen )
|
||||
do_bf_setkey( BLOWFISH_context *c, const byte *key, unsigned keylen )
|
||||
{
|
||||
int i, j;
|
||||
u32 data, datal, datar;
|
||||
@ -587,7 +584,7 @@ do_bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen )
|
||||
}
|
||||
|
||||
static int
|
||||
bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen )
|
||||
bf_setkey( void *c, const byte *key, unsigned keylen )
|
||||
{
|
||||
int rc = do_bf_setkey (c, key, keylen);
|
||||
burn_stack (64);
|
||||
@ -601,22 +598,19 @@ bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen )
|
||||
* the ALGO is invalid.
|
||||
*/
|
||||
const char *
|
||||
blowfish_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey)( void *c, byte *key, unsigned keylen ),
|
||||
void (**r_encrypt)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**r_decrypt)( void *c, byte *outbuf, byte *inbuf )
|
||||
)
|
||||
blowfish_get_info(int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey)(void *c, const byte *key, unsigned keylen),
|
||||
void (**r_encrypt)(void *c, byte *outbuf, const byte *inbuf),
|
||||
void (**r_decrypt)( void *c, byte *outbuf, const byte *inbuf)
|
||||
)
|
||||
{
|
||||
*keylen = 128;
|
||||
*blocksize = BLOWFISH_BLOCKSIZE;
|
||||
*contextsize = sizeof(BLOWFISH_context);
|
||||
*(int (**)(BLOWFISH_context*, byte*, unsigned))r_setkey
|
||||
= bf_setkey;
|
||||
*(void (**)(BLOWFISH_context*, byte*, byte*))r_encrypt
|
||||
= encrypt_block;
|
||||
*(void (**)(BLOWFISH_context*, byte*, byte*))r_decrypt
|
||||
= decrypt_block;
|
||||
*r_setkey = bf_setkey;
|
||||
*r_encrypt = encrypt_block;
|
||||
*r_decrypt = decrypt_block;
|
||||
|
||||
if( algo == CIPHER_ALGO_BLOWFISH )
|
||||
return "BLOWFISH";
|
||||
|
@ -54,12 +54,7 @@ typedef struct {
|
||||
byte Kr[16];
|
||||
} CAST5_context;
|
||||
|
||||
static int cast_setkey( CAST5_context *c, byte *key, unsigned keylen );
|
||||
static void encrypt_block( CAST5_context *bc, byte *outbuf, byte *inbuf );
|
||||
static void decrypt_block( CAST5_context *bc, byte *outbuf, byte *inbuf );
|
||||
|
||||
|
||||
|
||||
static int cast_setkey( void *c, const byte *key, unsigned keylen );
|
||||
|
||||
static const u32 s1[256] = {
|
||||
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949,
|
||||
@ -368,7 +363,7 @@ burn_stack (int bytes)
|
||||
|
||||
|
||||
static void
|
||||
do_encrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
|
||||
do_encrypt_block( CAST5_context *c, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
u32 l, r, t;
|
||||
u32 I; /* used by the Fx macros */
|
||||
@ -422,14 +417,14 @@ do_encrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
|
||||
}
|
||||
|
||||
static void
|
||||
encrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
|
||||
encrypt_block( void *c, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
do_encrypt_block (c, outbuf, inbuf);
|
||||
burn_stack (20+4*sizeof(void*));
|
||||
}
|
||||
|
||||
static void
|
||||
do_decrypt_block (CAST5_context *c, byte *outbuf, byte *inbuf )
|
||||
do_decrypt_block (CAST5_context *c, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
u32 l, r, t;
|
||||
u32 I;
|
||||
@ -470,7 +465,7 @@ do_decrypt_block (CAST5_context *c, byte *outbuf, byte *inbuf )
|
||||
}
|
||||
|
||||
static void
|
||||
decrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
|
||||
decrypt_block( void *c, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
do_decrypt_block (c, outbuf, inbuf);
|
||||
burn_stack (20+4*sizeof(void*));
|
||||
@ -573,7 +568,7 @@ key_schedule( u32 *x, u32 *z, u32 *k )
|
||||
|
||||
|
||||
static int
|
||||
do_cast_setkey( CAST5_context *c, byte *key, unsigned keylen )
|
||||
do_cast_setkey( CAST5_context *c, const byte *key, unsigned keylen )
|
||||
{
|
||||
static int initialized;
|
||||
static const char* selftest_failed;
|
||||
@ -616,7 +611,7 @@ do_cast_setkey( CAST5_context *c, byte *key, unsigned keylen )
|
||||
}
|
||||
|
||||
static int
|
||||
cast_setkey( CAST5_context *c, byte *key, unsigned keylen )
|
||||
cast_setkey( void *c, const byte *key, unsigned keylen )
|
||||
{
|
||||
int rc = do_cast_setkey (c, key, keylen);
|
||||
burn_stack (96+7*sizeof(void*));
|
||||
@ -631,22 +626,18 @@ cast_setkey( CAST5_context *c, byte *key, unsigned keylen )
|
||||
*/
|
||||
const char *
|
||||
cast5_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey)( void *c, byte *key, unsigned keylen ),
|
||||
void (**r_encrypt)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**r_decrypt)( void *c, byte *outbuf, byte *inbuf )
|
||||
)
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey)( void *c, const byte *key, unsigned keylen ),
|
||||
void (**r_encrypt)( void *c, byte *outbuf, const byte *inbuf ),
|
||||
void (**r_decrypt)( void *c, byte *outbuf, const byte *inbuf )
|
||||
)
|
||||
{
|
||||
*keylen = 128;
|
||||
*blocksize = CAST5_BLOCKSIZE;
|
||||
*contextsize = sizeof(CAST5_context);
|
||||
*(int (**)(CAST5_context*, byte*, unsigned))r_setkey
|
||||
= cast_setkey;
|
||||
*(void (**)(CAST5_context*, byte*, byte*))r_encrypt
|
||||
= encrypt_block;
|
||||
*(void (**)(CAST5_context*, byte*, byte*))r_decrypt
|
||||
= decrypt_block;
|
||||
|
||||
*r_setkey = cast_setkey;
|
||||
*r_encrypt = encrypt_block;
|
||||
*r_decrypt = decrypt_block;
|
||||
|
||||
if( algo == CIPHER_ALGO_CAST5 )
|
||||
return "CAST5";
|
||||
|
@ -43,9 +43,9 @@ struct cipher_table_s {
|
||||
size_t blocksize;
|
||||
size_t keylen;
|
||||
size_t contextsize; /* allocate this amount of context */
|
||||
int (*setkey)( void *c, byte *key, unsigned keylen );
|
||||
void (*encrypt)( void *c, byte *outbuf, byte *inbuf );
|
||||
void (*decrypt)( void *c, byte *outbuf, byte *inbuf );
|
||||
int (*setkey)( void *c, const byte *key, unsigned keylen );
|
||||
void (*encrypt)( void *c, byte *outbuf, const byte *inbuf );
|
||||
void (*decrypt)( void *c, byte *outbuf, const byte *inbuf );
|
||||
};
|
||||
|
||||
static struct cipher_table_s cipher_table[TABLE_SIZE];
|
||||
@ -59,9 +59,9 @@ struct cipher_handle_s {
|
||||
byte iv[MAX_BLOCKSIZE]; /* (this should be ulong aligned) */
|
||||
byte lastiv[MAX_BLOCKSIZE];
|
||||
int unused; /* in IV */
|
||||
int (*setkey)( void *c, byte *key, unsigned keylen );
|
||||
void (*encrypt)( void *c, byte *outbuf, byte *inbuf );
|
||||
void (*decrypt)( void *c, byte *outbuf, byte *inbuf );
|
||||
int (*setkey)( void *c, const byte *key, unsigned keylen );
|
||||
void (*encrypt)( void *c, byte *outbuf, const byte *inbuf );
|
||||
void (*decrypt)( void *c, byte *outbuf, const byte *inbuf );
|
||||
PROPERLY_ALIGNED_TYPE context;
|
||||
};
|
||||
|
||||
@ -431,7 +431,6 @@ cipher_setkey( CIPHER_HANDLE c, byte *key, unsigned keylen )
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
cipher_setiv( CIPHER_HANDLE c, const byte *iv, unsigned ivlen )
|
||||
{
|
||||
@ -447,8 +446,6 @@ cipher_setiv( CIPHER_HANDLE c, const byte *iv, unsigned ivlen )
|
||||
c->unused = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
do_ecb_encrypt( CIPHER_HANDLE c, byte *outbuf, byte *inbuf, unsigned nblocks )
|
||||
{
|
||||
|
27
cipher/des.c
27
cipher/des.c
@ -41,7 +41,7 @@
|
||||
* bits are parity bits and they will _not_ checked in this implementation, but
|
||||
* simply ignored.
|
||||
*
|
||||
* For Tripple-DES you could use either two 64bit keys or three 64bit keys.
|
||||
* For Triple-DES you could use either two 64bit keys or three 64bit keys.
|
||||
* The parity bits will _not_ checked, too.
|
||||
*
|
||||
* After initializing a context with a key you could use this context to
|
||||
@ -948,7 +948,7 @@ selftest (void)
|
||||
|
||||
|
||||
static int
|
||||
do_tripledes_setkey ( struct _tripledes_ctx *ctx, byte *key, unsigned keylen )
|
||||
do_tripledes_setkey ( void *ctx, const byte *key, unsigned keylen )
|
||||
{
|
||||
if( selftest_failed )
|
||||
return G10ERR_SELFTEST_FAILED;
|
||||
@ -968,14 +968,14 @@ do_tripledes_setkey ( struct _tripledes_ctx *ctx, byte *key, unsigned keylen )
|
||||
|
||||
|
||||
static void
|
||||
do_tripledes_encrypt( struct _tripledes_ctx *ctx, byte *outbuf, byte *inbuf )
|
||||
do_tripledes_encrypt( void *ctx, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
tripledes_ecb_encrypt ( ctx, inbuf, outbuf );
|
||||
burn_stack (32);
|
||||
}
|
||||
|
||||
static void
|
||||
do_tripledes_decrypt( struct _tripledes_ctx *ctx, byte *outbuf, byte *inbuf )
|
||||
do_tripledes_decrypt( void *ctx, byte *outbuf, const byte *inbuf )
|
||||
{
|
||||
tripledes_ecb_decrypt ( ctx, inbuf, outbuf );
|
||||
burn_stack (32);
|
||||
@ -990,11 +990,11 @@ do_tripledes_decrypt( struct _tripledes_ctx *ctx, byte *outbuf, byte *inbuf )
|
||||
*/
|
||||
const char *
|
||||
des_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey)( void *c, byte *key, unsigned keylen ),
|
||||
void (**r_encrypt)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**r_decrypt)( void *c, byte *outbuf, byte *inbuf )
|
||||
)
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey)( void *c, const byte *key, unsigned keylen ),
|
||||
void (**r_encrypt)( void *c, byte *outbuf, const byte *inbuf ),
|
||||
void (**r_decrypt)( void *c, byte *outbuf, const byte *inbuf )
|
||||
)
|
||||
{
|
||||
static int did_selftest = 0;
|
||||
|
||||
@ -1012,12 +1012,9 @@ des_get_info( int algo, size_t *keylen,
|
||||
*keylen = 192;
|
||||
*blocksize = 8;
|
||||
*contextsize = sizeof(struct _tripledes_ctx);
|
||||
*(int (**)(struct _tripledes_ctx*, byte*, unsigned))r_setkey
|
||||
= do_tripledes_setkey;
|
||||
*(void (**)(struct _tripledes_ctx*, byte*, byte*))r_encrypt
|
||||
= do_tripledes_encrypt;
|
||||
*(void (**)(struct _tripledes_ctx*, byte*, byte*))r_decrypt
|
||||
= do_tripledes_decrypt;
|
||||
*r_setkey = do_tripledes_setkey;
|
||||
*r_encrypt = do_tripledes_encrypt;
|
||||
*r_decrypt = do_tripledes_decrypt;
|
||||
return "3DES";
|
||||
}
|
||||
return NULL;
|
||||
|
@ -109,9 +109,9 @@ dlsym ( void *handle, const char *name )
|
||||
|
||||
typedef
|
||||
const char *(*INFO_FNC)(int, size_t*, size_t*, size_t*,
|
||||
int (**)( void *, byte *, unsigned),
|
||||
void (**)( void *, byte *, byte *),
|
||||
void (**)( void *, byte *, byte *));
|
||||
int (**)( void *, const byte *, unsigned),
|
||||
void (**)( void *, byte *, const byte *),
|
||||
void (**)( void *, byte *, const byte *));
|
||||
|
||||
static INFO_FNC
|
||||
load_module (const char *name)
|
||||
@ -152,11 +152,11 @@ load_module (const char *name)
|
||||
|
||||
const char *
|
||||
idea_get_info( int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey)( void *c, byte *key, unsigned keylen ),
|
||||
void (**r_encrypt)( void *c, byte *outbuf, byte *inbuf ),
|
||||
void (**r_decrypt)( void *c, byte *outbuf, byte *inbuf )
|
||||
)
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey)( void *c, const byte *key, unsigned keylen ),
|
||||
void (**r_encrypt)( void *c, byte *outbuf, const byte *inbuf ),
|
||||
void (**r_decrypt)( void *c, byte *outbuf, const byte *inbuf )
|
||||
)
|
||||
{
|
||||
static int initialized;
|
||||
static INFO_FNC info_fnc;
|
||||
|
@ -1824,7 +1824,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
|
||||
}
|
||||
|
||||
static int
|
||||
rijndael_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
|
||||
rijndael_setkey (void *ctx, const byte *key, const unsigned keylen)
|
||||
{
|
||||
int rc = do_setkey (ctx, key, keylen);
|
||||
burn_stack ( 100 + 16*sizeof(int));
|
||||
@ -1948,7 +1948,7 @@ do_encrypt (const RIJNDAEL_context *ctx, byte *b, const byte *a)
|
||||
}
|
||||
|
||||
static void
|
||||
rijndael_encrypt (const RIJNDAEL_context *ctx, byte *b, const byte *a)
|
||||
rijndael_encrypt (void *ctx, byte *b, const byte *a)
|
||||
{
|
||||
do_encrypt (ctx, b, a);
|
||||
burn_stack (16 + 2*sizeof(int));
|
||||
@ -2042,7 +2042,7 @@ do_decrypt (RIJNDAEL_context *ctx, byte *b, const byte *a)
|
||||
}
|
||||
|
||||
static void
|
||||
rijndael_decrypt (RIJNDAEL_context *ctx, byte *b, const byte *a)
|
||||
rijndael_decrypt (void *ctx, byte *b, const byte *a)
|
||||
{
|
||||
do_decrypt (ctx, b, a);
|
||||
burn_stack (16+2*sizeof(int));
|
||||
@ -2127,25 +2127,22 @@ selftest (void)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
rijndael_get_info (int algo, size_t *keylen,
|
||||
rijndael_get_info(int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey) (void *c, byte *key, unsigned keylen),
|
||||
void (**r_encrypt) (void *c, byte *outbuf, byte *inbuf),
|
||||
void (**r_decrypt) (void *c, byte *outbuf, byte *inbuf)
|
||||
)
|
||||
int (**r_setkey)(void *c, const byte *key, unsigned keylen),
|
||||
void (**r_encrypt)(void *c, byte *outbuf, const byte *inbuf),
|
||||
void (**r_decrypt)(void *c, byte *outbuf, const byte *inbuf)
|
||||
)
|
||||
{
|
||||
*keylen = algo==7? 128 : algo==8? 192 : 256;
|
||||
*blocksize = 16;
|
||||
*contextsize = sizeof (RIJNDAEL_context);
|
||||
|
||||
*(int (**)(RIJNDAEL_context*, const byte*, const unsigned))r_setkey
|
||||
= rijndael_setkey;
|
||||
*(void (**)(const RIJNDAEL_context*, byte*, const byte*))r_encrypt
|
||||
= rijndael_encrypt;
|
||||
*(void (**)(RIJNDAEL_context*, byte*, const byte*))r_decrypt
|
||||
= rijndael_decrypt;
|
||||
*r_setkey = rijndael_setkey;
|
||||
*r_encrypt = rijndael_encrypt;
|
||||
*r_decrypt = rijndael_decrypt;
|
||||
|
||||
if( algo == 7 )
|
||||
return "AES";
|
||||
|
@ -696,7 +696,7 @@ do_twofish_setkey (TWOFISH_context *ctx, const byte *key, unsigned int keylen)
|
||||
}
|
||||
|
||||
static int
|
||||
twofish_setkey (TWOFISH_context *ctx, const byte *key, unsigned int keylen)
|
||||
twofish_setkey (void *ctx, const byte *key, unsigned int keylen)
|
||||
{
|
||||
int rc = do_twofish_setkey (ctx, key, keylen);
|
||||
burn_stack (23+6*sizeof(void*));
|
||||
@ -798,7 +798,7 @@ do_twofish_encrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
|
||||
}
|
||||
|
||||
static void
|
||||
twofish_encrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
|
||||
twofish_encrypt (void *ctx, byte *out, const byte *in)
|
||||
{
|
||||
do_twofish_encrypt (ctx, out, in);
|
||||
burn_stack (24+3*sizeof (void*));
|
||||
@ -839,7 +839,7 @@ do_twofish_decrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
|
||||
}
|
||||
|
||||
static void
|
||||
twofish_decrypt (const TWOFISH_context *ctx, byte *out, const byte *in)
|
||||
twofish_decrypt (void *ctx, byte *out, const byte *in)
|
||||
{
|
||||
do_twofish_decrypt (ctx, out, in);
|
||||
burn_stack (24+3*sizeof (void*));
|
||||
@ -1008,25 +1008,22 @@ main()
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
|
||||
|
||||
const char *
|
||||
twofish_get_info (int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey) (void *c, byte *key, unsigned keylen),
|
||||
void (**r_encrypt) (void *c, byte *outbuf, byte *inbuf),
|
||||
void (**r_decrypt) (void *c, byte *outbuf, byte *inbuf)
|
||||
twofish_get_info(int algo, size_t *keylen,
|
||||
size_t *blocksize, size_t *contextsize,
|
||||
int (**r_setkey) (void *c, const byte *key, unsigned keylen),
|
||||
void (**r_encrypt) (void *c, byte *outbuf, const byte *inbuf),
|
||||
void (**r_decrypt) (void *c, byte *outbuf, const byte *inbuf)
|
||||
)
|
||||
{
|
||||
*keylen = algo==10? 256 : 128;
|
||||
*blocksize = 16;
|
||||
*contextsize = sizeof (TWOFISH_context);
|
||||
|
||||
*(int (**)(TWOFISH_context*, const byte*, const unsigned))r_setkey
|
||||
= twofish_setkey;
|
||||
*(void (**)(const TWOFISH_context*, byte*, const byte*))r_encrypt
|
||||
= twofish_encrypt;
|
||||
*(void (**)(const TWOFISH_context*, byte*, const byte*))r_decrypt
|
||||
= twofish_decrypt;
|
||||
*r_setkey = twofish_setkey;
|
||||
*r_encrypt = twofish_encrypt;
|
||||
*r_decrypt = twofish_decrypt;
|
||||
|
||||
if( algo == 10 )
|
||||
return "TWOFISH";
|
||||
|
Loading…
x
Reference in New Issue
Block a user