|
4 | 4 | \brief This function returns the maximum size of the resulting signature. |
5 | 5 |
|
6 | 6 | \return Returns SIG_TYPE_E if sig_type is not supported. Returns |
7 | | - BAD_FUNC_ARG if sig_type was invalid. A positive return value indicates |
| 7 | + BAD_FUNC_ARG if sig_type was invalid or key_len does not exactly match |
| 8 | + the size of the expected key structure. A positive return value indicates |
8 | 9 | the maximum size of a signature. |
9 | 10 |
|
10 | 11 | \param sig_type A signature type enum value such as |
11 | 12 | WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA. |
12 | | - \param key Pointer to a key structure such as ecc_key or RsaKey. |
13 | | - \param key_len Size of the key structure. |
| 13 | + \param key Pointer to the key structure corresponding to sig_type: |
| 14 | + pass an ecc_key* for WC_SIGNATURE_TYPE_ECC, or a RsaKey* for |
| 15 | + WC_SIGNATURE_TYPE_RSA / WC_SIGNATURE_TYPE_RSA_W_ENC. |
| 16 | + The caller is responsible for ensuring the pointer refers to the correct |
| 17 | + 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) |
| 19 | + or sizeof(RsaKey) matching the sig_type. Passing any other value |
| 20 | + causes the function to return BAD_FUNC_ARG without dereferencing key. |
| 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. |
14 | 25 |
|
15 | 26 | _Example_ |
16 | 27 | \code |
@@ -43,16 +54,19 @@ int wc_SignatureGetSize(enum wc_SignatureType sig_type, |
43 | 54 | \return BAD_FUNC_ARG -173, bad function argument provided |
44 | 55 | \return BUFFER_E -132, output buffer too small or input too large. |
45 | 56 |
|
46 | | - \param hash_type A hash type from the “enum wc_HashType” such as |
47 | | - “WC_HASH_TYPE_SHA256”. |
| 57 | + \param hash_type A hash type from the "enum wc_HashType" such as |
| 58 | + "WC_HASH_TYPE_SHA256". |
48 | 59 | \param sig_type A signature type enum value such as |
49 | 60 | WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA. |
50 | 61 | \param data Pointer to buffer containing the data to hash. |
51 | 62 | \param data_len Length of the data buffer. |
52 | 63 | \param sig Pointer to buffer to output signature. |
53 | 64 | \param sig_len Length of the signature output buffer. |
54 | | - \param key Pointer to a key structure such as ecc_key or RsaKey. |
55 | | - \param key_len Size of the key structure. |
| 65 | + \param key Pointer to the key structure corresponding to sig_type. |
| 66 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 67 | + to this parameter. |
| 68 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 69 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
56 | 70 |
|
57 | 71 | _Example_ |
58 | 72 | \code |
@@ -93,16 +107,19 @@ int wc_SignatureVerify( |
93 | 107 | \return BAD_FUNC_ARG -173, bad function argument provided |
94 | 108 | \return BUFFER_E -132, output buffer too small or input too large. |
95 | 109 |
|
96 | | - \param hash_type A hash type from the “enum wc_HashType” |
97 | | - such as “WC_HASH_TYPE_SHA256”. |
| 110 | + \param hash_type A hash type from the "enum wc_HashType" |
| 111 | + such as "WC_HASH_TYPE_SHA256". |
98 | 112 | \param sig_type A signature type enum value such as |
99 | 113 | WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA. |
100 | 114 | \param data Pointer to buffer containing the data to hash. |
101 | 115 | \param data_len Length of the data buffer. |
102 | 116 | \param sig Pointer to buffer to output signature. |
103 | 117 | \param sig_len Length of the signature output buffer. |
104 | | - \param key Pointer to a key structure such as ecc_key or RsaKey. |
105 | | - \param key_len Size of the key structure. |
| 118 | + \param key Pointer to the key structure corresponding to sig_type. |
| 119 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 120 | + to this parameter. |
| 121 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 122 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
106 | 123 | \param rng Pointer to an initialized RNG structure. |
107 | 124 |
|
108 | 125 | _Example_ |
@@ -166,8 +183,11 @@ int wc_SignatureGenerate( |
166 | 183 | \param hash_len Length of the hash buffer |
167 | 184 | \param sig Pointer to buffer containing the signature |
168 | 185 | \param sig_len Length of the signature buffer |
169 | | - \param key Pointer to a key structure such as ecc_key or RsaKey |
170 | | - \param key_len Size of the key structure |
| 186 | + \param key Pointer to the key structure corresponding to sig_type. |
| 187 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 188 | + to this parameter. |
| 189 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 190 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
171 | 191 |
|
172 | 192 | _Example_ |
173 | 193 | \code |
@@ -216,8 +236,11 @@ int wc_SignatureVerifyHash(enum wc_HashType hash_type, |
216 | 236 | \param hash_len Length of the hash buffer |
217 | 237 | \param sig Pointer to buffer to output signature |
218 | 238 | \param sig_len Pointer to length of signature output buffer |
219 | | - \param key Pointer to a key structure such as ecc_key or RsaKey |
220 | | - \param key_len Size of the key structure |
| 239 | + \param key Pointer to the key structure corresponding to sig_type. |
| 240 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 241 | + to this parameter. |
| 242 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 243 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
221 | 244 | \param rng Pointer to an initialized RNG structure |
222 | 245 |
|
223 | 246 | _Example_ |
@@ -266,8 +289,11 @@ int wc_SignatureGenerateHash(enum wc_HashType hash_type, |
266 | 289 | \param hash_len Length of the hash buffer |
267 | 290 | \param sig Pointer to buffer to output signature |
268 | 291 | \param sig_len Pointer to length of signature output buffer |
269 | | - \param key Pointer to a key structure such as ecc_key or RsaKey |
270 | | - \param key_len Size of the key structure |
| 292 | + \param key Pointer to the key structure corresponding to sig_type. |
| 293 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 294 | + to this parameter. |
| 295 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 296 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
271 | 297 | \param rng Pointer to an initialized RNG structure |
272 | 298 | \param verify If non-zero, verify the signature after generation |
273 | 299 |
|
@@ -317,8 +343,11 @@ int wc_SignatureGenerateHash_ex(enum wc_HashType hash_type, |
317 | 343 | \param data_len Length of the data buffer |
318 | 344 | \param sig Pointer to buffer to output signature |
319 | 345 | \param sig_len Pointer to length of signature output buffer |
320 | | - \param key Pointer to a key structure such as ecc_key or RsaKey |
321 | | - \param key_len Size of the key structure |
| 346 | + \param key Pointer to the key structure corresponding to sig_type. |
| 347 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 348 | + to this parameter. |
| 349 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 350 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
322 | 351 | \param rng Pointer to an initialized RNG structure |
323 | 352 | \param verify If non-zero, verify the signature after generation |
324 | 353 |
|
|
0 commit comments