[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Thu May 14 10:24:02 UTC 2015


The branch master has been updated
       via  167f6c93b00e1184b89d6a5c7a1ed22dbab03c68 (commit)
      from  1c7b2c0ed5d02d0d60179e0df0c49ef3f659fa77 (commit)


- Log -----------------------------------------------------------------
commit 167f6c93b00e1184b89d6a5c7a1ed22dbab03c68
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu May 14 08:44:06 2015 +0200

    Move definition of INTxx_MIN et al to internal header
    
    Having the INTxx_MIN et al macros defined in a public header is
    unnecessary and risky.  Also, it wasn't done for all platforms that
    might need it.
    
    So we move those numbers to an internal header file, do the math
    ourselves and make sure to account for the integer representations we
    know of.
    
    This introduces include/internal, which is unproblematic since we
    already use -I$(TOP)/include everywhere.  This directory is different
    from crypto/include/internal, as the former is more general internal
    headers for all of OpenSSL, while the latter is for libcrypto only.
    
    Reviewed-by: Matt Caswell <matt at openssl.org>

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

Summary of changes:
 .../rsa/rsa_depr.c => include/internal/numbers.h   | 106 +++++++++++----------
 include/openssl/e_os2.h                            |  19 ----
 2 files changed, 54 insertions(+), 71 deletions(-)
 copy crypto/rsa/rsa_depr.c => include/internal/numbers.h (62%)

diff --git a/crypto/rsa/rsa_depr.c b/include/internal/numbers.h
similarity index 62%
copy from crypto/rsa/rsa_depr.c
copy to include/internal/numbers.h
index 042b2b7..1f79ef7 100644
--- a/crypto/rsa/rsa_depr.c
+++ b/include/internal/numbers.h
@@ -1,6 +1,5 @@
-/* crypto/rsa/rsa_depr.c */
 /* ====================================================================
- * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 2015 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,55 +52,58 @@
  *
  */
 
-/*
- * NB: This file contains deprecated functions (compatibility wrappers to the
- * "new" versions).
- */
+#ifndef HEADER_NUMBERS_H
+# define HEADER_NUMBERS_H
+
+# include <limits.h>
+
+# if (-1 & 3) == 0x03		/* Two's complement */
+
+#  define __MAXUINT__(T) ((T) -1)
+#  define __MAXINT__(T) ((T) ((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T)))
+#  define __MININT__(T) (-__MAXINT__(T) - 1)
+
+# elif (-1 & 3) == 0x02		/* One's complement */
+
+#  define __MAXUINT__(T) (((T) -1) + 1)
+#  define __MAXINT__(T) ((T) ((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T)))
+#  define __MININT__(T) (-__MAXINT__(T))
+
+# elif (-1 & 3) == 0x01		/* Sign/magnitude */
+
+#  define __MAXINT__(T) ((T) (((((T) 1) << ((sizeof(T) * CHAR_BIT) - 2)) - 1) | (((T) 1) << ((sizeof(T) * CHAR_BIT) - 2))))
+#  define __MAXUINT__(T) ((T) (__MAXINT__(T) | (((T) 1) << ((sizeof(T) * CHAR_BIT) - 1))))
+#  define __MININT__(T) (-__MAXINT__(T))
+
+# else
+
+#  error "do not know the integer encoding on this architecture"
+
+# endif
+
+# ifndef INT8_MAX
+#  define INT8_MIN __MININT__(int8_t)
+#  define INT8_MAX __MAXINT__(int8_t)
+#  define UINT8_MAX __MAXUINT__(uint8_t)
+# endif
+
+# ifndef INT16_MAX
+#  define INT16_MIN __MININT__(int16_t)
+#  define INT16_MAX __MAXINT__(int16_t)
+#  define UINT16_MAX __MAXUINT__(uint16_t)
+# endif
+
+# ifndef INT32_MAX
+#  define INT32_MIN __MININT__(int32_t)
+#  define INT32_MAX __MAXINT__(int32_t)
+#  define UINT32_MAX __MAXUINT__(uint32_t)
+# endif
+
+# ifndef INT64_MAX
+#  define INT64_MIN __MININT__(int64_t)
+#  define INT64_MAX __MAXINT__(int64_t)
+#  define UINT64_MAX __MAXUINT__(uint64_t)
+# endif
 
-#include <stdio.h>
-#include <time.h>
-#include "cryptlib.h"
-#include <openssl/bn.h>
-#include <openssl/rsa.h>
-
-#ifdef OPENSSL_NO_DEPRECATED
-
-static void *dummy = &dummy;
-
-#else
-
-RSA *RSA_generate_key(int bits, unsigned long e_value,
-                      void (*callback) (int, int, void *), void *cb_arg)
-{
-    int i;
-    BN_GENCB *cb = BN_GENCB_new();
-    RSA *rsa = RSA_new();
-    BIGNUM *e = BN_new();
-
-    if (!cb || !rsa || !e)
-        goto err;
-
-    /*
-     * The problem is when building with 8, 16, or 32 BN_ULONG, unsigned long
-     * can be larger
-     */
-    for (i = 0; i < (int)sizeof(unsigned long) * 8; i++) {
-        if (e_value & (1UL << i))
-            if (BN_set_bit(e, i) == 0)
-                goto err;
-    }
-
-    BN_GENCB_set_old(cb, callback, cb_arg);
-
-    if (RSA_generate_key_ex(rsa, bits, e, cb)) {
-        BN_free(e);
-        BN_GENCB_free(cb);
-        return rsa;
-    }
- err:
-    BN_free(e);
-    RSA_free(rsa);
-    BN_GENCB_free(cb);
-    return 0;
-}
 #endif
+
diff --git a/include/openssl/e_os2.h b/include/openssl/e_os2.h
index 9df7d53..eef2a0b 100644
--- a/include/openssl/e_os2.h
+++ b/include/openssl/e_os2.h
@@ -284,25 +284,6 @@ typedef int int32_t;
 typedef unsigned int uint32_t;
 typedef __int64 int64_t;
 typedef unsigned __int64 uint64_t;
-
-#  include <limits.h>
-
-#  define INT8_MAX    SCHAR_MAX
-#  define INT8_MIN    SCHAR_MIN
-#  define UINT8_MAX   UCHAR_MAX
-
-#  define INT16_MAX   SHRT_MAX
-#  define INT16_MIN   SHRT_MIN
-#  define UINT16_MAX  USHRT_MAX
-
-#  define INT32_MAX   INT_MAX
-#  define INT32_MIN   INT_MIN
-#  define UINT32_MAX  UINT_MAX
-
-#  define INT64_MAX   _I64_MAX
-#  define INT64_MIN   _I64_MIN
-#  define UINT64_MAX  _UI64_MAX
-
 # else
 #  include <stdint.h>
 # endif


More information about the openssl-commits mailing list