X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fcamellia%2Fcmll_misc.c;h=f44d48564c2a28a2efd9c84857e73ca0574c60c7;hp=3c4ec36662e0e345731fe8e4c61154ffdaf06860;hb=7175dbaeba1dbcb176b63894f8a41e4f4b3e54d7;hpb=413e0853d7457e9ca2dcc18fd2ca15ef9327b04d diff --git a/crypto/camellia/cmll_misc.c b/crypto/camellia/cmll_misc.c index 3c4ec36662..f44d48564c 100644 --- a/crypto/camellia/cmll_misc.c +++ b/crypto/camellia/cmll_misc.c @@ -50,61 +50,31 @@ */ #include +#include #include #include "cmll_locl.h" -const char *CAMELLIA_version="CAMELLIA" OPENSSL_VERSION_PTEXT; +const char CAMELLIA_version[]="CAMELLIA" OPENSSL_VERSION_PTEXT; -int Camellia_set_key(const unsigned char *userKey, const int bits, +int private_Camellia_set_key(const unsigned char *userKey, const int bits, CAMELLIA_KEY *key) { - if (!userKey || !key) - { + if(!userKey || !key) return -1; - } - - switch(bits) - { - case 128: - camellia_setup128(userKey, (unsigned int *)key->rd_key); - key->enc = camellia_encrypt128; - key->dec = camellia_decrypt128; - break; - case 192: - camellia_setup192(userKey, (unsigned int *)key->rd_key); - key->enc = camellia_encrypt256; - key->dec = camellia_decrypt256; - break; - case 256: - camellia_setup256(userKey, (unsigned int *)key->rd_key); - key->enc = camellia_encrypt256; - key->dec = camellia_decrypt256; - break; - default: + if(bits != 128 && bits != 192 && bits != 256) return -2; - } - - key->bitLength = bits; + key->grand_rounds = Camellia_Ekeygen(bits , userKey, key->u.rd_key); return 0; } void Camellia_encrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key) { - uint32_t tmp[UNITSIZE]; - - memcpy(tmp, in, CAMELLIA_BLOCK_SIZE); - key->enc(key->rd_key, tmp); - memcpy(out, tmp, CAMELLIA_BLOCK_SIZE); + Camellia_EncryptBlock_Rounds(key->grand_rounds, in , key->u.rd_key , out); } void Camellia_decrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key) { - uint32_t tmp[UNITSIZE]; - - memcpy(tmp, in, CAMELLIA_BLOCK_SIZE); - key->dec(key->rd_key, tmp); - memcpy(out, tmp, CAMELLIA_BLOCK_SIZE); + Camellia_DecryptBlock_Rounds(key->grand_rounds, in , key->u.rd_key , out); } -