aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/openssl/openssl-qoriq/qoriq/0003-cryptodev-fix-algorithm-registration.patch
blob: 9d30cc32123980e7a223386f929af6b32de02f28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 36bb0879b498f8e87798848dafa058476f723165 Mon Sep 17 00:00:00 2001
From: Cristian Stoica <cristian.stoica@freescale.com>
Date: Thu, 31 Jul 2014 14:06:19 +0300
Subject: [PATCH 03/48] cryptodev: fix algorithm registration

Cryptodev specific algorithms must register only if available in kernel.

Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com>
---
 crypto/engine/eng_cryptodev.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index 4d783d4..3b6515e 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -134,6 +134,8 @@ static int cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key,
 static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
                           void (*f) (void));
 void ENGINE_load_cryptodev(void);
+const EVP_CIPHER cryptodev_aes_128_cbc_hmac_sha1;
+const EVP_CIPHER cryptodev_aes_256_cbc_hmac_sha1;
 
 static const ENGINE_CMD_DEFN cryptodev_defns[] = {
     {0, NULL, NULL, 0}
@@ -389,7 +391,21 @@ static int get_cryptodev_digests(const int **cnids)
  */
 static int cryptodev_usable_ciphers(const int **nids)
 {
-    return (get_cryptodev_ciphers(nids));
+    int i, count;
+
+    count = get_cryptodev_ciphers(nids);
+    /* add ciphers specific to cryptodev if found in kernel */
+    for (i = 0; i < count; i++) {
+        switch (*(*nids + i)) {
+        case NID_aes_128_cbc_hmac_sha1:
+            EVP_add_cipher(&cryptodev_aes_128_cbc_hmac_sha1);
+            break;
+        case NID_aes_256_cbc_hmac_sha1:
+            EVP_add_cipher(&cryptodev_aes_256_cbc_hmac_sha1);
+            break;
+        }
+    }
+    return count;
 }
 
 static int cryptodev_usable_digests(const int **nids)
@@ -1674,8 +1690,6 @@ void ENGINE_load_cryptodev(void)
     }
     put_dev_crypto(fd);
 
-    EVP_add_cipher(&cryptodev_aes_128_cbc_hmac_sha1);
-    EVP_add_cipher(&cryptodev_aes_256_cbc_hmac_sha1);
     if (!ENGINE_set_id(engine, "cryptodev") ||
         !ENGINE_set_name(engine, "BSD cryptodev engine") ||
         !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
-- 
2.7.0