Skip to content

Commit 232f6b7

Browse files
authored
Merge pull request #174 from haydenroche5/ecdsa_verify_return_code
Fix ECDSA verify error return code.
2 parents d210b99 + 5385916 commit 232f6b7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/we_ecc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static int we_pkey_ecdsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *sig
823823
* @param sigLen [in] Length of signature data.
824824
* @param tbs [in] To Be Signed data.
825825
* @param tbsLen [in] Length of To Be Signed data.
826-
* @returns 1 on success and 0 on failure.
826+
* @returns 1 on successful verification, 0 on failure, and -1 on error.
827827
*/
828828
static int we_pkey_ecdsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig,
829829
size_t sigLen, const unsigned char *tbs,
@@ -861,7 +861,7 @@ static int we_pkey_ecdsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig,
861861
/* Check for indefinite length - length not specified. */
862862
if (sig[o] == 0x80) {
863863
WOLFENGINE_ERROR_MSG(WE_LOG_PK, "Signature has indefinite length");
864-
ret = 0;
864+
ret = -1;
865865
}
866866
/* Check for multi-byte length. */
867867
else if (sig[o] > 0x80) {
@@ -880,7 +880,7 @@ static int we_pkey_ecdsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig,
880880
* SEQUENCE header length + SQUENCE data length */
881881
if ((ret == 1) && (o + len != sigLen)) {
882882
WOLFENGINE_ERROR_MSG(WE_LOG_PK, "Signature length invalid");
883-
ret = 0;
883+
ret = -1;
884884
}
885885
}
886886
if (ret == 1) {
@@ -889,7 +889,7 @@ static int we_pkey_ecdsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig,
889889
&ecc->key);
890890
if (rc != 0) {
891891
WOLFENGINE_ERROR_FUNC(WE_LOG_PK, "wc_ecc_verify_hash", rc);
892-
ret = 0;
892+
ret = -1;
893893
}
894894
}
895895
if (ret == 1) {
@@ -2485,7 +2485,7 @@ static int we_ec_key_sign(int type, const unsigned char *dgst, int dLen,
24852485
* @param dLen [in] Length of digest.
24862486
* @param sig [in] Signature data.
24872487
* @param sigLen [in] Length of signature data.
2488-
* @returns 1 on success and 0 on failure.
2488+
* @returns 11 on successful verification, 0 on failure, and -1 on error.
24892489
*/
24902490
static int we_ec_key_verify(int type, const unsigned char *dgst, int dLen,
24912491
const unsigned char *sig, int sigLen, EC_KEY *ecKey)
@@ -2511,7 +2511,7 @@ static int we_ec_key_verify(int type, const unsigned char *dgst, int dLen,
25112511
rc = wc_ecc_init(&key);
25122512
if (rc != 0) {
25132513
WOLFENGINE_ERROR_FUNC(WE_LOG_PK, "wc_ecc_init", rc);
2514-
ret = 0;
2514+
ret = -1;
25152515
}
25162516
}
25172517
if (ret == 1) {
@@ -2525,7 +2525,7 @@ static int we_ec_key_verify(int type, const unsigned char *dgst, int dLen,
25252525
rc = wc_ecc_verify_hash(sig, sigLen, dgst, dLen, &res, &key);
25262526
if (rc != 0) {
25272527
WOLFENGINE_ERROR_FUNC(WE_LOG_PK, "wc_ecc_verify_hash", rc);
2528-
ret = 0;
2528+
ret = -1;
25292529
}
25302530
}
25312531
if (ret == 1) {

src/we_rsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static int we_rsa_pub_enc_int(size_t fromLen, const unsigned char *from,
523523
}
524524
break;
525525
default:
526-
/* Unsupported padding mode for RSA encrpytion. */
526+
/* Unsupported padding mode for RSA encryption. */
527527
XSNPRINTF(errBuff, sizeof(errBuff), "Unknown padding mode: %d",
528528
rsa->padMode);
529529
WOLFENGINE_ERROR_MSG(WE_LOG_PK, errBuff);

0 commit comments

Comments
 (0)