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 "../../../include/fxcrt/fx_basic.h" | 7 #include "../../../include/fxcrt/fx_basic.h" |
8 #include "../../../include/fdrm/fx_crypt.h" | 8 #include "../../../include/fdrm/fx_crypt.h" |
9 #ifdef __cplusplus | 9 #ifdef __cplusplus |
10 extern "C" { | 10 extern "C" { |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 aes_encrypt(ctx, iv); | 982 aes_encrypt(ctx, iv); |
983 for (i = 0; i < 4; i++) { | 983 for (i = 0; i < 4; i++) { |
984 PUT_32BIT_MSB_FIRST(dest + 4 * i, iv[i]); | 984 PUT_32BIT_MSB_FIRST(dest + 4 * i, iv[i]); |
985 } | 985 } |
986 dest += 16; | 986 dest += 16; |
987 src += 16; | 987 src += 16; |
988 len -= 16; | 988 len -= 16; |
989 } | 989 } |
990 FXSYS_memcpy32(ctx->iv, iv, sizeof(iv)); | 990 FXSYS_memcpy32(ctx->iv, iv, sizeof(iv)); |
991 } | 991 } |
992 void CRYPT_AESSetKey(FX_LPVOID context, FX_DWORD blocklen, FX_LPCBYTE key, FX_DW
ORD keylen, FX_BOOL bEncrypt) | 992 void CRYPT_AESSetKey(void* context, FX_DWORD blocklen, const uint8_t* key, FX_DW
ORD keylen, FX_BOOL bEncrypt) |
993 { | 993 { |
994 aes_setup((AESContext*)context, blocklen, key, keylen); | 994 aes_setup((AESContext*)context, blocklen, key, keylen); |
995 } | 995 } |
996 void CRYPT_AESSetIV(FX_LPVOID context, FX_LPCBYTE iv) | 996 void CRYPT_AESSetIV(void* context, const uint8_t* iv) |
997 { | 997 { |
998 int i; | 998 int i; |
999 for (i = 0; i < ((AESContext*)context)->Nb; i++) { | 999 for (i = 0; i < ((AESContext*)context)->Nb; i++) { |
1000 ((AESContext*)context)->iv[i] = GET_32BIT_MSB_FIRST(iv + 4 * i); | 1000 ((AESContext*)context)->iv[i] = GET_32BIT_MSB_FIRST(iv + 4 * i); |
1001 } | 1001 } |
1002 } | 1002 } |
1003 void CRYPT_AESDecrypt(FX_LPVOID context, FX_LPBYTE dest, FX_LPCBYTE src, FX_DWOR
D len) | 1003 void CRYPT_AESDecrypt(void* context, uint8_t* dest, const uint8_t* src, FX_DWORD
len) |
1004 { | 1004 { |
1005 aes_decrypt_cbc(dest, src, len, (AESContext*)context); | 1005 aes_decrypt_cbc(dest, src, len, (AESContext*)context); |
1006 } | 1006 } |
1007 void CRYPT_AESEncrypt(FX_LPVOID context, FX_LPBYTE dest, FX_LPCBYTE src, FX_DWOR
D len) | 1007 void CRYPT_AESEncrypt(void* context, uint8_t* dest, const uint8_t* src, FX_DWORD
len) |
1008 { | 1008 { |
1009 aes_encrypt_cbc(dest, src, len, (AESContext*)context); | 1009 aes_encrypt_cbc(dest, src, len, (AESContext*)context); |
1010 } | 1010 } |
1011 #ifdef __cplusplus | 1011 #ifdef __cplusplus |
1012 }; | 1012 }; |
1013 #endif | 1013 #endif |
OLD | NEW |