[openssl] master update

Richard Levitte levitte at openssl.org
Thu Jan 23 16:18:59 UTC 2020


The branch master has been updated
       via  c24937d5e71a990763f227be229ad41aab44728f (commit)
      from  a88aef32c902b79261c53a16546f4adbf6b3a617 (commit)


- Log -----------------------------------------------------------------
commit c24937d5e71a990763f227be229ad41aab44728f
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Jan 22 14:00:21 2020 +0100

    Add internal maxsize macros
    
    We've started to see "magic" numbers being used for certain sizes,
    such as algorithm names and property query strings.
    
    This change takes care of the few items where buffers for algorithm
    names and property query strings are used.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
    (Merged from https://github.com/openssl/openssl/pull/10928)

-----------------------------------------------------------------------

Summary of changes:
 include/{crypto/dh.h => internal/sizes.h}       | 15 ++++++++++-----
 providers/implementations/asymciphers/rsa_enc.c |  5 +++--
 providers/implementations/signature/dsa.c       |  4 ++--
 3 files changed, 15 insertions(+), 9 deletions(-)
 copy include/{crypto/dh.h => internal/sizes.h} (50%)

diff --git a/include/crypto/dh.h b/include/internal/sizes.h
similarity index 50%
copy from include/crypto/dh.h
copy to include/internal/sizes.h
index 4032bdc10e..fab5cbdec7 100644
--- a/include/crypto/dh.h
+++ b/include/internal/sizes.h
@@ -7,9 +7,14 @@
  * https://www.openssl.org/source/license.html
  */
 
-#include <openssl/dh.h>
+#ifndef OSSL_INTERNAL_SIZES_H
+# define OSSL_INTERNAL_SIZES_H
 
-int dh_compute_key(OPENSSL_CTX *ctx, unsigned char *key, const BIGNUM *pub_key,
-                   DH *dh);
-int dh_compute_key_padded(OPENSSL_CTX *ctx, unsigned char *key,
-                          const BIGNUM *pub_key, DH *dh);
+/*
+ * Max sizes used to allocate buffers with a fixed sizes, for example for
+ * stack allocations, structure fields, ...
+ */
+# define OSSL_MAX_NAME_SIZE           50 /* Algorithm name */
+# define OSSL_MAX_PROPQUERY_SIZE     256 /* Property query strings */
+
+#endif
diff --git a/providers/implementations/asymciphers/rsa_enc.c b/providers/implementations/asymciphers/rsa_enc.c
index 53fc6de265..77f807e7ef 100644
--- a/providers/implementations/asymciphers/rsa_enc.c
+++ b/providers/implementations/asymciphers/rsa_enc.c
@@ -17,6 +17,7 @@
 /* Just for SSL_MAX_MASTER_KEY_LENGTH */
 #include <openssl/ssl.h>
 #include "internal/constant_time.h"
+#include "internal/sizes.h"
 #include "crypto/rsa.h"
 #include "prov/providercommonerr.h"
 #include "prov/provider_ctx.h"
@@ -322,8 +323,8 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[])
 {
     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
     const OSSL_PARAM *p;
-    /* Should be big enough */
-    char mdname[80], mdprops[80] = { '\0' };
+    char mdname[OSSL_MAX_NAME_SIZE];
+    char mdprops[OSSL_MAX_PROPQUERY_SIZE] = { '\0' };
     char *str = mdname;
     int pad_mode;
 
diff --git a/providers/implementations/signature/dsa.c b/providers/implementations/signature/dsa.c
index c656a45fd7..9892e6d5e4 100644
--- a/providers/implementations/signature/dsa.c
+++ b/providers/implementations/signature/dsa.c
@@ -13,6 +13,7 @@
 #include <openssl/dsa.h>
 #include <openssl/params.h>
 #include <openssl/evp.h>
+#include "internal/sizes.h"
 #include "prov/implementations.h"
 #include "prov/provider_ctx.h"
 #include "crypto/dsa.h"
@@ -49,8 +50,7 @@ typedef struct {
     OPENSSL_CTX *libctx;
     DSA *dsa;
     size_t mdsize;
-    /* Should be big enough */
-    char mdname[80];
+    char mdname[OSSL_MAX_NAME_SIZE];
     EVP_MD *md;
     EVP_MD_CTX *mdctx;
 } PROV_DSA_CTX;


More information about the openssl-commits mailing list