diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_camellia.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_camellia.c | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/src/lib/libcrypto/evp/e_camellia.c b/src/lib/libcrypto/evp/e_camellia.c index 8bb7c320d3..377d121b89 100644 --- a/src/lib/libcrypto/evp/e_camellia.c +++ b/src/lib/libcrypto/evp/e_camellia.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * are met: | 7 | * are met: |
8 | * | 8 | * |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * | 11 | * |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in | 13 | * notice, this list of conditions and the following disclaimer in |
@@ -63,63 +63,61 @@ | |||
63 | #include "evp_locl.h" | 63 | #include "evp_locl.h" |
64 | 64 | ||
65 | static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 65 | static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
66 | const unsigned char *iv, int enc); | 66 | const unsigned char *iv, int enc); |
67 | 67 | ||
68 | /* Camellia subkey Structure */ | 68 | /* Camellia subkey Structure */ |
69 | typedef struct | 69 | typedef struct { |
70 | { | ||
71 | CAMELLIA_KEY ks; | 70 | CAMELLIA_KEY ks; |
72 | } EVP_CAMELLIA_KEY; | 71 | } EVP_CAMELLIA_KEY; |
73 | 72 | ||
74 | /* Attribute operation for Camellia */ | 73 | /* Attribute operation for Camellia */ |
75 | #define data(ctx) EVP_C_DATA(EVP_CAMELLIA_KEY,ctx) | 74 | #define data(ctx) EVP_C_DATA(EVP_CAMELLIA_KEY,ctx) |
76 | 75 | ||
77 | IMPLEMENT_BLOCK_CIPHER(camellia_128, ks, Camellia, EVP_CAMELLIA_KEY, | 76 | IMPLEMENT_BLOCK_CIPHER(camellia_128, ks, Camellia, EVP_CAMELLIA_KEY, |
78 | NID_camellia_128, 16, 16, 16, 128, | 77 | NID_camellia_128, 16, 16, 16, 128, |
79 | 0, camellia_init_key, NULL, | 78 | 0, camellia_init_key, NULL, |
80 | EVP_CIPHER_set_asn1_iv, | 79 | EVP_CIPHER_set_asn1_iv, |
81 | EVP_CIPHER_get_asn1_iv, | 80 | EVP_CIPHER_get_asn1_iv, |
82 | NULL) | 81 | NULL) |
83 | IMPLEMENT_BLOCK_CIPHER(camellia_192, ks, Camellia, EVP_CAMELLIA_KEY, | 82 | IMPLEMENT_BLOCK_CIPHER(camellia_192, ks, Camellia, EVP_CAMELLIA_KEY, |
84 | NID_camellia_192, 16, 24, 16, 128, | 83 | NID_camellia_192, 16, 24, 16, 128, |
85 | 0, camellia_init_key, NULL, | 84 | 0, camellia_init_key, NULL, |
86 | EVP_CIPHER_set_asn1_iv, | 85 | EVP_CIPHER_set_asn1_iv, |
87 | EVP_CIPHER_get_asn1_iv, | 86 | EVP_CIPHER_get_asn1_iv, |
88 | NULL) | 87 | NULL) |
89 | IMPLEMENT_BLOCK_CIPHER(camellia_256, ks, Camellia, EVP_CAMELLIA_KEY, | 88 | IMPLEMENT_BLOCK_CIPHER(camellia_256, ks, Camellia, EVP_CAMELLIA_KEY, |
90 | NID_camellia_256, 16, 32, 16, 128, | 89 | NID_camellia_256, 16, 32, 16, 128, |
91 | 0, camellia_init_key, NULL, | 90 | 0, camellia_init_key, NULL, |
92 | EVP_CIPHER_set_asn1_iv, | 91 | EVP_CIPHER_set_asn1_iv, |
93 | EVP_CIPHER_get_asn1_iv, | 92 | EVP_CIPHER_get_asn1_iv, |
94 | NULL) | 93 | NULL) |
95 | 94 | ||
96 | #define IMPLEMENT_CAMELLIA_CFBR(ksize,cbits) IMPLEMENT_CFBR(camellia,Camellia,EVP_CAMELLIA_KEY,ks,ksize,cbits,16) | 95 | #define IMPLEMENT_CAMELLIA_CFBR(ksize,cbits) IMPLEMENT_CFBR(camellia,Camellia,EVP_CAMELLIA_KEY,ks,ksize,cbits,16) |
97 | 96 | ||
98 | IMPLEMENT_CAMELLIA_CFBR(128,1) | 97 | IMPLEMENT_CAMELLIA_CFBR(128, 1) |
99 | IMPLEMENT_CAMELLIA_CFBR(192,1) | 98 | IMPLEMENT_CAMELLIA_CFBR(192, 1) |
100 | IMPLEMENT_CAMELLIA_CFBR(256,1) | 99 | IMPLEMENT_CAMELLIA_CFBR(256, 1) |
101 | 100 | ||
102 | IMPLEMENT_CAMELLIA_CFBR(128,8) | 101 | IMPLEMENT_CAMELLIA_CFBR(128, 8) |
103 | IMPLEMENT_CAMELLIA_CFBR(192,8) | 102 | IMPLEMENT_CAMELLIA_CFBR(192, 8) |
104 | IMPLEMENT_CAMELLIA_CFBR(256,8) | 103 | IMPLEMENT_CAMELLIA_CFBR(256, 8) |
105 | 104 | ||
106 | 105 | ||
107 | 106 | /* The subkey for Camellia is generated. */ | |
108 | /* The subkey for Camellia is generated. */ | 107 | static int |
109 | static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 108 | camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
110 | const unsigned char *iv, int enc) | 109 | const unsigned char *iv, int enc) |
111 | { | 110 | { |
112 | int ret; | 111 | int ret; |
113 | 112 | ||
114 | ret=Camellia_set_key(key, ctx->key_len * 8, ctx->cipher_data); | 113 | ret = Camellia_set_key(key, ctx->key_len * 8, ctx->cipher_data); |
115 | 114 | ||
116 | if(ret < 0) | 115 | if (ret < 0) { |
117 | { | 116 | EVPerr(EVP_F_CAMELLIA_INIT_KEY, |
118 | EVPerr(EVP_F_CAMELLIA_INIT_KEY,EVP_R_CAMELLIA_KEY_SETUP_FAILED); | 117 | EVP_R_CAMELLIA_KEY_SETUP_FAILED); |
119 | return 0; | 118 | return 0; |
120 | } | ||
121 | |||
122 | return 1; | ||
123 | } | 119 | } |
124 | 120 | ||
121 | return 1; | ||
122 | } | ||
125 | #endif | 123 | #endif |