From 6faa8391f9085de7e4316f00b28af1007c2b3dde Mon Sep 17 00:00:00 2001 From: jordan Date: Fri, 1 Dec 2023 12:28:14 -0600 Subject: [PATCH] Add missing AesInit comments to documentation. --- wolfSSL/src-ja/chapter10.md | 3 +++ wolfSSL/src/chapter10.md | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/wolfSSL/src-ja/chapter10.md b/wolfSSL/src-ja/chapter10.md index 50d61839..3c030e55 100644 --- a/wolfSSL/src-ja/chapter10.md +++ b/wolfSSL/src-ja/chapter10.md @@ -295,6 +295,9 @@ const byte iv[]={ /*some 16 byte iv*/ }; byte plain[32]; /*an increment of 16, fill with data*/ byte cipher[32]; +wc_AesInit(&enc, HEAP_HINT, INVALID_DEVID); +wc_AesInit(&dec, HEAP_HINT, INVALID_DEVID); + /*encrypt*/ wc_AesSetKey(&enc, key, sizeof(key), iv, AES_ENCRYPTION); wc_AesCbcEncrypt(&enc, cipher, plain, sizeof(plain)); diff --git a/wolfSSL/src/chapter10.md b/wolfSSL/src/chapter10.md index 288e8cea..31e22b9a 100644 --- a/wolfSSL/src/chapter10.md +++ b/wolfSSL/src/chapter10.md @@ -180,6 +180,8 @@ wc_Poly1305Final(&pmac, pmacDigest); wolfCrypt provides support for AES with key sizes of 16 bytes (128 bits), 24 bytes (192 bits), or 32 bytes (256 bits). Supported AES modes include CBC, CTR, GCM, and CCM-8. +**NOTE**: [`wc_AesInit()`](group__AES.md#function-wc_aesinit) should always be called first to initialize the `Aes` structure, before calling other `Aes` API functions such as [`wc_AesSetKey()`](group__AES.md#function-wc_aessetkey), and [`wc_AesGcmSetKey()`](group__AES.md#function-wc_aesgcmsetkey). + CBC mode is supported for both encryption and decryption and is provided through the [`wc_AesSetKey()`](group__AES.md#function-wc_aessetkey), [`wc_AesCbcEncrypt()`](group__AES.md#function-wc_aescbcencrypt) and [`wc_AesCbcDecrypt()`](group__AES.md#function-wc_aescbcdecrypt) functions. Please include the header `wolfssl/wolfcrypt/aes.h` to use AES. AES has a block size of 16 bytes and the IV should also be 16 bytes. Function usage is usually as follows: ```c @@ -192,6 +194,9 @@ const byte iv[] = { /*some 16 byte iv*/ }; byte plain[32]; /*an increment of 16, fill with data*/ byte cipher[32]; +wc_AesInit(&enc, HEAP_HINT, INVALID_DEVID); +wc_AesInit(&dec, HEAP_HINT, INVALID_DEVID); + /*encrypt*/ wc_AesSetKey(&enc, key, sizeof(key), iv, AES_ENCRYPTION); wc_AesCbcEncrypt(&enc, cipher, plain, sizeof(plain));