thud migration: refresh OpenSSL patches to version 1.1.x
Removed patches already integrated in the OpenSSL code and refreshed the necessary ones. https://jira.digi.com/browse/DEL-6412 Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
parent
3716f50825
commit
b04b818426
|
|
@ -1,32 +1,33 @@
|
|||
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
|
||||
Date: Wed, 2 May 2018 18:49:28 +0200
|
||||
From: Arturo Buzarra <arturo.buzarra@digi.com>
|
||||
Date: Thu, 31 Jan 2019 18:01:02 +0100
|
||||
Subject: [PATCH] Modify openssl.cnf to automatically load the cryptochip
|
||||
engine
|
||||
|
||||
https://jira.digi.com/browse/DEL-5592
|
||||
|
||||
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
|
||||
Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
|
||||
---
|
||||
apps/openssl.cnf | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
diff --git a/apps/openssl.cnf b/apps/openssl.cnf
|
||||
index 1eb86c4..49d9d83 100644
|
||||
index 6df2878d50..762582f4d0 100644
|
||||
--- a/apps/openssl.cnf
|
||||
+++ b/apps/openssl.cnf
|
||||
@@ -3,6 +3,8 @@
|
||||
# This is mostly being used for generation of certificate requests.
|
||||
#
|
||||
|
||||
|
||||
+openssl_conf = openssl_init
|
||||
+
|
||||
# This definition stops the following lines choking if HOME isn't
|
||||
# defined.
|
||||
HOME = .
|
||||
@@ -348,3 +350,14 @@ tsa_name = yes # Must the TSA name be included in the reply?
|
||||
# (optional, default: no)
|
||||
ess_cert_id_chain = no # Must the ESS cert id chain be included?
|
||||
# Note that you can include other files from the main configuration
|
||||
# file using the .include directive.
|
||||
#.include filename
|
||||
@@ -348,3 +350,14 @@ ess_cert_id_chain = no # Must the ESS cert id chain be included?
|
||||
# (optional, default: no)
|
||||
ess_cert_id_alg = sha1 # algorithm to compute certificate
|
||||
# identifier (optional, default: sha1)
|
||||
+
|
||||
+[ openssl_init ]
|
||||
+engines = engine_section
|
||||
|
|
@ -1,449 +0,0 @@
|
|||
From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
|
||||
Date: Wed, 11 May 2016 12:07:15 +0200
|
||||
Subject: [PATCH] cryptodev: Fix issue with signature generation
|
||||
|
||||
That patch also enables support for SHA2 hashes, and removes support
|
||||
for hashes that were never supported by cryptodev.
|
||||
|
||||
Forward port of patch from:
|
||||
https://rt.openssl.org/Ticket/Display.html?id=2770&user=guest&pass=guest
|
||||
|
||||
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
|
||||
---
|
||||
crypto/engine/eng_cryptodev.c | 197 +++++++++++++++++++++++++++++++-----------
|
||||
1 file changed, 147 insertions(+), 50 deletions(-)
|
||||
|
||||
diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
|
||||
index 926d95c0d7fc..d3554b4eaecd 100644
|
||||
--- a/crypto/engine/eng_cryptodev.c
|
||||
+++ b/crypto/engine/eng_cryptodev.c
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) 2002 Bob Beck <beck@openbsd.org>
|
||||
* Copyright (c) 2002 Theo de Raadt
|
||||
* Copyright (c) 2002 Markus Friedl
|
||||
+ * Copyright (c) 2012 Nikos Mavrogiannopoulos
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -72,7 +73,6 @@ struct dev_crypto_state {
|
||||
struct session_op d_sess;
|
||||
int d_fd;
|
||||
# ifdef USE_CRYPTODEV_DIGESTS
|
||||
- char dummy_mac_key[HASH_MAX_LEN];
|
||||
unsigned char digest_res[HASH_MAX_LEN];
|
||||
char *mac_data;
|
||||
int mac_len;
|
||||
@@ -189,8 +189,10 @@ static struct {
|
||||
static struct {
|
||||
int id;
|
||||
int nid;
|
||||
- int keylen;
|
||||
+ int digestlen;
|
||||
} digests[] = {
|
||||
+#if 0
|
||||
+ /* HMAC is not supported */
|
||||
{
|
||||
CRYPTO_MD5_HMAC, NID_hmacWithMD5, 16
|
||||
},
|
||||
@@ -198,15 +200,15 @@ static struct {
|
||||
CRYPTO_SHA1_HMAC, NID_hmacWithSHA1, 20
|
||||
},
|
||||
{
|
||||
- CRYPTO_RIPEMD160_HMAC, NID_ripemd160, 16
|
||||
- /* ? */
|
||||
+ CRYPTO_SHA2_256_HMAC, NID_hmacWithSHA256, 32
|
||||
},
|
||||
{
|
||||
- CRYPTO_MD5_KPDK, NID_undef, 0
|
||||
+ CRYPTO_SHA2_384_HMAC, NID_hmacWithSHA384, 48
|
||||
},
|
||||
{
|
||||
- CRYPTO_SHA1_KPDK, NID_undef, 0
|
||||
+ CRYPTO_SHA2_512_HMAC, NID_hmacWithSHA512, 64
|
||||
},
|
||||
+#endif
|
||||
{
|
||||
CRYPTO_MD5, NID_md5, 16
|
||||
},
|
||||
@@ -214,6 +216,15 @@ static struct {
|
||||
CRYPTO_SHA1, NID_sha1, 20
|
||||
},
|
||||
{
|
||||
+ CRYPTO_SHA2_256, NID_sha256, 32
|
||||
+ },
|
||||
+ {
|
||||
+ CRYPTO_SHA2_384, NID_sha384, 48
|
||||
+ },
|
||||
+ {
|
||||
+ CRYPTO_SHA2_512, NID_sha512, 64
|
||||
+ },
|
||||
+ {
|
||||
0, NID_undef, 0
|
||||
},
|
||||
};
|
||||
@@ -288,13 +299,14 @@ static int get_cryptodev_ciphers(const int **cnids)
|
||||
static int nids[CRYPTO_ALGORITHM_MAX];
|
||||
struct session_op sess;
|
||||
int fd, i, count = 0;
|
||||
+ unsigned char fake_key[CRYPTO_CIPHER_MAX_KEY_LEN];
|
||||
|
||||
if ((fd = get_dev_crypto()) < 0) {
|
||||
*cnids = NULL;
|
||||
return (0);
|
||||
}
|
||||
memset(&sess, 0, sizeof(sess));
|
||||
- sess.key = (caddr_t) "123456789abcdefghijklmno";
|
||||
+ sess.key = (void*)fake_key;
|
||||
|
||||
for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
|
||||
if (ciphers[i].nid == NID_undef)
|
||||
@@ -325,6 +337,7 @@ static int get_cryptodev_ciphers(const int **cnids)
|
||||
static int get_cryptodev_digests(const int **cnids)
|
||||
{
|
||||
static int nids[CRYPTO_ALGORITHM_MAX];
|
||||
+ unsigned char fake_key[CRYPTO_CIPHER_MAX_KEY_LEN];
|
||||
struct session_op sess;
|
||||
int fd, i, count = 0;
|
||||
|
||||
@@ -333,12 +346,12 @@ static int get_cryptodev_digests(const int **cnids)
|
||||
return (0);
|
||||
}
|
||||
memset(&sess, 0, sizeof(sess));
|
||||
- sess.mackey = (caddr_t) "123456789abcdefghijklmno";
|
||||
+ sess.mackey = fake_key;
|
||||
for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
|
||||
if (digests[i].nid == NID_undef)
|
||||
continue;
|
||||
sess.mac = digests[i].id;
|
||||
- sess.mackeylen = digests[i].keylen;
|
||||
+ sess.mackeylen = 8;
|
||||
sess.cipher = 0;
|
||||
if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
|
||||
ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
|
||||
@@ -424,14 +437,14 @@ cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
cryp.ses = sess->ses;
|
||||
cryp.flags = 0;
|
||||
cryp.len = inl;
|
||||
- cryp.src = (caddr_t) in;
|
||||
- cryp.dst = (caddr_t) out;
|
||||
+ cryp.src = (void*) in;
|
||||
+ cryp.dst = (void*) out;
|
||||
cryp.mac = 0;
|
||||
|
||||
cryp.op = ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
|
||||
|
||||
if (ctx->cipher->iv_len) {
|
||||
- cryp.iv = (caddr_t) ctx->iv;
|
||||
+ cryp.iv = (void*) ctx->iv;
|
||||
if (!ctx->encrypt) {
|
||||
iiv = in + inl - ctx->cipher->iv_len;
|
||||
memcpy(save_iv, iiv, ctx->cipher->iv_len);
|
||||
@@ -483,7 +496,7 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
if ((state->d_fd = get_dev_crypto()) < 0)
|
||||
return (0);
|
||||
|
||||
- sess->key = (caddr_t) key;
|
||||
+ sess->key = (void*)key;
|
||||
sess->keylen = ctx->key_len;
|
||||
sess->cipher = cipher;
|
||||
|
||||
@@ -749,16 +762,6 @@ static int digest_nid_to_cryptodev(int nid)
|
||||
return (0);
|
||||
}
|
||||
|
||||
-static int digest_key_length(int nid)
|
||||
-{
|
||||
- int i;
|
||||
-
|
||||
- for (i = 0; digests[i].id; i++)
|
||||
- if (digests[i].nid == nid)
|
||||
- return digests[i].keylen;
|
||||
- return (0);
|
||||
-}
|
||||
-
|
||||
static int cryptodev_digest_init(EVP_MD_CTX *ctx)
|
||||
{
|
||||
struct dev_crypto_state *state = ctx->md_data;
|
||||
@@ -769,7 +772,6 @@ static int cryptodev_digest_init(EVP_MD_CTX *ctx)
|
||||
printf("cryptodev_digest_init: Can't get digest \n");
|
||||
return (0);
|
||||
}
|
||||
-
|
||||
memset(state, 0, sizeof(struct dev_crypto_state));
|
||||
|
||||
if ((state->d_fd = get_dev_crypto()) < 0) {
|
||||
@@ -777,8 +779,8 @@ static int cryptodev_digest_init(EVP_MD_CTX *ctx)
|
||||
return (0);
|
||||
}
|
||||
|
||||
- sess->mackey = state->dummy_mac_key;
|
||||
- sess->mackeylen = digest_key_length(ctx->digest->type);
|
||||
+ sess->mackey = NULL;
|
||||
+ sess->mackeylen = 0;
|
||||
sess->mac = digest;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
|
||||
@@ -794,8 +796,8 @@ static int cryptodev_digest_init(EVP_MD_CTX *ctx)
|
||||
static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
|
||||
size_t count)
|
||||
{
|
||||
- struct crypt_op cryp;
|
||||
struct dev_crypto_state *state = ctx->md_data;
|
||||
+ struct crypt_op cryp;
|
||||
struct session_op *sess = &state->d_sess;
|
||||
|
||||
if (!data || state->d_fd < 0) {
|
||||
@@ -804,7 +806,7 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
|
||||
}
|
||||
|
||||
if (!count) {
|
||||
- return (0);
|
||||
+ return (1);
|
||||
}
|
||||
|
||||
if (!(ctx->flags & EVP_MD_CTX_FLAG_ONESHOT)) {
|
||||
@@ -828,9 +830,9 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
|
||||
cryp.ses = sess->ses;
|
||||
cryp.flags = 0;
|
||||
cryp.len = count;
|
||||
- cryp.src = (caddr_t) data;
|
||||
+ cryp.src = (void*) data;
|
||||
cryp.dst = NULL;
|
||||
- cryp.mac = (caddr_t) state->digest_res;
|
||||
+ cryp.mac = (void*) state->digest_res;
|
||||
if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
|
||||
printf("cryptodev_digest_update: digest failed\n");
|
||||
return (0);
|
||||
@@ -844,8 +846,6 @@ static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
struct dev_crypto_state *state = ctx->md_data;
|
||||
struct session_op *sess = &state->d_sess;
|
||||
|
||||
- int ret = 1;
|
||||
-
|
||||
if (!md || state->d_fd < 0) {
|
||||
printf("cryptodev_digest_final: illegal input\n");
|
||||
return (0);
|
||||
@@ -859,7 +859,7 @@ static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
cryp.len = state->mac_len;
|
||||
cryp.src = state->mac_data;
|
||||
cryp.dst = NULL;
|
||||
- cryp.mac = (caddr_t) md;
|
||||
+ cryp.mac = (void*)md;
|
||||
if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
|
||||
printf("cryptodev_digest_final: digest failed\n");
|
||||
return (0);
|
||||
@@ -870,7 +870,7 @@ static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
|
||||
memcpy(md, state->digest_res, ctx->digest->md_size);
|
||||
|
||||
- return (ret);
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
|
||||
@@ -921,8 +921,8 @@ static int cryptodev_digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from)
|
||||
|
||||
digest = digest_nid_to_cryptodev(to->digest->type);
|
||||
|
||||
- sess->mackey = dstate->dummy_mac_key;
|
||||
- sess->mackeylen = digest_key_length(to->digest->type);
|
||||
+ sess->mackey = NULL;
|
||||
+ sess->mackeylen = 0;
|
||||
sess->mac = digest;
|
||||
|
||||
dstate->d_fd = get_dev_crypto();
|
||||
@@ -945,34 +945,118 @@ static int cryptodev_digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from)
|
||||
return 1;
|
||||
}
|
||||
|
||||
-const EVP_MD cryptodev_sha1 = {
|
||||
+static const EVP_MD cryptodev_sha1 = {
|
||||
NID_sha1,
|
||||
- NID_undef,
|
||||
+ NID_sha1WithRSAEncryption,
|
||||
SHA_DIGEST_LENGTH,
|
||||
+#if defined(EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) && defined(EVP_MD_FLAG_DIGALGID_ABSENT)
|
||||
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|
|
||||
+ EVP_MD_FLAG_DIGALGID_ABSENT|
|
||||
+#endif
|
||||
EVP_MD_FLAG_ONESHOT,
|
||||
cryptodev_digest_init,
|
||||
cryptodev_digest_update,
|
||||
cryptodev_digest_final,
|
||||
cryptodev_digest_copy,
|
||||
cryptodev_digest_cleanup,
|
||||
- EVP_PKEY_NULL_method,
|
||||
+ EVP_PKEY_RSA_method,
|
||||
SHA_CBLOCK,
|
||||
- sizeof(struct dev_crypto_state),
|
||||
+ sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
|
||||
};
|
||||
|
||||
-const EVP_MD cryptodev_md5 = {
|
||||
+static const EVP_MD cryptodev_sha256 = {
|
||||
+ NID_sha256,
|
||||
+ NID_sha256WithRSAEncryption,
|
||||
+ SHA256_DIGEST_LENGTH,
|
||||
+#if defined(EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) && defined(EVP_MD_FLAG_DIGALGID_ABSENT)
|
||||
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|
|
||||
+ EVP_MD_FLAG_DIGALGID_ABSENT|
|
||||
+#endif
|
||||
+ EVP_MD_FLAG_ONESHOT,
|
||||
+ cryptodev_digest_init,
|
||||
+ cryptodev_digest_update,
|
||||
+ cryptodev_digest_final,
|
||||
+ cryptodev_digest_copy,
|
||||
+ cryptodev_digest_cleanup,
|
||||
+ EVP_PKEY_RSA_method,
|
||||
+ SHA256_CBLOCK,
|
||||
+ sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
|
||||
+};
|
||||
+
|
||||
+static const EVP_MD cryptodev_sha224 = {
|
||||
+ NID_sha224,
|
||||
+ NID_sha224WithRSAEncryption,
|
||||
+ SHA224_DIGEST_LENGTH,
|
||||
+#if defined(EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) && defined(EVP_MD_FLAG_DIGALGID_ABSENT)
|
||||
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|
|
||||
+ EVP_MD_FLAG_DIGALGID_ABSENT|
|
||||
+#endif
|
||||
+ EVP_MD_FLAG_ONESHOT,
|
||||
+ cryptodev_digest_init,
|
||||
+ cryptodev_digest_update,
|
||||
+ cryptodev_digest_final,
|
||||
+ cryptodev_digest_copy,
|
||||
+ cryptodev_digest_cleanup,
|
||||
+ EVP_PKEY_RSA_method,
|
||||
+ SHA256_CBLOCK,
|
||||
+ sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
|
||||
+};
|
||||
+
|
||||
+static const EVP_MD cryptodev_sha384 = {
|
||||
+ NID_sha384,
|
||||
+ NID_sha384WithRSAEncryption,
|
||||
+ SHA384_DIGEST_LENGTH,
|
||||
+#if defined(EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) && defined(EVP_MD_FLAG_DIGALGID_ABSENT)
|
||||
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|
|
||||
+ EVP_MD_FLAG_DIGALGID_ABSENT|
|
||||
+#endif
|
||||
+ EVP_MD_FLAG_ONESHOT,
|
||||
+ cryptodev_digest_init,
|
||||
+ cryptodev_digest_update,
|
||||
+ cryptodev_digest_final,
|
||||
+ cryptodev_digest_copy,
|
||||
+ cryptodev_digest_cleanup,
|
||||
+ EVP_PKEY_RSA_method,
|
||||
+ SHA512_CBLOCK,
|
||||
+ sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
|
||||
+};
|
||||
+
|
||||
+static const EVP_MD cryptodev_sha512 = {
|
||||
+ NID_sha512,
|
||||
+ NID_sha512WithRSAEncryption,
|
||||
+ SHA512_DIGEST_LENGTH,
|
||||
+#if defined(EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) && defined(EVP_MD_FLAG_DIGALGID_ABSENT)
|
||||
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|
|
||||
+ EVP_MD_FLAG_DIGALGID_ABSENT|
|
||||
+#endif
|
||||
+ EVP_MD_FLAG_ONESHOT,
|
||||
+ cryptodev_digest_init,
|
||||
+ cryptodev_digest_update,
|
||||
+ cryptodev_digest_final,
|
||||
+ cryptodev_digest_copy,
|
||||
+ cryptodev_digest_cleanup,
|
||||
+ EVP_PKEY_RSA_method,
|
||||
+ SHA512_CBLOCK,
|
||||
+ sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
|
||||
+};
|
||||
+
|
||||
+static const EVP_MD cryptodev_md5 = {
|
||||
NID_md5,
|
||||
- NID_undef,
|
||||
+ NID_md5WithRSAEncryption,
|
||||
16 /* MD5_DIGEST_LENGTH */ ,
|
||||
+#if defined(EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) && defined(EVP_MD_FLAG_DIGALGID_ABSENT)
|
||||
+ EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|
|
||||
+ EVP_MD_FLAG_DIGALGID_ABSENT|
|
||||
+#endif
|
||||
EVP_MD_FLAG_ONESHOT,
|
||||
cryptodev_digest_init,
|
||||
cryptodev_digest_update,
|
||||
cryptodev_digest_final,
|
||||
cryptodev_digest_copy,
|
||||
cryptodev_digest_cleanup,
|
||||
- EVP_PKEY_NULL_method,
|
||||
+ EVP_PKEY_RSA_method,
|
||||
64 /* MD5_CBLOCK */ ,
|
||||
- sizeof(struct dev_crypto_state),
|
||||
+ sizeof(EVP_MD *)+sizeof(struct dev_crypto_state),
|
||||
};
|
||||
|
||||
# endif /* USE_CRYPTODEV_DIGESTS */
|
||||
@@ -992,6 +1076,18 @@ cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
|
||||
case NID_sha1:
|
||||
*digest = &cryptodev_sha1;
|
||||
break;
|
||||
+ case NID_sha224:
|
||||
+ *digest = &cryptodev_sha224;
|
||||
+ break;
|
||||
+ case NID_sha256:
|
||||
+ *digest = &cryptodev_sha256;
|
||||
+ break;
|
||||
+ case NID_sha384:
|
||||
+ *digest = &cryptodev_sha384;
|
||||
+ break;
|
||||
+ case NID_sha512:
|
||||
+ *digest = &cryptodev_sha512;
|
||||
+ break;
|
||||
default:
|
||||
# endif /* USE_CRYPTODEV_DIGESTS */
|
||||
*digest = NULL;
|
||||
@@ -1022,7 +1118,7 @@ static int bn2crparam(const BIGNUM *a, struct crparam *crp)
|
||||
return (1);
|
||||
memset(b, 0, bytes);
|
||||
|
||||
- crp->crp_p = (caddr_t) b;
|
||||
+ crp->crp_p = (void*) b;
|
||||
crp->crp_nbits = bits;
|
||||
|
||||
for (i = 0, j = 0; i < a->top; i++) {
|
||||
@@ -1277,7 +1373,7 @@ static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen,
|
||||
kop.crk_op = CRK_DSA_SIGN;
|
||||
|
||||
/* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */
|
||||
- kop.crk_param[0].crp_p = (caddr_t) dgst;
|
||||
+ kop.crk_param[0].crp_p = (void*)dgst;
|
||||
kop.crk_param[0].crp_nbits = dlen * 8;
|
||||
if (bn2crparam(dsa->p, &kop.crk_param[1]))
|
||||
goto err;
|
||||
@@ -1317,7 +1413,7 @@ cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
|
||||
kop.crk_op = CRK_DSA_VERIFY;
|
||||
|
||||
/* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */
|
||||
- kop.crk_param[0].crp_p = (caddr_t) dgst;
|
||||
+ kop.crk_param[0].crp_p = (void*)dgst;
|
||||
kop.crk_param[0].crp_nbits = dlen * 8;
|
||||
if (bn2crparam(dsa->p, &kop.crk_param[1]))
|
||||
goto err;
|
||||
@@ -1398,9 +1494,10 @@ cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
|
||||
goto err;
|
||||
kop.crk_iparams = 3;
|
||||
|
||||
- kop.crk_param[3].crp_p = (caddr_t) key;
|
||||
- kop.crk_param[3].crp_nbits = keylen * 8;
|
||||
+ kop.crk_param[3].crp_p = (void*) key;
|
||||
+ kop.crk_param[3].crp_nbits = keylen;
|
||||
kop.crk_oparams = 1;
|
||||
+ dhret = keylen/8;
|
||||
|
||||
if (ioctl(fd, CIOCKEY, &kop) == -1) {
|
||||
const DH_METHOD *meth = DH_OpenSSL();
|
||||
@@ -1470,7 +1567,7 @@ void ENGINE_load_cryptodev(void)
|
||||
put_dev_crypto(fd);
|
||||
|
||||
if (!ENGINE_set_id(engine, "cryptodev") ||
|
||||
- !ENGINE_set_name(engine, "BSD cryptodev engine") ||
|
||||
+ !ENGINE_set_name(engine, "cryptodev engine") ||
|
||||
!ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
|
||||
!ENGINE_set_digests(engine, cryptodev_engine_digests) ||
|
||||
!ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
|
||||
|
|
@ -1,203 +0,0 @@
|
|||
From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
|
||||
Date: Wed, 11 May 2016 12:33:20 +0200
|
||||
Subject: [PATCH] cryptodev: allow copying EVP contexts
|
||||
|
||||
Forward port of patch from:
|
||||
https://rt.openssl.org/Ticket/Display.html?id=2770&user=guest&pass=guest
|
||||
|
||||
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
|
||||
---
|
||||
crypto/engine/eng_cryptodev.c | 57 ++++++++++++++++++++++++++-----------------
|
||||
1 file changed, 35 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
|
||||
index d3554b4eaecd..47e292f5e3c0 100644
|
||||
--- a/crypto/engine/eng_cryptodev.c
|
||||
+++ b/crypto/engine/eng_cryptodev.c
|
||||
@@ -547,151 +547,164 @@ static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
|
||||
* gets called when libcrypto requests a cipher NID.
|
||||
*/
|
||||
|
||||
+static int cryptodev_cipher_ctrl(EVP_CIPHER_CTX *ctx, int type, int p1, void *p2)
|
||||
+{
|
||||
+ struct dev_crypto_state *state = ctx->cipher_data;
|
||||
+ struct session_op *sess = &state->d_sess;
|
||||
+
|
||||
+ if (type == EVP_CTRL_COPY) {
|
||||
+ EVP_CIPHER_CTX *out = p2;
|
||||
+ return cryptodev_init_key(out, sess->key, ctx->iv, 0);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/* RC4 */
|
||||
const EVP_CIPHER cryptodev_rc4 = {
|
||||
NID_rc4,
|
||||
1, 16, 0,
|
||||
- EVP_CIPH_VARIABLE_LENGTH,
|
||||
+ EVP_CIPH_VARIABLE_LENGTH|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
NULL,
|
||||
NULL,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
/* DES CBC EVP */
|
||||
const EVP_CIPHER cryptodev_des_cbc = {
|
||||
NID_des_cbc,
|
||||
8, 8, 8,
|
||||
- EVP_CIPH_CBC_MODE,
|
||||
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
/* 3DES CBC EVP */
|
||||
const EVP_CIPHER cryptodev_3des_cbc = {
|
||||
NID_des_ede3_cbc,
|
||||
8, 24, 8,
|
||||
- EVP_CIPH_CBC_MODE,
|
||||
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
const EVP_CIPHER cryptodev_bf_cbc = {
|
||||
NID_bf_cbc,
|
||||
8, 16, 8,
|
||||
- EVP_CIPH_CBC_MODE,
|
||||
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
const EVP_CIPHER cryptodev_cast_cbc = {
|
||||
NID_cast5_cbc,
|
||||
8, 16, 8,
|
||||
- EVP_CIPH_CBC_MODE,
|
||||
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
const EVP_CIPHER cryptodev_aes_cbc = {
|
||||
NID_aes_128_cbc,
|
||||
16, 16, 16,
|
||||
- EVP_CIPH_CBC_MODE,
|
||||
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
const EVP_CIPHER cryptodev_aes_192_cbc = {
|
||||
NID_aes_192_cbc,
|
||||
16, 24, 16,
|
||||
- EVP_CIPH_CBC_MODE,
|
||||
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
const EVP_CIPHER cryptodev_aes_256_cbc = {
|
||||
NID_aes_256_cbc,
|
||||
16, 32, 16,
|
||||
- EVP_CIPH_CBC_MODE,
|
||||
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
# ifdef CRYPTO_AES_CTR
|
||||
const EVP_CIPHER cryptodev_aes_ctr = {
|
||||
NID_aes_128_ctr,
|
||||
16, 16, 14,
|
||||
- EVP_CIPH_CTR_MODE,
|
||||
+ EVP_CIPH_CTR_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
const EVP_CIPHER cryptodev_aes_ctr_192 = {
|
||||
NID_aes_192_ctr,
|
||||
16, 24, 14,
|
||||
- EVP_CIPH_CTR_MODE,
|
||||
+ EVP_CIPH_CTR_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
|
||||
const EVP_CIPHER cryptodev_aes_ctr_256 = {
|
||||
NID_aes_256_ctr,
|
||||
16, 32, 14,
|
||||
- EVP_CIPH_CTR_MODE,
|
||||
+ EVP_CIPH_CTR_MODE|EVP_CIPH_CUSTOM_COPY,
|
||||
cryptodev_init_key,
|
||||
cryptodev_cipher,
|
||||
cryptodev_cleanup,
|
||||
sizeof(struct dev_crypto_state),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
- NULL
|
||||
+ cryptodev_cipher_ctrl
|
||||
};
|
||||
# endif
|
||||
/*
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,7 +3,7 @@
|
|||
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
||||
|
||||
CRYPTOCHIP_COMMON_PATCHES = " \
|
||||
file://0003-Modify-openssl.cnf-to-automatically-load-the-cryptoc.patch \
|
||||
file://0001-Modify-openssl.cnf-to-automatically-load-the-cryptoc.patch \
|
||||
"
|
||||
|
||||
SRC_URI_remove = " \
|
||||
|
|
@ -12,8 +12,5 @@ SRC_URI_remove = " \
|
|||
"
|
||||
|
||||
SRC_URI += " \
|
||||
file://0001-cryptodev-Fix-issue-with-signature-generation.patch \
|
||||
file://0002-cryptodev-allow-copying-EVP-contexts.patch \
|
||||
${@bb.utils.contains("MACHINE_FEATURES", "cryptochip", "${CRYPTOCHIP_COMMON_PATCHES}", "", d)} \
|
||||
file://version-script.patch \
|
||||
"
|
||||
|
|
|
|||
Loading…
Reference in New Issue