diff options
author | Eneas U de Queiroz <cote2004-github@yahoo.com> | 2019-02-27 21:39:18 +0000 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2019-03-09 18:55:07 +0100 |
commit | d971ae51a51cb1b145b6fbbf7d1327a99be257b1 (patch) | |
tree | 767db48749564fe5ca80e00fca3461f80f8b7af7 /package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch | |
parent | c3425be0820b215f44ebf831a0b794e1b70441ad (diff) | |
download | upstream-d971ae51a51cb1b145b6fbbf7d1327a99be257b1.tar.gz upstream-d971ae51a51cb1b145b6fbbf7d1327a99be257b1.tar.bz2 upstream-d971ae51a51cb1b145b6fbbf7d1327a99be257b1.zip |
openssl: backport devcrypto changes from master
The patches to the /dev/crypto engine were commited to openssl master,
and will be in the next major version (3.0).
Changes:
- Optimization in computing a digest in one operation, saving an ioctl
- Runtime configuration options for the choice of algorithms to use
- Command to dump useful information about the algorithms supported by
the engine and the system.
- Build the devcrypto engine as a dynamic module, like other engines.
The devcrypto engine is built as a separate package by default, but
options were added to allow building the engines into the main library.
Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
[refresh patches]
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch')
-rw-r--r-- | package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch b/package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch new file mode 100644 index 0000000000..ebc4aa988f --- /dev/null +++ b/package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch @@ -0,0 +1,58 @@ +From 48e2c9202ea345347da91f4c583e5915eb010d50 Mon Sep 17 00:00:00 2001 +From: Eneas U de Queiroz <cote2004-github@yahoo.com> +Date: Mon, 5 Nov 2018 15:54:17 -0200 +Subject: [PATCH 1/4] eng_devcrypto: save ioctl if EVP_MD_..FLAG_ONESHOT + +Since each ioctl causes a context switch, slowing things down, if +EVP_MD_CTX_FLAG_ONESHOT is set, then: + - call the ioctl in digest_update, saving the result; and + - just copy the result in digest_final, instead of using another ioctl. + +Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com> + +Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> +Reviewed-by: Richard Levitte <levitte@openssl.org> +(Merged from https://github.com/openssl/openssl/pull/7585) + +--- a/crypto/engine/eng_devcrypto.c ++++ b/crypto/engine/eng_devcrypto.c +@@ -461,6 +461,7 @@ struct digest_ctx { + struct session_op sess; + /* This signals that the init function was called, not that it succeeded. */ + int init_called; ++ unsigned char digest_res[HASH_MAX_LEN]; + }; + + static const struct digest_data_st { +@@ -564,12 +565,15 @@ static int digest_update(EVP_MD_CTX *ctx + if (digest_ctx == NULL) + return 0; + +- if (digest_op(digest_ctx, data, count, NULL, COP_FLAG_UPDATE) < 0) { +- SYSerr(SYS_F_IOCTL, errno); +- return 0; ++ if (EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT)) { ++ if (digest_op(digest_ctx, data, count, digest_ctx->digest_res, 0) >= 0) ++ return 1; ++ } else if (digest_op(digest_ctx, data, count, NULL, COP_FLAG_UPDATE) >= 0) { ++ return 1; + } + +- return 1; ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; + } + + static int digest_final(EVP_MD_CTX *ctx, unsigned char *md) +@@ -579,7 +583,10 @@ static int digest_final(EVP_MD_CTX *ctx, + + if (md == NULL || digest_ctx == NULL) + return 0; +- if (digest_op(digest_ctx, NULL, 0, md, COP_FLAG_FINAL) < 0) { ++ ++ if (EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT)) { ++ memcpy(md, digest_ctx->digest_res, EVP_MD_CTX_size(ctx)); ++ } else if (digest_op(digest_ctx, NULL, 0, md, COP_FLAG_FINAL) < 0) { + SYSerr(SYS_F_IOCTL, errno); + return 0; + } |