Camellia fixes and improvements from HEAD.
[oweals/openssl.git] / crypto / ec / ecp_nist.c
index c28b27530e664e4ccfd9ee82bd3b0724e56de525..71893d5eaba18c01f0b7bf10106c705b1e98f391 100644 (file)
@@ -61,6 +61,8 @@
  * and contributed to the OpenSSL project.
  */
 
+#include <limits.h>
+
 #include <openssl/err.h>
 #include <openssl/obj_mac.h>
 #include "ec_lcl.h"
@@ -72,7 +74,7 @@ const EC_METHOD *EC_GFp_nist_method(void)
                ec_GFp_simple_group_init,
                ec_GFp_simple_group_finish,
                ec_GFp_simple_group_clear_finish,
-               ec_GFp_simple_group_copy,
+               ec_GFp_nist_group_copy,
                ec_GFp_nist_group_set_curve,
                ec_GFp_simple_group_get_curve,
                ec_GFp_simple_group_get_degree,
@@ -110,10 +112,16 @@ const EC_METHOD *EC_GFp_nist_method(void)
        return &ret;
        }
 
-#if BN_BITS2 == 64 && UINT_MAX != 4294967295UL && ULONG_MAX != 4294967295UL
+#if BN_BITS2 == 64
 #define        NO_32_BIT_TYPE
 #endif
 
+int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src)
+       {
+       dest->field_mod_func = src->field_mod_func;
+
+       return ec_GFp_simple_group_copy(dest, src);
+       }
 
 int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
        const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
@@ -132,28 +140,28 @@ int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
                group->field_mod_func = BN_nist_mod_192;
        else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0)
                {
-#if !defined(NO_32_BIT_TYPE) || defined(OPENSSL_NO_ASM)
+#ifndef NO_32_BIT_TYPE
                group->field_mod_func = BN_nist_mod_224;
 #else
-               ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE_GFP, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
+               ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
                goto err;
 #endif
                }
        else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0)
                {
-#if !defined(NO_32_BIT_TYPE) || defined(OPENSSL_NO_ASM)
+#ifndef NO_32_BIT_TYPE
                group->field_mod_func = BN_nist_mod_256;
 #else
-               ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE_GFP, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
+               ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
                goto err;
 #endif
                }
        else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0)
                {
-#if !defined(NO_32_BIT_TYPE) || defined(OPENSSL_NO_ASM)
+#ifndef NO_32_BIT_TYPE
                group->field_mod_func = BN_nist_mod_384;
 #else
-               ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE_GFP, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
+               ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_SUPPORTED_NIST_PRIME);
                goto err;
 #endif
                }
@@ -162,7 +170,7 @@ int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
                group->field_mod_func = BN_nist_mod_521;
        else
                {
-               ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE_GFP, EC_R_NOT_A_NIST_PRIME);
+               ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_NIST_PRIME);
                goto err;
                }