File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change 1818 \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
Original file line number Diff line number Diff 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 (key_len == ( word32 ) 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 (key_len == ( word32 ) 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
You can’t perform that action at this time.
0 commit comments