Remove CRYPT_aes_context::encrypt and decrypt members.
They always hold the same function pointers. Plus, we make
these via FX_Alloc() and ideally FX_Alloc'd chunks would be
purely data.
Change-Id: Ib3eb8f4dd0c1982768a688013d772afab944ea32
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/62512
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fdrm/fx_crypt.h b/core/fdrm/fx_crypt.h
index cb3247a..90af101 100644
--- a/core/fdrm/fx_crypt.h
+++ b/core/fdrm/fx_crypt.h
@@ -19,8 +19,6 @@
#define MAX_NR 14
#define MAX_NB 8
struct CRYPT_aes_context {
- void (*encrypt)(CRYPT_aes_context* ctx, unsigned int* block);
- void (*decrypt)(CRYPT_aes_context* ctx, unsigned int* block);
int Nb;
int Nr;
unsigned int keysched[(MAX_NR + 1) * MAX_NB];
diff --git a/core/fdrm/fx_crypt_aes.cpp b/core/fdrm/fx_crypt_aes.cpp
index 4f10945..d4e446f 100644
--- a/core/fdrm/fx_crypt_aes.cpp
+++ b/core/fdrm/fx_crypt_aes.cpp
@@ -520,8 +520,6 @@
int Nk = keylen / 4;
ctx->Nb = 4;
ctx->Nr = 6 + (ctx->Nb > Nk ? ctx->Nb : Nk);
- ctx->encrypt = aes_encrypt_nb_4;
- ctx->decrypt = aes_decrypt_nb_4;
int rconst = 1;
for (int i = 0; i < (ctx->Nr + 1) * ctx->Nb; i++) {
if (i < Nk) {
@@ -574,8 +572,9 @@
}
void aes_decrypt(CRYPT_aes_context* ctx, unsigned int* block) {
- ctx->decrypt(ctx, block);
+ aes_decrypt_nb_4(ctx, block);
}
+
void aes_decrypt_cbc(unsigned char* dest,
const unsigned char* src,
int len,
@@ -601,7 +600,7 @@
}
void aes_encrypt(CRYPT_aes_context* ctx, unsigned int* block) {
- ctx->encrypt(ctx, block);
+ aes_encrypt_nb_4(ctx, block);
}
void aes_encrypt_cbc(unsigned char* dest,