The branch master has been updated via 397e23f8db5aecfaef4d470b0c421d2cd84da6f7 (commit) via 6b1fe3d059d8c5b3b86a7203faf59a7538fc9f0d (commit) from 5c5eb286afc046094cf48ecc49b10d04a1a3146c (commit)
- Log ----------------------------------------------------------------- commit 397e23f8db5aecfaef4d470b0c421d2cd84da6f7 Author: Patrick Steuer <patrick.ste...@de.ibm.com> Date: Mon Dec 4 18:32:12 2017 +0100 apps/speed.c: initialize buffers Stop valgrind's complaints about uninitialized values. Signed-off-by: Patrick Steuer <patrick.ste...@de.ibm.com> Reviewed-by: Rich Salz <rs...@openssl.org> Reviewed-by: Andy Polyakov <ap...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4842) commit 6b1fe3d059d8c5b3b86a7203faf59a7538fc9f0d Author: Patrick Steuer <patrick.ste...@de.ibm.com> Date: Mon Dec 4 17:40:23 2017 +0100 apps/speed.c: generate evp_cipher keys implicitly Generate keys using EVP_CIPHER's key generation routine to support keys of a specific form. Signed-off-by: Patrick Steuer <patrick.ste...@de.ibm.com> Reviewed-by: Rich Salz <rs...@openssl.org> Reviewed-by: Andy Polyakov <ap...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4842) ----------------------------------------------------------------------- Summary of changes: apps/speed.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/apps/speed.c b/apps/speed.c index 610716d..4c6ee08 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -141,6 +141,7 @@ typedef struct loopargs_st { unsigned char *buf2; unsigned char *buf_malloc; unsigned char *buf2_malloc; + unsigned char *key; unsigned int siglen; #ifndef OPENSSL_NO_RSA RSA *rsa_key[RSA_NUM]; @@ -1266,6 +1267,8 @@ int speed_main(int argc, char **argv) int ret = 1, i, k, misalign = 0; long count = 0; int size_num = OSSL_NELEM(lengths_list); + int keylen; + int buflen; #ifndef NO_FORK int multi = 0; #endif @@ -1603,12 +1606,12 @@ int speed_main(int argc, char **argv) } } - loopargs[i].buf_malloc = - app_malloc(lengths[size_num - 1] + MAX_MISALIGNMENT + 1, - "input buffer"); - loopargs[i].buf2_malloc = - app_malloc(lengths[size_num - 1] + MAX_MISALIGNMENT + 1, - "input buffer"); + buflen = lengths[size_num - 1] + MAX_MISALIGNMENT + 1; + loopargs[i].buf_malloc = app_malloc(buflen, "input buffer"); + loopargs[i].buf2_malloc = app_malloc(buflen, "input buffer"); + memset(loopargs[i].buf_malloc, 0, buflen); + memset(loopargs[i].buf2_malloc, 0, buflen); + /* Align the start of buffers on a 64 byte boundary */ loopargs[i].buf = loopargs[i].buf_malloc + misalign; loopargs[i].buf2 = loopargs[i].buf2_malloc + misalign; @@ -2407,13 +2410,17 @@ int speed_main(int argc, char **argv) for (k = 0; k < loopargs_len; k++) { loopargs[k].ctx = EVP_CIPHER_CTX_new(); - if (decrypt) - EVP_DecryptInit_ex(loopargs[k].ctx, evp_cipher, NULL, - key32, iv); - else - EVP_EncryptInit_ex(loopargs[k].ctx, evp_cipher, NULL, - key32, iv); + EVP_CipherInit_ex(loopargs[k].ctx, evp_cipher, NULL, NULL, + iv, decrypt ? 0 : 1); + EVP_CIPHER_CTX_set_padding(loopargs[k].ctx, 0); + + keylen = EVP_CIPHER_CTX_key_length(loopargs[k].ctx); + loopargs[k].key = app_malloc(keylen, "evp_cipher key"); + EVP_CIPHER_CTX_rand_key(loopargs[k].ctx, loopargs[k].key); + EVP_CipherInit_ex(loopargs[k].ctx, NULL, NULL, + loopargs[k].key, NULL, -1); + OPENSSL_clear_free(loopargs[k].key, keylen); } switch (EVP_CIPHER_mode(evp_cipher)) { case EVP_CIPH_CCM_MODE: @@ -3241,9 +3248,9 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, const SEC *seconds) static const int mblengths_list[] = { 8 * 1024, 2 * 8 * 1024, 4 * 8 * 1024, 8 * 8 * 1024, 8 * 16 * 1024 }; const int *mblengths = mblengths_list; - int j, count, num = OSSL_NELEM(mblengths_list); + int j, count, keylen, num = OSSL_NELEM(mblengths_list); const char *alg_name; - unsigned char *inp, *out, no_key[32], no_iv[16]; + unsigned char *inp, *out, *key, no_key[32], no_iv[16]; EVP_CIPHER_CTX *ctx; double d = 0.0; @@ -3255,7 +3262,14 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, const SEC *seconds) inp = app_malloc(mblengths[num - 1], "multiblock input buffer"); out = app_malloc(mblengths[num - 1] + 1024, "multiblock output buffer"); ctx = EVP_CIPHER_CTX_new(); - EVP_EncryptInit_ex(ctx, evp_cipher, NULL, no_key, no_iv); + EVP_EncryptInit_ex(ctx, evp_cipher, NULL, NULL, no_iv); + + keylen = EVP_CIPHER_CTX_key_length(ctx); + key = app_malloc(keylen, "evp_cipher key"); + EVP_CIPHER_CTX_rand_key(ctx, key); + EVP_EncryptInit_ex(ctx, NULL, NULL, key, NULL); + OPENSSL_clear_free(key, keylen); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_MAC_KEY, sizeof(no_key), no_key); alg_name = OBJ_nid2ln(EVP_CIPHER_nid(evp_cipher)); _____ openssl-commits mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-commits