Skip to content

Commit e04fe0c

Browse files
committed
fix typo
1 parent 0e14849 commit e04fe0c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

doc/dox_comments/header_files/signature.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
WC_SIGNATURE_TYPE_RSA / WC_SIGNATURE_TYPE_RSA_W_ENC.
1616
The caller is responsible for ensuring the pointer refers to the correct
1717
type; this function cannot verify the actual runtime type of the object.
18-
\param key_len If key is non-NULL, key_len Must be exactly sizeof(ecc_key)
18+
\param key_len If key is non-NULL, key_len must be exactly sizeof(ecc_key)
1919
or sizeof(RsaKey) matching the sig_type. Passing any other value
2020
causes the function to return BAD_FUNC_ARG without dereferencing key.
21-
The conventional idiom is to pass sizeof(*key) at the call site.
21+
Always pass the size of the concrete key type at the call site: if you
22+
have a typed pointer (e.g., ecc_key* k), use sizeof(*k); otherwise use
23+
sizeof(ecc_key) or sizeof(RsaKey) directly. Do not use sizeof(*key)
24+
on the const void* parameter itself, as dereferencing void is invalid.
2225
2326
_Example_
2427
\code

wolfcrypt/src/signature.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int wc_SignatureGetSize(enum wc_SignatureType sig_type,
9898
* the const void* API cannot verify the actual runtime
9999
* type of the pointed-to object.
100100
* Callers must pass a valid ecc_key* cast to const void*. */
101-
if (key_len == sizeof(ecc_key)) {
101+
if ((size_t)key_len == sizeof(ecc_key)) {
102102
#if defined(HAVE_SELFTEST) || (defined(HAVE_FIPS) && FIPS_VERSION3_LT(5,0,0))
103103
sig_len = wc_ecc_sig_size((ecc_key*)(wc_ptr_t)key);
104104
#else
@@ -119,7 +119,7 @@ int wc_SignatureGetSize(enum wc_SignatureType sig_type,
119119
/* Verify that key_len matches exactly sizeof(RsaKey).
120120
* Same caveat as the ECC case above: size equality is necessary
121121
* but not sufficient; the caller must pass a valid RsaKey*. */
122-
if (key_len == sizeof(RsaKey)) {
122+
if ((size_t)key_len == sizeof(RsaKey)) {
123123
#if defined(HAVE_SELFTEST) || (defined(HAVE_FIPS) && FIPS_VERSION3_LT(5,0,0))
124124
sig_len = wc_RsaEncryptSize((RsaKey*)(wc_ptr_t)key);
125125
#else

0 commit comments

Comments
 (0)