OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fpdfapi/parser/cpdf_crypto_handler.h" | 7 #include "core/fpdfapi/parser/cpdf_crypto_handler.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
11 #include "core/fdrm/crypto/fx_crypt.h" | 11 #include "core/fdrm/crypto/fx_crypt.h" |
12 #include "core/fpdfapi/parser/cpdf_parser.h" | 12 #include "core/fpdfapi/parser/cpdf_parser.h" |
13 #include "core/fpdfapi/parser/cpdf_security_handler.h" | 13 #include "core/fpdfapi/parser/cpdf_security_handler.h" |
14 #include "core/fpdfapi/parser/cpdf_simple_parser.h" | 14 #include "core/fpdfapi/parser/cpdf_simple_parser.h" |
15 | 15 |
16 void CPDF_CryptoHandler::CryptBlock(FX_BOOL bEncrypt, | 16 void CPDF_CryptoHandler::CryptBlock(bool bEncrypt, |
17 uint32_t objnum, | 17 uint32_t objnum, |
18 uint32_t gennum, | 18 uint32_t gennum, |
19 const uint8_t* src_buf, | 19 const uint8_t* src_buf, |
20 uint32_t src_size, | 20 uint32_t src_size, |
21 uint8_t* dest_buf, | 21 uint8_t* dest_buf, |
22 uint32_t& dest_size) { | 22 uint32_t& dest_size) { |
23 if (m_Cipher == FXCIPHER_NONE) { | 23 if (m_Cipher == FXCIPHER_NONE) { |
24 FXSYS_memcpy(dest_buf, src_buf, src_size); | 24 FXSYS_memcpy(dest_buf, src_buf, src_size); |
25 return; | 25 return; |
26 } | 26 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 ASSERT(dest_size == src_size); | 69 ASSERT(dest_size == src_size); |
70 if (dest_buf != src_buf) { | 70 if (dest_buf != src_buf) { |
71 FXSYS_memcpy(dest_buf, src_buf, src_size); | 71 FXSYS_memcpy(dest_buf, src_buf, src_size); |
72 } | 72 } |
73 CRYPT_ArcFourCryptBlock(dest_buf, dest_size, realkey, realkeylen); | 73 CRYPT_ArcFourCryptBlock(dest_buf, dest_size, realkey, realkeylen); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 struct AESCryptContext { | 77 struct AESCryptContext { |
78 uint8_t m_Context[2048]; | 78 uint8_t m_Context[2048]; |
79 FX_BOOL m_bIV; | 79 bool m_bIV; |
80 uint8_t m_Block[16]; | 80 uint8_t m_Block[16]; |
81 uint32_t m_BlockOffset; | 81 uint32_t m_BlockOffset; |
82 }; | 82 }; |
83 | 83 |
84 void* CPDF_CryptoHandler::CryptStart(uint32_t objnum, | 84 void* CPDF_CryptoHandler::CryptStart(uint32_t objnum, |
85 uint32_t gennum, | 85 uint32_t gennum, |
86 FX_BOOL bEncrypt) { | 86 bool bEncrypt) { |
87 if (m_Cipher == FXCIPHER_NONE) { | 87 if (m_Cipher == FXCIPHER_NONE) { |
88 return this; | 88 return this; |
89 } | 89 } |
90 if (m_Cipher == FXCIPHER_AES && m_KeyLen == 32) { | 90 if (m_Cipher == FXCIPHER_AES && m_KeyLen == 32) { |
91 AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1); | 91 AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1); |
92 pContext->m_bIV = TRUE; | 92 pContext->m_bIV = true; |
93 pContext->m_BlockOffset = 0; | 93 pContext->m_BlockOffset = 0; |
94 CRYPT_AESSetKey(pContext->m_Context, 16, m_EncryptKey, 32, bEncrypt); | 94 CRYPT_AESSetKey(pContext->m_Context, 16, m_EncryptKey, 32, bEncrypt); |
95 if (bEncrypt) { | 95 if (bEncrypt) { |
96 for (int i = 0; i < 16; i++) { | 96 for (int i = 0; i < 16; i++) { |
97 pContext->m_Block[i] = (uint8_t)rand(); | 97 pContext->m_Block[i] = (uint8_t)rand(); |
98 } | 98 } |
99 CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block); | 99 CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block); |
100 } | 100 } |
101 return pContext; | 101 return pContext; |
102 } | 102 } |
103 uint8_t key1[48]; | 103 uint8_t key1[48]; |
104 PopulateKey(objnum, gennum, key1); | 104 PopulateKey(objnum, gennum, key1); |
105 | 105 |
106 if (m_Cipher == FXCIPHER_AES) { | 106 if (m_Cipher == FXCIPHER_AES) { |
107 FXSYS_memcpy(key1 + m_KeyLen + 5, "sAlT", 4); | 107 FXSYS_memcpy(key1 + m_KeyLen + 5, "sAlT", 4); |
108 } | 108 } |
109 uint8_t realkey[16]; | 109 uint8_t realkey[16]; |
110 CRYPT_MD5Generate( | 110 CRYPT_MD5Generate( |
111 key1, m_Cipher == FXCIPHER_AES ? m_KeyLen + 9 : m_KeyLen + 5, realkey); | 111 key1, m_Cipher == FXCIPHER_AES ? m_KeyLen + 9 : m_KeyLen + 5, realkey); |
112 int realkeylen = m_KeyLen + 5; | 112 int realkeylen = m_KeyLen + 5; |
113 if (realkeylen > 16) { | 113 if (realkeylen > 16) { |
114 realkeylen = 16; | 114 realkeylen = 16; |
115 } | 115 } |
116 if (m_Cipher == FXCIPHER_AES) { | 116 if (m_Cipher == FXCIPHER_AES) { |
117 AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1); | 117 AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1); |
118 pContext->m_bIV = TRUE; | 118 pContext->m_bIV = true; |
119 pContext->m_BlockOffset = 0; | 119 pContext->m_BlockOffset = 0; |
120 CRYPT_AESSetKey(pContext->m_Context, 16, realkey, 16, bEncrypt); | 120 CRYPT_AESSetKey(pContext->m_Context, 16, realkey, 16, bEncrypt); |
121 if (bEncrypt) { | 121 if (bEncrypt) { |
122 for (int i = 0; i < 16; i++) { | 122 for (int i = 0; i < 16; i++) { |
123 pContext->m_Block[i] = (uint8_t)rand(); | 123 pContext->m_Block[i] = (uint8_t)rand(); |
124 } | 124 } |
125 CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block); | 125 CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block); |
126 } | 126 } |
127 return pContext; | 127 return pContext; |
128 } | 128 } |
129 void* pContext = FX_Alloc(uint8_t, 1040); | 129 void* pContext = FX_Alloc(uint8_t, 1040); |
130 CRYPT_ArcFourSetup(pContext, realkey, realkeylen); | 130 CRYPT_ArcFourSetup(pContext, realkey, realkeylen); |
131 return pContext; | 131 return pContext; |
132 } | 132 } |
133 | 133 |
134 FX_BOOL CPDF_CryptoHandler::CryptStream(void* context, | 134 bool CPDF_CryptoHandler::CryptStream(void* context, |
135 const uint8_t* src_buf, | 135 const uint8_t* src_buf, |
136 uint32_t src_size, | 136 uint32_t src_size, |
137 CFX_BinaryBuf& dest_buf, | 137 CFX_BinaryBuf& dest_buf, |
138 FX_BOOL bEncrypt) { | 138 bool bEncrypt) { |
139 if (!context) { | 139 if (!context) { |
140 return FALSE; | 140 return false; |
141 } | 141 } |
142 if (m_Cipher == FXCIPHER_NONE) { | 142 if (m_Cipher == FXCIPHER_NONE) { |
143 dest_buf.AppendBlock(src_buf, src_size); | 143 dest_buf.AppendBlock(src_buf, src_size); |
144 return TRUE; | 144 return true; |
145 } | 145 } |
146 if (m_Cipher == FXCIPHER_RC4) { | 146 if (m_Cipher == FXCIPHER_RC4) { |
147 int old_size = dest_buf.GetSize(); | 147 int old_size = dest_buf.GetSize(); |
148 dest_buf.AppendBlock(src_buf, src_size); | 148 dest_buf.AppendBlock(src_buf, src_size); |
149 CRYPT_ArcFourCrypt(context, dest_buf.GetBuffer() + old_size, src_size); | 149 CRYPT_ArcFourCrypt(context, dest_buf.GetBuffer() + old_size, src_size); |
150 return TRUE; | 150 return true; |
151 } | 151 } |
152 AESCryptContext* pContext = (AESCryptContext*)context; | 152 AESCryptContext* pContext = (AESCryptContext*)context; |
153 if (pContext->m_bIV && bEncrypt) { | 153 if (pContext->m_bIV && bEncrypt) { |
154 dest_buf.AppendBlock(pContext->m_Block, 16); | 154 dest_buf.AppendBlock(pContext->m_Block, 16); |
155 pContext->m_bIV = FALSE; | 155 pContext->m_bIV = false; |
156 } | 156 } |
157 uint32_t src_off = 0; | 157 uint32_t src_off = 0; |
158 uint32_t src_left = src_size; | 158 uint32_t src_left = src_size; |
159 while (1) { | 159 while (1) { |
160 uint32_t copy_size = 16 - pContext->m_BlockOffset; | 160 uint32_t copy_size = 16 - pContext->m_BlockOffset; |
161 if (copy_size > src_left) { | 161 if (copy_size > src_left) { |
162 copy_size = src_left; | 162 copy_size = src_left; |
163 } | 163 } |
164 FXSYS_memcpy(pContext->m_Block + pContext->m_BlockOffset, src_buf + src_off, | 164 FXSYS_memcpy(pContext->m_Block + pContext->m_BlockOffset, src_buf + src_off, |
165 copy_size); | 165 copy_size); |
166 src_off += copy_size; | 166 src_off += copy_size; |
167 src_left -= copy_size; | 167 src_left -= copy_size; |
168 pContext->m_BlockOffset += copy_size; | 168 pContext->m_BlockOffset += copy_size; |
169 if (pContext->m_BlockOffset == 16) { | 169 if (pContext->m_BlockOffset == 16) { |
170 if (!bEncrypt && pContext->m_bIV) { | 170 if (!bEncrypt && pContext->m_bIV) { |
171 CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block); | 171 CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block); |
172 pContext->m_bIV = FALSE; | 172 pContext->m_bIV = false; |
173 pContext->m_BlockOffset = 0; | 173 pContext->m_BlockOffset = 0; |
174 } else if (src_off < src_size) { | 174 } else if (src_off < src_size) { |
175 uint8_t block_buf[16]; | 175 uint8_t block_buf[16]; |
176 if (bEncrypt) { | 176 if (bEncrypt) { |
177 CRYPT_AESEncrypt(pContext->m_Context, block_buf, pContext->m_Block, | 177 CRYPT_AESEncrypt(pContext->m_Context, block_buf, pContext->m_Block, |
178 16); | 178 16); |
179 } else { | 179 } else { |
180 CRYPT_AESDecrypt(pContext->m_Context, block_buf, pContext->m_Block, | 180 CRYPT_AESDecrypt(pContext->m_Context, block_buf, pContext->m_Block, |
181 16); | 181 16); |
182 } | 182 } |
183 dest_buf.AppendBlock(block_buf, 16); | 183 dest_buf.AppendBlock(block_buf, 16); |
184 pContext->m_BlockOffset = 0; | 184 pContext->m_BlockOffset = 0; |
185 } | 185 } |
186 } | 186 } |
187 if (!src_left) { | 187 if (!src_left) { |
188 break; | 188 break; |
189 } | 189 } |
190 } | 190 } |
191 return TRUE; | 191 return true; |
192 } | 192 } |
193 FX_BOOL CPDF_CryptoHandler::CryptFinish(void* context, | 193 bool CPDF_CryptoHandler::CryptFinish(void* context, |
194 CFX_BinaryBuf& dest_buf, | 194 CFX_BinaryBuf& dest_buf, |
195 FX_BOOL bEncrypt) { | 195 bool bEncrypt) { |
196 if (!context) { | 196 if (!context) { |
197 return FALSE; | 197 return false; |
198 } | 198 } |
199 if (m_Cipher == FXCIPHER_NONE) { | 199 if (m_Cipher == FXCIPHER_NONE) { |
200 return TRUE; | 200 return true; |
201 } | 201 } |
202 if (m_Cipher == FXCIPHER_RC4) { | 202 if (m_Cipher == FXCIPHER_RC4) { |
203 FX_Free(context); | 203 FX_Free(context); |
204 return TRUE; | 204 return true; |
205 } | 205 } |
206 AESCryptContext* pContext = (AESCryptContext*)context; | 206 AESCryptContext* pContext = (AESCryptContext*)context; |
207 if (bEncrypt) { | 207 if (bEncrypt) { |
208 uint8_t block_buf[16]; | 208 uint8_t block_buf[16]; |
209 if (pContext->m_BlockOffset == 16) { | 209 if (pContext->m_BlockOffset == 16) { |
210 CRYPT_AESEncrypt(pContext->m_Context, block_buf, pContext->m_Block, 16); | 210 CRYPT_AESEncrypt(pContext->m_Context, block_buf, pContext->m_Block, 16); |
211 dest_buf.AppendBlock(block_buf, 16); | 211 dest_buf.AppendBlock(block_buf, 16); |
212 pContext->m_BlockOffset = 0; | 212 pContext->m_BlockOffset = 0; |
213 } | 213 } |
214 FXSYS_memset(pContext->m_Block + pContext->m_BlockOffset, | 214 FXSYS_memset(pContext->m_Block + pContext->m_BlockOffset, |
215 (uint8_t)(16 - pContext->m_BlockOffset), | 215 (uint8_t)(16 - pContext->m_BlockOffset), |
216 16 - pContext->m_BlockOffset); | 216 16 - pContext->m_BlockOffset); |
217 CRYPT_AESEncrypt(pContext->m_Context, block_buf, pContext->m_Block, 16); | 217 CRYPT_AESEncrypt(pContext->m_Context, block_buf, pContext->m_Block, 16); |
218 dest_buf.AppendBlock(block_buf, 16); | 218 dest_buf.AppendBlock(block_buf, 16); |
219 } else if (pContext->m_BlockOffset == 16) { | 219 } else if (pContext->m_BlockOffset == 16) { |
220 uint8_t block_buf[16]; | 220 uint8_t block_buf[16]; |
221 CRYPT_AESDecrypt(pContext->m_Context, block_buf, pContext->m_Block, 16); | 221 CRYPT_AESDecrypt(pContext->m_Context, block_buf, pContext->m_Block, 16); |
222 if (block_buf[15] <= 16) { | 222 if (block_buf[15] <= 16) { |
223 dest_buf.AppendBlock(block_buf, 16 - block_buf[15]); | 223 dest_buf.AppendBlock(block_buf, 16 - block_buf[15]); |
224 } | 224 } |
225 } | 225 } |
226 FX_Free(pContext); | 226 FX_Free(pContext); |
227 return TRUE; | 227 return true; |
228 } | 228 } |
229 | 229 |
230 void CPDF_CryptoHandler::Decrypt(uint32_t objnum, | 230 void CPDF_CryptoHandler::Decrypt(uint32_t objnum, |
231 uint32_t gennum, | 231 uint32_t gennum, |
232 CFX_ByteString& str) { | 232 CFX_ByteString& str) { |
233 CFX_BinaryBuf dest_buf; | 233 CFX_BinaryBuf dest_buf; |
234 void* context = DecryptStart(objnum, gennum); | 234 void* context = DecryptStart(objnum, gennum); |
235 DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf); | 235 DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf); |
236 DecryptFinish(context, dest_buf); | 236 DecryptFinish(context, dest_buf); |
237 str = CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize()); | 237 str = CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize()); |
238 } | 238 } |
239 | 239 |
240 void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) { | 240 void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) { |
241 return CryptStart(objnum, gennum, FALSE); | 241 return CryptStart(objnum, gennum, false); |
242 } | 242 } |
243 uint32_t CPDF_CryptoHandler::DecryptGetSize(uint32_t src_size) { | 243 uint32_t CPDF_CryptoHandler::DecryptGetSize(uint32_t src_size) { |
244 return m_Cipher == FXCIPHER_AES ? src_size - 16 : src_size; | 244 return m_Cipher == FXCIPHER_AES ? src_size - 16 : src_size; |
245 } | 245 } |
246 | 246 |
247 FX_BOOL CPDF_CryptoHandler::Init(CPDF_Dictionary* pEncryptDict, | 247 bool CPDF_CryptoHandler::Init(CPDF_Dictionary* pEncryptDict, |
248 CPDF_SecurityHandler* pSecurityHandler) { | 248 CPDF_SecurityHandler* pSecurityHandler) { |
249 const uint8_t* key; | 249 const uint8_t* key; |
250 if (!pSecurityHandler->GetCryptInfo(m_Cipher, key, m_KeyLen)) { | 250 if (!pSecurityHandler->GetCryptInfo(m_Cipher, key, m_KeyLen)) { |
251 return FALSE; | 251 return false; |
252 } | 252 } |
253 if (m_KeyLen > 32 || m_KeyLen < 0) { | 253 if (m_KeyLen > 32 || m_KeyLen < 0) { |
254 return FALSE; | 254 return false; |
255 } | 255 } |
256 if (m_Cipher != FXCIPHER_NONE) { | 256 if (m_Cipher != FXCIPHER_NONE) { |
257 FXSYS_memcpy(m_EncryptKey, key, m_KeyLen); | 257 FXSYS_memcpy(m_EncryptKey, key, m_KeyLen); |
258 } | 258 } |
259 if (m_Cipher == FXCIPHER_AES) { | 259 if (m_Cipher == FXCIPHER_AES) { |
260 m_pAESContext = FX_Alloc(uint8_t, 2048); | 260 m_pAESContext = FX_Alloc(uint8_t, 2048); |
261 } | 261 } |
262 return TRUE; | 262 return true; |
263 } | 263 } |
264 | 264 |
265 FX_BOOL CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) { | 265 bool CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) { |
266 if (cipher == FXCIPHER_AES) { | 266 if (cipher == FXCIPHER_AES) { |
267 switch (keylen) { | 267 switch (keylen) { |
268 case 16: | 268 case 16: |
269 case 24: | 269 case 24: |
270 case 32: | 270 case 32: |
271 break; | 271 break; |
272 default: | 272 default: |
273 return FALSE; | 273 return false; |
274 } | 274 } |
275 } else if (cipher == FXCIPHER_AES2) { | 275 } else if (cipher == FXCIPHER_AES2) { |
276 if (keylen != 32) { | 276 if (keylen != 32) { |
277 return FALSE; | 277 return false; |
278 } | 278 } |
279 } else if (cipher == FXCIPHER_RC4) { | 279 } else if (cipher == FXCIPHER_RC4) { |
280 if (keylen < 5 || keylen > 16) { | 280 if (keylen < 5 || keylen > 16) { |
281 return FALSE; | 281 return false; |
282 } | 282 } |
283 } else { | 283 } else { |
284 if (keylen > 32) { | 284 if (keylen > 32) { |
285 keylen = 32; | 285 keylen = 32; |
286 } | 286 } |
287 } | 287 } |
288 m_Cipher = cipher; | 288 m_Cipher = cipher; |
289 m_KeyLen = keylen; | 289 m_KeyLen = keylen; |
290 FXSYS_memcpy(m_EncryptKey, key, keylen); | 290 FXSYS_memcpy(m_EncryptKey, key, keylen); |
291 if (m_Cipher == FXCIPHER_AES) { | 291 if (m_Cipher == FXCIPHER_AES) { |
292 m_pAESContext = FX_Alloc(uint8_t, 2048); | 292 m_pAESContext = FX_Alloc(uint8_t, 2048); |
293 } | 293 } |
294 return TRUE; | 294 return true; |
295 } | 295 } |
296 FX_BOOL CPDF_CryptoHandler::DecryptStream(void* context, | 296 bool CPDF_CryptoHandler::DecryptStream(void* context, |
297 const uint8_t* src_buf, | 297 const uint8_t* src_buf, |
298 uint32_t src_size, | 298 uint32_t src_size, |
299 CFX_BinaryBuf& dest_buf) { | 299 CFX_BinaryBuf& dest_buf) { |
300 return CryptStream(context, src_buf, src_size, dest_buf, FALSE); | 300 return CryptStream(context, src_buf, src_size, dest_buf, false); |
301 } | 301 } |
302 FX_BOOL CPDF_CryptoHandler::DecryptFinish(void* context, | 302 bool CPDF_CryptoHandler::DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) { |
303 CFX_BinaryBuf& dest_buf) { | 303 return CryptFinish(context, dest_buf, false); |
304 return CryptFinish(context, dest_buf, FALSE); | |
305 } | 304 } |
306 uint32_t CPDF_CryptoHandler::EncryptGetSize(uint32_t objnum, | 305 uint32_t CPDF_CryptoHandler::EncryptGetSize(uint32_t objnum, |
307 uint32_t version, | 306 uint32_t version, |
308 const uint8_t* src_buf, | 307 const uint8_t* src_buf, |
309 uint32_t src_size) { | 308 uint32_t src_size) { |
310 if (m_Cipher == FXCIPHER_AES) { | 309 if (m_Cipher == FXCIPHER_AES) { |
311 return src_size + 32; | 310 return src_size + 32; |
312 } | 311 } |
313 return src_size; | 312 return src_size; |
314 } | 313 } |
315 FX_BOOL CPDF_CryptoHandler::EncryptContent(uint32_t objnum, | 314 bool CPDF_CryptoHandler::EncryptContent(uint32_t objnum, |
316 uint32_t gennum, | 315 uint32_t gennum, |
317 const uint8_t* src_buf, | 316 const uint8_t* src_buf, |
318 uint32_t src_size, | 317 uint32_t src_size, |
319 uint8_t* dest_buf, | 318 uint8_t* dest_buf, |
320 uint32_t& dest_size) { | 319 uint32_t& dest_size) { |
321 CryptBlock(TRUE, objnum, gennum, src_buf, src_size, dest_buf, dest_size); | 320 CryptBlock(true, objnum, gennum, src_buf, src_size, dest_buf, dest_size); |
322 return TRUE; | 321 return true; |
323 } | 322 } |
324 CPDF_CryptoHandler::CPDF_CryptoHandler() { | 323 CPDF_CryptoHandler::CPDF_CryptoHandler() { |
325 m_pAESContext = nullptr; | 324 m_pAESContext = nullptr; |
326 m_Cipher = FXCIPHER_NONE; | 325 m_Cipher = FXCIPHER_NONE; |
327 m_KeyLen = 0; | 326 m_KeyLen = 0; |
328 } | 327 } |
329 CPDF_CryptoHandler::~CPDF_CryptoHandler() { | 328 CPDF_CryptoHandler::~CPDF_CryptoHandler() { |
330 FX_Free(m_pAESContext); | 329 FX_Free(m_pAESContext); |
331 } | 330 } |
332 | 331 |
333 void CPDF_CryptoHandler::PopulateKey(uint32_t objnum, | 332 void CPDF_CryptoHandler::PopulateKey(uint32_t objnum, |
334 uint32_t gennum, | 333 uint32_t gennum, |
335 uint8_t* key) { | 334 uint8_t* key) { |
336 FXSYS_memcpy(key, m_EncryptKey, m_KeyLen); | 335 FXSYS_memcpy(key, m_EncryptKey, m_KeyLen); |
337 key[m_KeyLen + 0] = (uint8_t)objnum; | 336 key[m_KeyLen + 0] = (uint8_t)objnum; |
338 key[m_KeyLen + 1] = (uint8_t)(objnum >> 8); | 337 key[m_KeyLen + 1] = (uint8_t)(objnum >> 8); |
339 key[m_KeyLen + 2] = (uint8_t)(objnum >> 16); | 338 key[m_KeyLen + 2] = (uint8_t)(objnum >> 16); |
340 key[m_KeyLen + 3] = (uint8_t)gennum; | 339 key[m_KeyLen + 3] = (uint8_t)gennum; |
341 key[m_KeyLen + 4] = (uint8_t)(gennum >> 8); | 340 key[m_KeyLen + 4] = (uint8_t)(gennum >> 8); |
342 } | 341 } |
OLD | NEW |