Commit 7c5963e1 authored by Niels Möller's avatar Niels Möller
Browse files

* src/algorithms.c: Use static algorithm objects.

* src/blowfish.c: Likewise.
* src/rijndael.c: Likewise.
* src/crypto.h: Likewise.
* src/twofish.c: Likewise.
* src/cast.c: Likewise.

Rev: src/algorithms.c:1.17
Rev: src/blowfish.c:1.8
Rev: src/cast.c:1.4
Rev: src/crypto.h:1.21
Rev: src/rijndael.c:1.3
Rev: src/twofish.c:1.5
parent 3e30d394
......@@ -54,12 +54,12 @@ all_symmetric_algorithms()
#endif
,
ATOM_ARCFOUR, &crypto_arcfour_algorithm,
ATOM_BLOWFISH_CBC, crypto_cbc(make_blowfish()),
ATOM_TWOFISH_CBC, crypto_cbc(make_twofish()),
ATOM_RIJNDAEL_CBC_LOCAL, crypto_cbc(make_rijndael()),
ATOM_SERPENT_CBC_LOCAL, crypto_cbc(make_serpent()),
ATOM_BLOWFISH_CBC, crypto_cbc(&blowfish_algorithm),
ATOM_TWOFISH_CBC, crypto_cbc(&twofish256_algorithm),
ATOM_RIJNDAEL_CBC_LOCAL, crypto_cbc(&rijndael256_algorithm),
ATOM_SERPENT_CBC_LOCAL, crypto_cbc(&serpent256_algorithm),
ATOM_3DES_CBC, crypto_cbc(make_des3()),
ATOM_CAST128_CBC, crypto_cbc(make_cast()),
ATOM_CAST128_CBC, crypto_cbc(&cast128_algorithm),
#if WITH_IDEA
ATOM_IDEA_CBC, crypto_cbc(&idea_algorithm),
#endif
......
......@@ -99,8 +99,5 @@ make_blowfish_algorithm(UINT32 key_size)
return algorithm;
}
struct crypto_algorithm *
make_blowfish(void)
{
return make_blowfish_algorithm(BLOWFISH_KEYSIZE);
}
struct crypto_algorithm blowfish_algorithm =
{ STATIC_HEADER, BLOWFISH_BLOCKSIZE, BLOWFISH_KEYSIZE, 0, make_blowfish_instance};
......@@ -93,7 +93,5 @@ struct crypto_algorithm *make_cast_algorithm(UINT32 key_size)
return algorithm;
}
struct crypto_algorithm *make_cast(void)
{
return make_cast_algorithm(128/8);
}
struct crypto_algorithm cast128_algorithm =
{ STATIC_HEADER, CAST_BLOCKSIZE, CAST_MAX_KEYSIZE, 0, make_cast_instance};
......@@ -37,18 +37,28 @@
extern struct crypto_algorithm crypto_arcfour_algorithm;
extern struct crypto_algorithm crypto_des_algorithm;
struct crypto_algorithm *make_des3(void);
struct crypto_algorithm *make_cast_algorithm(UINT32 key_size);
extern struct crypto_algorithm cast128_algorithm;
struct crypto_algorithm *make_twofish_algorithm(UINT32 key_size);
struct crypto_algorithm *make_twofish(void);
struct crypto_algorithm *make_blowfish_algorithm(UINT32 key_size);
struct crypto_algorithm *make_blowfish(void);
extern struct crypto_algorithm blowfish_algorithm;
struct crypto_algorithm *make_twofish_algorithm(UINT32 key_size);
extern struct crypto_algorithm twofish128_algorithm;
extern struct crypto_algorithm twofish192_algorithm;
extern struct crypto_algorithm twofish256_algorithm;
struct crypto_algorithm *make_rijndael_algorithm(UINT32 key_size);
struct crypto_algorithm *make_rijndael(void);
extern struct crypto_algorithm rijndael128_algorithm;
extern struct crypto_algorithm rijndael192_algorithm;
extern struct crypto_algorithm rijndael256_algorithm;
struct crypto_algorithm *make_serpent_algorithm(UINT32 key_size);
struct crypto_algorithm *make_serpent(void);
struct crypto_algorithm *make_des3(void);
struct crypto_algorithm *make_cast_algorithm(UINT32 key_size);
struct crypto_algorithm *make_cast(void);
extern struct crypto_algorithm serpent128_algorithm;
extern struct crypto_algorithm serpent192_algorithm;
extern struct crypto_algorithm serpent256_algorithm;
#ifdef WITH_IDEA
extern struct crypto_algorithm idea_algorithm;
......
......@@ -71,8 +71,6 @@ make_rijndael_instance(struct crypto_algorithm *algorithm, int mode,
? do_rijndael_encrypt
: do_rijndael_decrypt);
/* We don't have to deal with weak keys - as a second round AES
* candidate, Rijndael doesn't have any. */
rijndael_setup(&self->ctx, algorithm->key_size, key);
return(&self->super);
......@@ -94,8 +92,11 @@ make_rijndael_algorithm(UINT32 key_size)
return algorithm;
}
struct crypto_algorithm *
make_rijndael(void)
{
return(make_rijndael_algorithm(RIJNDAEL_KEYSIZE));
}
struct crypto_algorithm rijndael128_algorithm =
{ STATIC_HEADER, RIJNDAEL_BLOCKSIZE, 16, 0, make_rijndael_instance};
struct crypto_algorithm rijndael192_algorithm =
{ STATIC_HEADER, RIJNDAEL_BLOCKSIZE, 24, 0, make_rijndael_instance};
struct crypto_algorithm rijndael256_algorithm =
{ STATIC_HEADER, RIJNDAEL_BLOCKSIZE, 32, 0, make_rijndael_instance};
......@@ -93,7 +93,11 @@ make_twofish_algorithm(UINT32 key_size)
return algorithm;
}
struct crypto_algorithm *make_twofish(void)
{
return make_twofish_algorithm(TWOFISH_KEYSIZE);
}
struct crypto_algorithm twofish128_algorithm =
{ STATIC_HEADER, TWOFISH_BLOCKSIZE, 16, 0, make_twofish_instance};
struct crypto_algorithm twofish192_algorithm =
{ STATIC_HEADER, TWOFISH_BLOCKSIZE, 24, 0, make_twofish_instance};
struct crypto_algorithm twofish256_algorithm =
{ STATIC_HEADER, TWOFISH_BLOCKSIZE, 32, 0, make_twofish_instance};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment