Fix AES-256 key initialization.

This commit is contained in:
Michael R Sweet
2026-01-10 14:44:47 -05:00
parent 846b0c9c7f
commit 0feace3eb5
3 changed files with 5 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ v1.7.0 - YYYY-MM-DD
-------------------
- Now use TTF 1.1 or later for font support.
- Fixed a buffer overflow in the (still not enabled) AES-256 code.
v1.6.2 - YYYY-MM-DD

View File

@@ -1,7 +1,7 @@
//
// AES functions for PDFio.
//
// Copyright © 2021-2025 by Michael R Sweet.
// Copyright © 2021-2026 by Michael R Sweet.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
@@ -117,7 +117,7 @@ _pdfioCryptoAESInit(
memcpy(ctx->round_key, key, keylen);
// All other round keys are found from the previous round keys.
for (rkptr0 = ctx->round_key, rkptr = rkptr0 + keylen, rkend = rkptr + 16 * ctx->round_size, i = nwords; rkptr < rkend; i ++)
for (rkptr0 = ctx->round_key, rkptr = rkptr0 + keylen, rkend = rkptr0 + 16 * ctx->round_size + 16, i = nwords; rkptr < rkend; i ++)
{
if ((i % nwords) == 0)
{

View File

@@ -1,7 +1,7 @@
//
// Private header file for PDFio.
//
// Copyright © 2021-2025 by Michael R Sweet.
// Copyright © 2021-2026 by Michael R Sweet.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
@@ -176,7 +176,7 @@ typedef struct _pdfio_value_s // Value structure
typedef struct _pdfio_aes_s // AES encryption state
{
size_t round_size; // Size of round key
uint8_t round_key[240], // Round key
uint8_t round_key[256], // Round key
iv[16]; // Initialization vector
} _pdfio_aes_t;