Skip to content

Commit c105613

Browse files
authored
Update chapter06.md
1 parent 0557a04 commit c105613

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

wolfSSL/src/chapter06.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ The `wc_CryptoInfo` structure contains a union of different structures (some of
254254
To determine the type of cryptographic request and process it accordingly, one would typically use a switch-case statement on the `algo_type` field of the `wc_CryptoInfo` structure. Each case within the switch would correspond to a different cryptographic operation, such as a symmetric cipher, hashing, public key operations, etc. There is a one-to-one mapping between `wc_AlgoType` and the corresponding algo type union, which are commented in the `wc_CryptoInfo` struct definition in
255255
`wolfssl/wolfcrypt/cryptocb.h`.
256256

257-
The crypto callback should return zero on success, or a nonzero error code on failure. For unsupported algorithms, the callback should return `CRYPTOCB_UNAVAILABLE`, which will cause wolfCrypt to fall back to the internal implementation.
257+
The crypto callback should return zero on success, or a valid wolfCrypt error code on failure. For unsupported algorithms, the callback should return `CRYPTOCB_UNAVAILABLE`, which will cause wolfCrypt to fall back to the internal implementation.
258258

259259
Here's a simplified example to illustrate this:
260260

@@ -266,17 +266,17 @@ int myCryptoCallback(int devId, wc_CryptoInfo* info, void* ctx)
266266
switch (info->algo_type) {
267267
case WC_ALGO_TYPE_HASH:
268268
/* Handle hashing, using algo type union: info->hash */
269-
ret = 0; /* or non-zero error code */
269+
ret = 0; /* or wolfCrypt error code */
270270
break;
271271
272272
case WC_ALGO_TYPE_PK:
273273
/* Handle public key operations, using algo type union: info->pk */
274-
ret = 0; /* or non-zero error code */
274+
ret = 0; /* or wolfCrypt error code */
275275
break;
276276
277277
case WC_ALGO_TYPE_CIPHER:
278278
/* Handle cipher operations, using algo type union: info->cipher */
279-
ret = 0; /* or non-zero error code */
279+
ret = 0; /* or wolfCrypt error code */
280280
break;
281281
282282
/* and so on for other algo types... */
@@ -301,24 +301,24 @@ int myCryptoCallback(int devId, wc_CryptoInfo* info, void* ctx)
301301
switch (info->pk.type) { /* pk type is of type wc_PkType */
302302
case WC_PK_TYPE_ECDH:
303303
/* use info->pk.ecdh */
304-
ret = 0; /* or non-zero error code */
304+
ret = 0; /* or wolfCrypt error code */
305305
break;
306306
307307
case WC_PK_TYPE_ECDSA_SIGN:
308308
/* use info->pk.eccsign */
309-
ret = 0; /* or non-zero error code */
309+
ret = 0; /* or wolfCrypt error code */
310310
break;
311311
312312
case WC_PK_TYPE_ECDSA_VERIFY:
313313
/* use info->pk.eccverify */
314-
ret = 0; /* or non-zero error code */
314+
ret = 0; /* or wolfCrypt error code */
315315
break;
316316
}
317317
break;
318318
319319
case WC_ALGO_TYPE_RNG:
320320
/* use info->rng */
321-
ret = 0; /* or non-zero error code */
321+
ret = 0; /* or wolfCrypt error code */
322322
break;
323323
}
324324

0 commit comments

Comments
 (0)