1 From 21e3ca4ec77f9258aa4001f07faac1c4942b48b4 Mon Sep 17 00:00:00 2001
2 From: Tudor Ambarus <tudor.ambarus@freescale.com>
3 Date: Fri, 9 May 2014 17:54:06 +0300
4 Subject: [PATCH 18/26] eng_cryptodev: extend TLS offload with
7 Both obj_mac.h and obj_dat.h were generated using the scripts
11 $ perl objects.pl objects.txt obj_mac.num obj_mac.h
12 $ perl obj_dat.pl obj_mac.h obj_dat.h
14 Change-Id: I94f13cdd09df67e33e6acd3c00aab47cb358ac46
15 Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com>
16 Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
17 Reviewed-on: http://git.am.freescale.net:8181/34001
19 crypto/engine/eng_cryptodev.c | 24 ++++++++++++++++++++++++
20 crypto/objects/obj_dat.h | 10 +++++++---
21 crypto/objects/obj_mac.h | 4 ++++
22 crypto/objects/obj_mac.num | 1 +
23 crypto/objects/objects.txt | 1 +
24 ssl/ssl_ciph.c | 4 ++++
25 6 files changed, 41 insertions(+), 3 deletions(-)
27 diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
28 index 79b2678..299e84b 100644
29 --- a/crypto/engine/eng_cryptodev.c
30 +++ b/crypto/engine/eng_cryptodev.c
31 @@ -135,6 +135,7 @@ static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
32 void ENGINE_load_cryptodev(void);
33 const EVP_CIPHER cryptodev_aes_128_cbc_hmac_sha1;
34 const EVP_CIPHER cryptodev_aes_256_cbc_hmac_sha1;
35 +const EVP_CIPHER cryptodev_3des_cbc_hmac_sha1;
37 inline int spcf_bn2bin(BIGNUM *bn, unsigned char **bin, int *bin_len)
39 @@ -252,6 +253,7 @@ static struct {
40 { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, 0},
41 { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 16, 0},
42 { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, 0},
43 + { CRYPTO_TLS10_3DES_CBC_HMAC_SHA1, NID_des_ede3_cbc_hmac_sha1, 8, 24, 20},
44 { CRYPTO_TLS10_AES_CBC_HMAC_SHA1, NID_aes_128_cbc_hmac_sha1, 16, 16, 20},
45 { CRYPTO_TLS10_AES_CBC_HMAC_SHA1, NID_aes_256_cbc_hmac_sha1, 16, 32, 20},
46 { CRYPTO_AES_GCM, NID_aes_128_gcm, 16, 16, 0},
47 @@ -466,6 +468,9 @@ cryptodev_usable_ciphers(const int **nids)
48 case NID_aes_256_cbc_hmac_sha1:
49 EVP_add_cipher(&cryptodev_aes_256_cbc_hmac_sha1);
51 + case NID_des_ede3_cbc_hmac_sha1:
52 + EVP_add_cipher(&cryptodev_3des_cbc_hmac_sha1);
57 @@ -571,6 +576,7 @@ static int cryptodev_aead_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
58 switch (ctx->cipher->nid) {
59 case NID_aes_128_cbc_hmac_sha1:
60 case NID_aes_256_cbc_hmac_sha1:
61 + case NID_des_ede3_cbc_hmac_sha1:
62 cryp.flags = COP_FLAG_AEAD_TLS_TYPE;
65 @@ -763,6 +769,7 @@ static int cryptodev_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
66 switch (ctx->cipher->nid) {
67 case NID_aes_128_cbc_hmac_sha1:
68 case NID_aes_256_cbc_hmac_sha1:
69 + case NID_des_ede3_cbc_hmac_sha1:
70 maclen = SHA_DIGEST_LENGTH;
73 @@ -1082,6 +1089,20 @@ const EVP_CIPHER cryptodev_aes_256_cbc = {
77 +const EVP_CIPHER cryptodev_3des_cbc_hmac_sha1 = {
78 + NID_des_ede3_cbc_hmac_sha1,
80 + EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_AEAD_CIPHER,
81 + cryptodev_init_aead_key,
82 + cryptodev_aead_cipher,
84 + sizeof(struct dev_crypto_state),
85 + EVP_CIPHER_set_asn1_iv,
86 + EVP_CIPHER_get_asn1_iv,
87 + cryptodev_cbc_hmac_sha1_ctrl,
91 const EVP_CIPHER cryptodev_aes_128_cbc_hmac_sha1 = {
92 NID_aes_128_cbc_hmac_sha1,
94 @@ -1163,6 +1184,9 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
96 *cipher = &cryptodev_aes_256_cbc;
98 + case NID_des_ede3_cbc_hmac_sha1:
99 + *cipher = &cryptodev_3des_cbc_hmac_sha1;
101 case NID_aes_128_cbc_hmac_sha1:
102 *cipher = &cryptodev_aes_128_cbc_hmac_sha1;
104 diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h
105 index bc69665..9f2267a 100644
106 --- a/crypto/objects/obj_dat.h
107 +++ b/crypto/objects/obj_dat.h
109 * [including the GNU Public Licence.]
120 static const unsigned char lvalues[5974]={
121 @@ -2399,6 +2399,8 @@ static const ASN1_OBJECT nid_objs[NUM_NID]={
122 {"AES-256-CBC-HMAC-SHA1","aes-256-cbc-hmac-sha1",
123 NID_aes_256_cbc_hmac_sha1,0,NULL,0},
124 {"RSAES-OAEP","rsaesOaep",NID_rsaesOaep,9,&(lvalues[5964]),0},
125 +{"DES-EDE3-CBC-HMAC-SHA1","des-ede3-cbc-hmac-sha1",
126 + NID_des_ede3_cbc_hmac_sha1,0,NULL,0},
129 static const unsigned int sn_objs[NUM_SN]={
130 @@ -2474,6 +2476,7 @@ static const unsigned int sn_objs[NUM_SN]={
131 62, /* "DES-EDE-OFB" */
133 44, /* "DES-EDE3-CBC" */
134 +920, /* "DES-EDE3-CBC-HMAC-SHA1" */
135 61, /* "DES-EDE3-CFB" */
136 658, /* "DES-EDE3-CFB1" */
137 659, /* "DES-EDE3-CFB8" */
138 @@ -3585,6 +3588,7 @@ static const unsigned int ln_objs[NUM_LN]={
139 62, /* "des-ede-ofb" */
141 44, /* "des-ede3-cbc" */
142 +920, /* "des-ede3-cbc-hmac-sha1" */
143 61, /* "des-ede3-cfb" */
144 658, /* "des-ede3-cfb1" */
145 659, /* "des-ede3-cfb8" */
146 diff --git a/crypto/objects/obj_mac.h b/crypto/objects/obj_mac.h
147 index b5ea7cd..8751902 100644
148 --- a/crypto/objects/obj_mac.h
149 +++ b/crypto/objects/obj_mac.h
150 @@ -4030,3 +4030,7 @@
151 #define LN_aes_256_cbc_hmac_sha1 "aes-256-cbc-hmac-sha1"
152 #define NID_aes_256_cbc_hmac_sha1 918
154 +#define SN_des_ede3_cbc_hmac_sha1 "DES-EDE3-CBC-HMAC-SHA1"
155 +#define LN_des_ede3_cbc_hmac_sha1 "des-ede3-cbc-hmac-sha1"
156 +#define NID_des_ede3_cbc_hmac_sha1 920
158 diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num
159 index 1d0a7c8..9d44bb5 100644
160 --- a/crypto/objects/obj_mac.num
161 +++ b/crypto/objects/obj_mac.num
162 @@ -917,3 +917,4 @@ aes_128_cbc_hmac_sha1 916
163 aes_192_cbc_hmac_sha1 917
164 aes_256_cbc_hmac_sha1 918
166 +des_ede3_cbc_hmac_sha1 920
167 diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt
168 index d3bfad7..90d2fc5 100644
169 --- a/crypto/objects/objects.txt
170 +++ b/crypto/objects/objects.txt
171 @@ -1290,3 +1290,4 @@ kisa 1 6 : SEED-OFB : seed-ofb
172 : AES-128-CBC-HMAC-SHA1 : aes-128-cbc-hmac-sha1
173 : AES-192-CBC-HMAC-SHA1 : aes-192-cbc-hmac-sha1
174 : AES-256-CBC-HMAC-SHA1 : aes-256-cbc-hmac-sha1
175 + : DES-EDE3-CBC-HMAC-SHA1 : des-ede3-cbc-hmac-sha1
176 diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
177 index 8188ff5..310fe76 100644
180 @@ -639,6 +639,10 @@ int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc,
181 c->algorithm_mac == SSL_SHA1 &&
182 (evp=EVP_get_cipherbyname("AES-256-CBC-HMAC-SHA1")))
183 *enc = evp, *md = NULL;
184 + else if (c->algorithm_enc == SSL_3DES &&
185 + c->algorithm_mac == SSL_SHA1 &&
186 + (evp = EVP_get_cipherbyname("DES-EDE3-CBC-HMAC-SHA1")))
187 + *enc = evp, *md = NULL;