ecc_sign_determinisitic.c for deterministic SHA256, SHA384, and SHA512 for SECP256R1, SECP384R1, SECP521R1.

ecc_sign_deterministic
aidan garske 2024-07-01 08:46:26 -07:00
parent f6e6fecdfa
commit c0b7ae1076
2 changed files with 8 additions and 5 deletions

Binary file not shown.

View File

@ -43,8 +43,8 @@ gcc -lwolfssl -o ecc_sign ecc_sign.c
/* message = "sample": */ /* message = "sample": */
static const char kMsg[] = "sample"; static const char kMsg[] = "sample";
#define DIGEST_SZ WC_SHA384_DIGEST_SIZE #define DIGEST_SZ WC_SHA256_DIGEST_SIZE
#define HASH_FUNC crypto_sha384 #define HASH_FUNC crypto_sha256
#if 0 #if 0
@ -73,7 +73,7 @@ static const char kMsg[] = "sample";
0x77, 0xA3, 0xC2, 0x94, 0xD4, 0x46, 0x22, 0x99 0x77, 0xA3, 0xC2, 0x94, 0xD4, 0x46, 0x22, 0x99
}; };
#elif 1 #elif 0
/* SECP384R1 */ /* SECP384R1 */
#define ECC_KEY_CURVE ECC_SECP384R1 #define ECC_KEY_CURVE ECC_SECP384R1
@ -106,7 +106,7 @@ static const char kMsg[] = "sample";
0x73, 0x44, 0xFD, 0x25, 0x33, 0x26, 0x47, 0x20 0x73, 0x44, 0xFD, 0x25, 0x33, 0x26, 0x47, 0x20
}; };
#elif 0 #elif 1
/* SECP521R1 */ /* SECP521R1 */
#define ECC_KEY_CURVE ECC_SECP521R1 #define ECC_KEY_CURVE ECC_SECP521R1
@ -453,7 +453,10 @@ int main()
wolfSSL_Debugging_ON(); wolfSSL_Debugging_ON();
#endif #endif
printf("Running NIST P-%d,SHA-%d Deterministic Sign Test\n", ECC_KEY_SIZE*8, DIGEST_SZ*8); if (ECC_KEY_SIZE == 66)
printf("Running NIST P-%d,SHA-%d Deterministic Sign Test\n", (ECC_KEY_SIZE*8)-7, DIGEST_SZ*8);
else
printf("Running NIST P-%d,SHA-%d Deterministic Sign Test\n", (ECC_KEY_SIZE*8), DIGEST_SZ*8);
memset(sig, 0, sizeof(sig)); memset(sig, 0, sizeof(sig));