• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FDRM_FX_CRYPT_AES_H_
8 #define CORE_FDRM_FX_CRYPT_AES_H_
9 
10 #include <stdint.h>
11 
12 #include <array>
13 
14 #include "core/fxcrt/span.h"
15 
16 struct CRYPT_aes_context {
17   static constexpr int kMaxNb = 8;
18   static constexpr int kMaxNr = 14;
19   static constexpr int kSchedSize = (kMaxNr + 1) * kMaxNb;
20 
21   int Nb;
22   int Nr;
23   std::array<uint32_t, kSchedSize> keysched;
24   std::array<uint32_t, kSchedSize> invkeysched;
25   std::array<uint32_t, kMaxNb> iv;
26 };
27 
28 void CRYPT_AESSetKey(CRYPT_aes_context* ctx,
29                      const uint8_t* key,
30                      uint32_t keylen);
31 void CRYPT_AESSetIV(CRYPT_aes_context* ctx, const uint8_t* iv);
32 void CRYPT_AESDecrypt(CRYPT_aes_context* ctx,
33                       uint8_t* dest,
34                       const uint8_t* src,
35                       uint32_t size);
36 void CRYPT_AESEncrypt(CRYPT_aes_context* ctx,
37                       pdfium::span<uint8_t> dest,
38                       pdfium::span<const uint8_t> src);
39 
40 #endif  // CORE_FDRM_FX_CRYPT_AES_H_
41