s390x assembly pack: cleanse only sensitive fields
authorPatrick Steuer <patrick.steuer@de.ibm.com>
Tue, 24 Sep 2019 12:44:27 +0000 (14:44 +0200)
committerPatrick Steuer <patrick.steuer@de.ibm.com>
Wed, 25 Sep 2019 13:53:53 +0000 (15:53 +0200)
of instruction parameter blocks.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10004)

crypto/ec/ecp_s390x_nistp.c

index be81f0b8f0cb3f2e268af31d1ba778e526e33fb3..9533698b0fa968c5f3735a7103f61344a07a8324 100644 (file)
@@ -110,7 +110,7 @@ ret:
     /* Otherwise use default. */
     if (rc == -1)
         rc = ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);
-    OPENSSL_cleanse(param, sizeof(param));
+    OPENSSL_cleanse(param + S390X_OFF_SCALAR(len), len);
     BN_CTX_end(ctx);
     BN_CTX_free(new_ctx);
     return rc;
@@ -203,7 +203,7 @@ static ECDSA_SIG *ecdsa_s390x_nistp_sign_sig(const unsigned char *dgst,
 
     ok = 1;
 ret:
-    OPENSSL_cleanse(param, sizeof(param));
+    OPENSSL_cleanse(param + S390X_OFF_K(len), 2 * len);
     if (ok != 1) {
         ECDSA_SIG_free(sig);
         sig = NULL;