]> code.ossystems Code Review - meta-freescale.git/blob
a4178841b94aa27499921c16470082cc5c9551f5
[meta-freescale.git] /
1 From 6555c11c9f62fc37c60bb335cfeb5c9d641e493a Mon Sep 17 00:00:00 2001
2 From: Cristian Stoica <cristian.stoica@freescale.com>
3 Date: Fri, 21 Mar 2014 16:22:27 +0200
4 Subject: [PATCH][fsl 09/15] eng_cryptodev: extend TLS offload with new
5  algorithms
6
7 Upstream-status: Pending
8
9 - aes-192-cbc-hmac-sha1
10 - aes-256-cbc-hmac-sha1
11
12 Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
13 ---
14  crypto/engine/eng_cryptodev.c |   41 +++++++++++++++++++++++++++++++++++++++++
15  1 file changed, 41 insertions(+)
16
17 diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
18 index c5e8fb3..e2d4c53 100644
19 --- a/crypto/engine/eng_cryptodev.c
20 +++ b/crypto/engine/eng_cryptodev.c
21 @@ -248,6 +248,8 @@ static struct {
22         { CRYPTO_CAST_CBC,      NID_cast5_cbc,    8,  16, 0},
23         { CRYPTO_SKIPJACK_CBC,  NID_undef,        0,  0,  0},
24         { CRYPTO_TLS10_AES_CBC_HMAC_SHA1, NID_aes_128_cbc_hmac_sha1, 16, 16, 20},
25 +       { CRYPTO_TLS10_AES_CBC_HMAC_SHA1, NID_aes_192_cbc_hmac_sha1, 16, 24, 20},
26 +       { CRYPTO_TLS10_AES_CBC_HMAC_SHA1, NID_aes_256_cbc_hmac_sha1, 16, 32, 20},
27         { 0, NID_undef, 0, 0, 0},
28  };
29  
30 @@ -536,6 +538,8 @@ static int cryptodev_aead_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
31         /* TODO: make a seamless integration with cryptodev flags */
32         switch (ctx->cipher->nid) {
33         case NID_aes_128_cbc_hmac_sha1:
34 +       case NID_aes_192_cbc_hmac_sha1:
35 +       case NID_aes_256_cbc_hmac_sha1:
36                 cryp.flags = COP_FLAG_AEAD_TLS_TYPE;
37         }
38         cryp.ses = sess->ses;
39 @@ -729,6 +733,8 @@ static int cryptodev_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
40                 /* TODO: this should be an extension of EVP_CIPHER struct */
41                 switch (ctx->cipher->nid) {
42                 case NID_aes_128_cbc_hmac_sha1:
43 +               case NID_aes_192_cbc_hmac_sha1:
44 +               case NID_aes_256_cbc_hmac_sha1:
45                         maclen = SHA_DIGEST_LENGTH;
46                 }
47  
48 @@ -871,6 +877,33 @@ const EVP_CIPHER cryptodev_aes_128_cbc_hmac_sha1 = {
49         NULL
50  };
51  
52 +const EVP_CIPHER cryptodev_aes_192_cbc_hmac_sha1 = {
53 +       NID_aes_192_cbc_hmac_sha1,
54 +       16, 24, 16,
55 +       EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_AEAD_CIPHER,
56 +       cryptodev_init_aead_key,
57 +       cryptodev_aead_cipher,
58 +       cryptodev_cleanup,
59 +       sizeof(struct dev_crypto_state),
60 +       EVP_CIPHER_set_asn1_iv,
61 +       EVP_CIPHER_get_asn1_iv,
62 +       cryptodev_cbc_hmac_sha1_ctrl,
63 +       NULL
64 +};
65 +
66 +const EVP_CIPHER cryptodev_aes_256_cbc_hmac_sha1 = {
67 +       NID_aes_256_cbc_hmac_sha1,
68 +       16, 32, 16,
69 +       EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_AEAD_CIPHER,
70 +       cryptodev_init_aead_key,
71 +       cryptodev_aead_cipher,
72 +       cryptodev_cleanup,
73 +       sizeof(struct dev_crypto_state),
74 +       EVP_CIPHER_set_asn1_iv,
75 +       EVP_CIPHER_get_asn1_iv,
76 +       cryptodev_cbc_hmac_sha1_ctrl,
77 +       NULL
78 +};
79  /*
80   * Registered by the ENGINE when used to find out how to deal with
81   * a particular NID in the ENGINE. this says what we'll do at the
82 @@ -911,6 +944,12 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
83         case NID_aes_128_cbc_hmac_sha1:
84                 *cipher = &cryptodev_aes_128_cbc_hmac_sha1;
85                 break;
86 +       case NID_aes_192_cbc_hmac_sha1:
87 +               *cipher = &cryptodev_aes_192_cbc_hmac_sha1;
88 +               break;
89 +       case NID_aes_256_cbc_hmac_sha1:
90 +               *cipher = &cryptodev_aes_256_cbc_hmac_sha1;
91 +               break;
92         default:
93                 *cipher = NULL;
94                 break;
95 @@ -3830,6 +3869,8 @@ ENGINE_load_cryptodev(void)
96         put_dev_crypto(fd);
97  
98         EVP_add_cipher(&cryptodev_aes_128_cbc_hmac_sha1);
99 +       EVP_add_cipher(&cryptodev_aes_192_cbc_hmac_sha1);
100 +       EVP_add_cipher(&cryptodev_aes_256_cbc_hmac_sha1);
101         if (!ENGINE_set_id(engine, "cryptodev") ||
102             !ENGINE_set_name(engine, "BSD cryptodev engine") ||
103             !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
104 -- 
105 1.7.9.7
106