Skip to content

Commit 64a234d

Browse files
committed
Updates per review comments
1 parent b29aabc commit 64a234d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/wp_aes_stream.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ static int wp_aes_stream_init(wp_AesStreamCtx *ctx, const unsigned char *key,
281281
const OSSL_PARAM params[], int enc)
282282
{
283283
int ok = 1;
284+
/* Decryption is the same as encryption with CTR mode. */
284285
int dir = AES_ENCRYPTION;
285286

286287
ctx->enc = enc;
@@ -299,7 +300,6 @@ static int wp_aes_stream_init(wp_AesStreamCtx *ctx, const unsigned char *key,
299300
}
300301
if (ok) {
301302
#if defined(WP_HAVE_AESCTS)
302-
/* Decryption is the same as encryption with CTR mode. */
303303
if (ctx->mode == EVP_CIPH_CBC_MODE && !enc) {
304304
dir = AES_DECRYPTION;
305305
}
@@ -320,6 +320,7 @@ static int wp_aes_stream_init(wp_AesStreamCtx *ctx, const unsigned char *key,
320320

321321
if (ok) {
322322
#if defined(WP_HAVE_AESCTS)
323+
/* We only allow one shot, always reset on init */
323324
ctx->updated = 0;
324325
#endif
325326
ok = wp_aes_stream_set_ctx_params(ctx, params);
@@ -377,6 +378,10 @@ static int wp_aes_cts_encrypt(wp_AesStreamCtx *ctx, unsigned char *out,
377378
int blocks;
378379
byte ctsBlock[AES_BLOCK_SIZE * 2];
379380

381+
/* Since AES-CTS is not a FIPS approved algo, we will never be able to call
382+
* the existing wolfSSL AES_CTS APIs with FIPS, so the implementation is
383+
* effectively copied here from wolfSSL internals. */
384+
380385
blocks = (int)((inLen + (AES_BLOCK_SIZE - 1)) / AES_BLOCK_SIZE);
381386
blocks -= 2;
382387
XMEMSET(ctsBlock, 0, AES_BLOCK_SIZE * 2);
@@ -423,6 +428,10 @@ static int wp_aes_cts_decrypt(wp_AesStreamCtx *ctx, unsigned char *out,
423428
word32 partialSz;
424429
word32 padSz;
425430

431+
/* Since AES-CTS is not a FIPS approved algo, we will never be able to call
432+
* the existing wolfSSL AES_CTS APIs with FIPS, so the implementation is
433+
* effectively copied here from wolfSSL internals. */
434+
426435
partialSz = inLen % AES_BLOCK_SIZE;
427436
if (partialSz == 0) {
428437
partialSz = AES_BLOCK_SIZE;

0 commit comments

Comments
 (0)