Peer review feedback. Adjust README.md and fix possible use of un-init variable.
parent
4f732c9b6b
commit
8b8915d17e
|
@ -20,8 +20,12 @@ The `ecc_keys.c` example shows how to work with storing and loading keys after t
|
|||
|
||||
## ecc_sign
|
||||
|
||||
The `ecc_verify.c` example uses NIST test vectors to demonstrate hashing a message and verifying an ECC signature.
|
||||
The `ecc_sign.c:` example takes a random message and private key, creates a signature then verifies it.
|
||||
|
||||
## ecc_verify
|
||||
|
||||
The `ecc_sign.c:` example takes a random message and private key, creates a signature then verifies it.
|
||||
The `ecc_verify.c` example uses NIST test vectors to demonstrate hashing a message and verifying an ECC signature.
|
||||
|
||||
## ecc_pub
|
||||
|
||||
The `ecc_pub` example code shows how to extracting an ECC public key from private key.
|
||||
|
|
|
@ -295,7 +295,7 @@ int main()
|
|||
int ret;
|
||||
uint8_t hash[WC_SHA256_DIGEST_SIZE];
|
||||
uint8_t sig[ECC_CURVE_SZ*2];
|
||||
uint32_t sigSz = sizeof(sig);
|
||||
uint32_t sigSz = 0;
|
||||
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
wolfSSL_Debugging_ON();
|
||||
|
@ -303,6 +303,8 @@ int main()
|
|||
|
||||
printf("Running NIST P-256,SHA-256 Sign Test\n");
|
||||
|
||||
memset(sig, 0, sizeof(sig));
|
||||
|
||||
ret = crypto_sha256(
|
||||
kMsg, sizeof(kMsg), /* input message */
|
||||
hash, sizeof(hash), /* hash digest result */
|
||||
|
@ -313,6 +315,7 @@ int main()
|
|||
/* Note: result of an ECC sign varies for each call even with same
|
||||
private key and hash. This is because a new random public key is
|
||||
used for each operation. */
|
||||
sigSz = sizeof(sig);
|
||||
ret = crypto_ecc_sign(
|
||||
kPrivKey, sizeof(kPrivKey), /* private key */
|
||||
hash, sizeof(hash), /* computed hash digest */
|
||||
|
@ -333,16 +336,18 @@ int main()
|
|||
);
|
||||
}
|
||||
|
||||
printf("Signature %d\n", sigSz);
|
||||
print_hex(sig, sigSz);
|
||||
if (ret == 0) {
|
||||
printf("Signature %d\n", sigSz);
|
||||
print_hex(sig, sigSz);
|
||||
|
||||
if (ret != 0) {
|
||||
printf("Failure %d: %s\n", ret, wc_GetErrorString(ret));
|
||||
return -1;
|
||||
printf("Success\n");
|
||||
}
|
||||
else {
|
||||
printf("Failure %d: %s\n", ret, wc_GetErrorString(ret));
|
||||
ret = -1;
|
||||
}
|
||||
printf("Success\n");
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
#else
|
||||
printf("wolfSSL requires ECC and SHA256\n");
|
||||
return -1;
|
||||
|
|
|
@ -231,11 +231,13 @@ int main()
|
|||
);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
printf("Failure %d: %s\n", ret, wc_GetErrorString(ret));
|
||||
return -1;
|
||||
if (ret == 0) {
|
||||
printf("Success\n");
|
||||
}
|
||||
else {
|
||||
printf("Failure %d: %s\n", ret, wc_GetErrorString(ret));
|
||||
ret = -1;
|
||||
}
|
||||
printf("Success\n");
|
||||
|
||||
return ret;
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue