Skip to content

Commit 8e28ab2

Browse files
committed
Address Copilot feedback: clarify typedef and fix error codes for unsupported algos
1 parent 7e7e637 commit 8e28ab2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

wolfcrypt/src/asn.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31981,7 +31981,9 @@ static int WriteCertBody(DerCert* der, byte* buf)
3198131981

3198231982

3198331983
#if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_REQ)
31984-
/* Internal typedef for callback signature if not already defined in header */
31984+
/* Internal typedef for callback signature - must match wc_SignCertCb in asn_public.h
31985+
* This fallback is needed when WOLFSSL_CERT_SIGN_CB is not defined but
31986+
* MakeSignatureCb is still used internally by the refactored MakeSignature. */
3198531987
#ifndef WOLFSSL_CERT_SIGN_CB
3198631988
typedef int (*wc_SignCertCb)(const byte* in, word32 inLen,
3198731989
byte* out, word32* outLen,
@@ -32037,25 +32039,23 @@ static int InternalSignCb(const byte* in, word32 inLen,
3203732039

3203832040
#if defined(HAVE_ED25519) && defined(HAVE_ED25519_SIGN)
3203932041
if (keyType == ED25519_TYPE && signCtx->ed25519Key) {
32040-
/* Ed25519 needs the original message, not hash */
32041-
/* Note: For Ed25519, 'in' should be the original message buffer */
32042-
/* This is a limitation of the refactoring - Ed25519 signs messages, not hashes */
32043-
ret = NOT_COMPILED_IN; /* Cannot support Ed25519 through callback path */
32042+
/* Ed25519 signs messages, not hashes - cannot use callback path */
32043+
ret = SIG_TYPE_E;
3204432044
}
3204532045
#endif /* HAVE_ED25519 && HAVE_ED25519_SIGN */
3204632046

3204732047
#if defined(HAVE_ED448) && defined(HAVE_ED448_SIGN)
3204832048
if (keyType == ED448_TYPE && signCtx->ed448Key) {
32049-
/* Ed448 needs the original message, not hash */
32050-
ret = NOT_COMPILED_IN; /* Cannot support Ed448 through callback path */
32049+
/* Ed448 signs messages, not hashes - cannot use callback path */
32050+
ret = SIG_TYPE_E;
3205132051
}
3205232052
#endif /* HAVE_ED448 && HAVE_ED448_SIGN */
3205332053

3205432054
#if defined(HAVE_FALCON)
3205532055
if (keyType == FALCON_LEVEL1_TYPE || keyType == FALCON_LEVEL5_TYPE) {
3205632056
if (signCtx->falconKey) {
32057-
/* Falcon needs the original message */
32058-
ret = NOT_COMPILED_IN; /* Cannot support Falcon through callback path */
32057+
/* Falcon signs messages, not hashes - cannot use callback path */
32058+
ret = SIG_TYPE_E;
3205932059
}
3206032060
}
3206132061
#endif /* HAVE_FALCON */
@@ -32064,8 +32064,8 @@ static int InternalSignCb(const byte* in, word32 inLen,
3206432064
if (keyType == DILITHIUM_LEVEL2_TYPE || keyType == DILITHIUM_LEVEL3_TYPE ||
3206532065
keyType == DILITHIUM_LEVEL5_TYPE) {
3206632066
if (signCtx->dilithiumKey) {
32067-
/* Dilithium needs the original message */
32068-
ret = NOT_COMPILED_IN; /* Cannot support Dilithium through callback path */
32067+
/* Dilithium signs messages, not hashes - cannot use callback path */
32068+
ret = SIG_TYPE_E;
3206932069
}
3207032070
}
3207132071
#endif /* HAVE_DILITHIUM && !WOLFSSL_DILITHIUM_NO_SIGN */
@@ -32075,8 +32075,8 @@ static int InternalSignCb(const byte* in, word32 inLen,
3207532075
keyType == SPHINCS_FAST_LEVEL5_TYPE || keyType == SPHINCS_SMALL_LEVEL1_TYPE ||
3207632076
keyType == SPHINCS_SMALL_LEVEL3_TYPE || keyType == SPHINCS_SMALL_LEVEL5_TYPE) {
3207732077
if (signCtx->sphincsKey) {
32078-
/* Sphincs needs the original message */
32079-
ret = NOT_COMPILED_IN; /* Cannot support Sphincs through callback path */
32078+
/* Sphincs signs messages, not hashes - cannot use callback path */
32079+
ret = SIG_TYPE_E;
3208032080
}
3208132081
}
3208232082
#endif /* HAVE_SPHINCS */

0 commit comments

Comments
 (0)