• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_H_
8 #define CORE_FDRM_FX_CRYPT_H_
9 
10 #include <stdint.h>
11 #include <array>
12 
13 #include "core/fdrm/fx_crypt_aes.h"
14 #include "core/fdrm/fx_crypt_sha.h"
15 #include "core/fxcrt/span.h"
16 
17 struct CRYPT_rc4_context {
18   static constexpr int32_t kPermutationLength = 256;
19 
20   int32_t x;
21   int32_t y;
22   std::array<int32_t, kPermutationLength> m;
23 };
24 
25 struct CRYPT_md5_context {
26   std::array<uint32_t, 2> total;
27   std::array<uint32_t, 4> state;
28   uint8_t buffer[64];
29 };
30 
31 void CRYPT_ArcFourCryptBlock(pdfium::span<uint8_t> data,
32                              pdfium::span<const uint8_t> key);
33 void CRYPT_ArcFourSetup(CRYPT_rc4_context* context,
34                         pdfium::span<const uint8_t> key);
35 void CRYPT_ArcFourCrypt(CRYPT_rc4_context* context, pdfium::span<uint8_t> data);
36 
37 CRYPT_md5_context CRYPT_MD5Start();
38 void CRYPT_MD5Update(CRYPT_md5_context* context,
39                      pdfium::span<const uint8_t> data);
40 void CRYPT_MD5Finish(CRYPT_md5_context* context,
41                      pdfium::span<uint8_t, 16> digest);
42 void CRYPT_MD5Generate(pdfium::span<const uint8_t> data,
43                        pdfium::span<uint8_t, 16> digest);
44 
45 #endif  // CORE_FDRM_FX_CRYPT_H_
46