|
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* (cast to const void*) for |
| 15 | + WC_SIGNATURE_TYPE_ECC, or a RsaKey* for |
| 16 | + WC_SIGNATURE_TYPE_RSA / WC_SIGNATURE_TYPE_RSA_W_ENC. |
| 17 | + The caller is responsible for ensuring the pointer refers to the correct |
| 18 | + type; this function cannot verify the actual runtime type of the object. |
| 19 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 20 | + sizeof(RsaKey) matching the sig_type. Passing any other value |
| 21 | + causes the function to return BAD_FUNC_ARG without dereferencing key. |
| 22 | + The conventional idiom is to pass sizeof(*key) at the call site. |
14 | 23 |
|
15 | 24 | _Example_ |
16 | 25 | \code |
@@ -43,16 +52,19 @@ int wc_SignatureGetSize(enum wc_SignatureType sig_type, |
43 | 52 | \return BAD_FUNC_ARG -173, bad function argument provided |
44 | 53 | \return BUFFER_E -132, output buffer too small or input too large. |
45 | 54 |
|
46 | | - \param hash_type A hash type from the “enum wc_HashType” such as |
47 | | - “WC_HASH_TYPE_SHA256”. |
| 55 | + \param hash_type A hash type from the "enum wc_HashType" such as |
| 56 | + "WC_HASH_TYPE_SHA256". |
48 | 57 | \param sig_type A signature type enum value such as |
49 | 58 | WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA. |
50 | 59 | \param data Pointer to buffer containing the data to hash. |
51 | 60 | \param data_len Length of the data buffer. |
52 | 61 | \param sig Pointer to buffer to output signature. |
53 | 62 | \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. |
| 63 | + \param key Pointer to the key structure corresponding to sig_type. |
| 64 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 65 | + to this parameter. |
| 66 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 67 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
56 | 68 |
|
57 | 69 | _Example_ |
58 | 70 | \code |
@@ -93,16 +105,19 @@ int wc_SignatureVerify( |
93 | 105 | \return BAD_FUNC_ARG -173, bad function argument provided |
94 | 106 | \return BUFFER_E -132, output buffer too small or input too large. |
95 | 107 |
|
96 | | - \param hash_type A hash type from the “enum wc_HashType” |
97 | | - such as “WC_HASH_TYPE_SHA256”. |
| 108 | + \param hash_type A hash type from the "enum wc_HashType" |
| 109 | + such as "WC_HASH_TYPE_SHA256". |
98 | 110 | \param sig_type A signature type enum value such as |
99 | 111 | WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA. |
100 | 112 | \param data Pointer to buffer containing the data to hash. |
101 | 113 | \param data_len Length of the data buffer. |
102 | 114 | \param sig Pointer to buffer to output signature. |
103 | 115 | \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. |
| 116 | + \param key Pointer to the key structure corresponding to sig_type. |
| 117 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 118 | + to this parameter. |
| 119 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 120 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
106 | 121 | \param rng Pointer to an initialized RNG structure. |
107 | 122 |
|
108 | 123 | _Example_ |
@@ -166,8 +181,11 @@ int wc_SignatureGenerate( |
166 | 181 | \param hash_len Length of the hash buffer |
167 | 182 | \param sig Pointer to buffer containing the signature |
168 | 183 | \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 |
| 184 | + \param key Pointer to the key structure corresponding to sig_type. |
| 185 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 186 | + to this parameter. |
| 187 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 188 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
171 | 189 |
|
172 | 190 | _Example_ |
173 | 191 | \code |
@@ -216,8 +234,11 @@ int wc_SignatureVerifyHash(enum wc_HashType hash_type, |
216 | 234 | \param hash_len Length of the hash buffer |
217 | 235 | \param sig Pointer to buffer to output signature |
218 | 236 | \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 |
| 237 | + \param key Pointer to the key structure corresponding to sig_type. |
| 238 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 239 | + to this parameter. |
| 240 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 241 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
221 | 242 | \param rng Pointer to an initialized RNG structure |
222 | 243 |
|
223 | 244 | _Example_ |
@@ -266,8 +287,11 @@ int wc_SignatureGenerateHash(enum wc_HashType hash_type, |
266 | 287 | \param hash_len Length of the hash buffer |
267 | 288 | \param sig Pointer to buffer to output signature |
268 | 289 | \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 |
| 290 | + \param key Pointer to the key structure corresponding to sig_type. |
| 291 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 292 | + to this parameter. |
| 293 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 294 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
271 | 295 | \param rng Pointer to an initialized RNG structure |
272 | 296 | \param verify If non-zero, verify the signature after generation |
273 | 297 |
|
@@ -317,8 +341,11 @@ int wc_SignatureGenerateHash_ex(enum wc_HashType hash_type, |
317 | 341 | \param data_len Length of the data buffer |
318 | 342 | \param sig Pointer to buffer to output signature |
319 | 343 | \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 |
| 344 | + \param key Pointer to the key structure corresponding to sig_type. |
| 345 | + See wc_SignatureGetSize() for the type-safety constraints that apply |
| 346 | + to this parameter. |
| 347 | + \param key_len Must be exactly sizeof(ecc_key) or |
| 348 | + sizeof(RsaKey) matching sig_type. See wc_SignatureGetSize(). |
322 | 349 | \param rng Pointer to an initialized RNG structure |
323 | 350 | \param verify If non-zero, verify the signature after generation |
324 | 351 |
|
|
0 commit comments