Merge pull request #2049 from danielinux/ecc-verify-only

Allow ECC Verify-only operations with NO_ASN and SP_MATH
This commit is contained in:
toddouska 2019-01-21 15:37:55 -08:00 committed by GitHub
commit d00dd9d7c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 53 deletions

View File

@ -28,6 +28,9 @@
/* in case user set HAVE_ECC there */
#include <wolfssl/wolfcrypt/settings.h>
/* public ASN interface */
#include <wolfssl/wolfcrypt/asn_public.h>
/*
Possible ECC enable options:
* HAVE_ECC: Overall control of ECC default: on
@ -87,12 +90,6 @@ ECC Curve Sizes:
#error Brainpool and Koblitz curves requires WOLFSSL_CUSTOM_CURVES
#endif
/* Make sure ASN is enabled for ECC sign/verify */
#if (defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)) && defined(NO_ASN)
#error ASN must be enabled for ECC sign/verify
#endif
#if defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
/* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
#define FIPS_NO_WRAPPERS
@ -6579,6 +6576,7 @@ int wc_ecc_export_private_raw(ecc_key* key, byte* qx, word32* qxLen,
#endif /* HAVE_ECC_KEY_EXPORT */
#ifndef NO_ASN
#ifdef HAVE_ECC_KEY_IMPORT
/* import private key, public part optional if (pub) passed as NULL */
int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
@ -6646,7 +6644,6 @@ int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
}
#endif /* HAVE_ECC_KEY_IMPORT */
#ifndef NO_ASN
/**
Convert ECC R,S to signature
r R component of signature

View File

@ -22118,7 +22118,7 @@ int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* r, int map, void* heap)
return err;
}
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN)
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
/* Returns 1 if the number of zero.
* Implementation is constant time.
*
@ -22130,7 +22130,7 @@ static int sp_256_iszero_8(const sp_digit* a)
return (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]) == 0;
}
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN */
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN || HAVE_ECC_VERIFY */
/* Add 1 to a. (a = a + 1)
*
* a A single precision integer.

View File

@ -27739,7 +27739,7 @@ int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* r, int map, void* heap)
return err;
}
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN)
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
/* Returns 1 if the number of zero.
* Implementation is constant time.
*
@ -27751,7 +27751,7 @@ static int sp_256_iszero_4(const sp_digit* a)
return (a[0] | a[1] | a[2] | a[3]) == 0;
}
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN */
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN || HAVE_ECC_VERIFY */
/* Add 1 to a. (a = a + 1)
*
* a A single precision integer.

View File

@ -15207,7 +15207,7 @@ int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* r, int map, void* heap)
return err;
}
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN)
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
/* Returns 1 if the number of zero.
* Implementation is constant time.
*
@ -15219,7 +15219,7 @@ static int sp_256_iszero_8(const sp_digit* a)
return (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]) == 0;
}
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN */
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN || HAVE_ECC_VERIFY */
/* Add 1 to a. (a = a + 1)
*
* a A single precision integer.

View File

@ -10909,7 +10909,7 @@ int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* r, int map, void* heap)
return err;
}
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN)
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
/* Returns 1 if the number of zero.
* Implementation is constant time.
*
@ -10922,7 +10922,7 @@ static int sp_256_iszero_10(const sp_digit* a)
a[8] | a[9]) == 0;
}
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN */
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN || HAVE_ECC_VERIFY */
/* Add 1 to a. (a = a + 1)
*
* r A single precision integer.

View File

@ -10395,7 +10395,7 @@ int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* r, int map, void* heap)
return err;
}
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN)
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
/* Returns 1 if the number of zero.
* Implementation is constant time.
*
@ -10407,7 +10407,7 @@ static int sp_256_iszero_5(const sp_digit* a)
return (a[0] | a[1] | a[2] | a[3] | a[4]) == 0;
}
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN */
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN || HAVE_ECC_VERIFY */
/* Add 1 to a. (a = a + 1)
*
* r A single precision integer.

View File

@ -15333,7 +15333,7 @@ int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* r, int map, void* heap)
return err;
}
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN)
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
/* Returns 1 if the number of zero.
* Implementation is constant time.
*
@ -15345,7 +15345,7 @@ static int sp_256_iszero_8(const sp_digit* a)
return (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]) == 0;
}
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN */
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN || HAVE_ECC_VERIFY */
/* Add 1 to a. (a = a + 1)
*
* a A single precision integer.

View File

@ -44400,7 +44400,7 @@ int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* r, int map, void* heap)
return err;
}
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN)
#if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
/* Returns 1 if the number of zero.
* Implementation is constant time.
*
@ -44412,7 +44412,7 @@ static int sp_256_iszero_4(const sp_digit* a)
return (a[0] | a[1] | a[2] | a[3]) == 0;
}
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN */
#endif /* WOLFSSL_VALIDATE_ECC_KEYGEN || HAVE_ECC_SIGN || HAVE_ECC_VERIFY */
/* Add 1 to a. (a = a + 1)
*
* a A single precision integer.

View File

@ -411,38 +411,6 @@ enum Key_Agree {
};
enum Ecc_Sum {
ECC_SECP112R1_OID = 182,
ECC_SECP112R2_OID = 183,
ECC_SECP128R1_OID = 204,
ECC_SECP128R2_OID = 205,
ECC_SECP160R1_OID = 184,
ECC_SECP160R2_OID = 206,
ECC_SECP160K1_OID = 185,
ECC_BRAINPOOLP160R1_OID = 98,
ECC_SECP192R1_OID = 520,
ECC_PRIME192V2_OID = 521,
ECC_PRIME192V3_OID = 522,
ECC_SECP192K1_OID = 207,
ECC_BRAINPOOLP192R1_OID = 100,
ECC_SECP224R1_OID = 209,
ECC_SECP224K1_OID = 208,
ECC_BRAINPOOLP224R1_OID = 102,
ECC_PRIME239V1_OID = 523,
ECC_PRIME239V2_OID = 524,
ECC_PRIME239V3_OID = 525,
ECC_SECP256R1_OID = 526,
ECC_SECP256K1_OID = 186,
ECC_BRAINPOOLP256R1_OID = 104,
ECC_X25519_OID = 365,
ECC_ED25519_OID = 256,
ECC_BRAINPOOLP320R1_OID = 106,
ECC_SECP384R1_OID = 210,
ECC_BRAINPOOLP384R1_OID = 108,
ECC_BRAINPOOLP512R1_OID = 110,
ECC_SECP521R1_OID = 211,
};
enum KDF_Sum {
PBKDF2_OID = 660

View File

@ -50,6 +50,38 @@
#define WC_RNG_TYPE_DEFINED
#endif
enum Ecc_Sum {
ECC_SECP112R1_OID = 182,
ECC_SECP112R2_OID = 183,
ECC_SECP128R1_OID = 204,
ECC_SECP128R2_OID = 205,
ECC_SECP160R1_OID = 184,
ECC_SECP160R2_OID = 206,
ECC_SECP160K1_OID = 185,
ECC_BRAINPOOLP160R1_OID = 98,
ECC_SECP192R1_OID = 520,
ECC_PRIME192V2_OID = 521,
ECC_PRIME192V3_OID = 522,
ECC_SECP192K1_OID = 207,
ECC_BRAINPOOLP192R1_OID = 100,
ECC_SECP224R1_OID = 209,
ECC_SECP224K1_OID = 208,
ECC_BRAINPOOLP224R1_OID = 102,
ECC_PRIME239V1_OID = 523,
ECC_PRIME239V2_OID = 524,
ECC_PRIME239V3_OID = 525,
ECC_SECP256R1_OID = 526,
ECC_SECP256K1_OID = 186,
ECC_BRAINPOOLP256R1_OID = 104,
ECC_X25519_OID = 365,
ECC_ED25519_OID = 256,
ECC_BRAINPOOLP320R1_OID = 106,
ECC_SECP384R1_OID = 210,
ECC_BRAINPOOLP384R1_OID = 108,
ECC_BRAINPOOLP512R1_OID = 110,
ECC_SECP521R1_OID = 211,
};
/* Certificate file Type */
enum CertType {