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
7 Upstream-status: Pending
9 - aes-192-cbc-hmac-sha1
10 - aes-256-cbc-hmac-sha1
12 Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
14 crypto/engine/eng_cryptodev.c | 41 +++++++++++++++++++++++++++++++++++++++++
15 1 file changed, 41 insertions(+)
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},
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;
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;
48 @@ -871,6 +877,33 @@ const EVP_CIPHER cryptodev_aes_128_cbc_hmac_sha1 = {
52 +const EVP_CIPHER cryptodev_aes_192_cbc_hmac_sha1 = {
53 + NID_aes_192_cbc_hmac_sha1,
55 + EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_AEAD_CIPHER,
56 + cryptodev_init_aead_key,
57 + cryptodev_aead_cipher,
59 + sizeof(struct dev_crypto_state),
60 + EVP_CIPHER_set_asn1_iv,
61 + EVP_CIPHER_get_asn1_iv,
62 + cryptodev_cbc_hmac_sha1_ctrl,
66 +const EVP_CIPHER cryptodev_aes_256_cbc_hmac_sha1 = {
67 + NID_aes_256_cbc_hmac_sha1,
69 + EVP_CIPH_CBC_MODE | EVP_CIPH_FLAG_AEAD_CIPHER,
70 + cryptodev_init_aead_key,
71 + cryptodev_aead_cipher,
73 + sizeof(struct dev_crypto_state),
74 + EVP_CIPHER_set_asn1_iv,
75 + EVP_CIPHER_get_asn1_iv,
76 + cryptodev_cbc_hmac_sha1_ctrl,
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;
86 + case NID_aes_192_cbc_hmac_sha1:
87 + *cipher = &cryptodev_aes_192_cbc_hmac_sha1;
89 + case NID_aes_256_cbc_hmac_sha1:
90 + *cipher = &cryptodev_aes_256_cbc_hmac_sha1;
95 @@ -3830,6 +3869,8 @@ ENGINE_load_cryptodev(void)
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) ||