12 #include "../Common.h" 31 #define CRYPTO_DES_KEY_SIZE 8 32 #define CRYPTO_2KTDEA_KEY_SIZE (CRYPTO_DES_KEY_SIZE * 2) 33 #define CRYPTO_3KTDEA_KEY_SIZE (CRYPTO_DES_KEY_SIZE * 3) 35 typedef uint8_t Crypto2KTDEAKeyType[CRYPTO_2KTDEA_KEY_SIZE];
36 typedef uint8_t Crypto3KTDEAKeyType[CRYPTO_3KTDEA_KEY_SIZE];
38 #define CRYPTO_DES_BLOCK_SIZE 8 39 #define CRYPTO_2KTDEA_BLOCK_SIZE (CRYPTO_DES_BLOCK_SIZE) 40 #define CRYPTO_3KTDEA_BLOCK_SIZE (CRYPTO_DES_BLOCK_SIZE) 43 typedef void (*CryptoTDEACBCFuncType)(uint16_t Count,
const void *Plaintext,
void *Ciphertext,
void *IV,
const uint8_t *Keys);
44 typedef void (*CryptoTDEAFuncType)(
const void *PlainText,
void *Ciphertext,
const uint8_t *Keys);
46 void CryptoEncryptDEA(
void *Plaintext,
void *Ciphertext,
const uint8_t *Keys);
47 void CryptoDecryptDEA(
void *Plaintext,
void *Ciphertext,
const uint8_t *Keys);
48 void EncryptDESBuffer(uint16_t Count,
const void *Plaintext,
void *Ciphertext,
const uint8_t *Keys);
49 void DecryptDESBuffer(uint16_t Count,
void *Plaintext,
const void *Ciphertext,
const uint8_t *Keys);
57 void CryptoEncrypt2KTDEA(
const void *Plaintext,
void *Ciphertext,
const uint8_t *Keys);
58 void CryptoDecrypt2KTDEA(
const void *Plaintext,
void *Ciphertext,
const uint8_t *Keys);
60 void CryptoEncrypt3KTDEA(
void *Plaintext,
void *Ciphertext,
const uint8_t *Keys);
61 void CryptoDecrypt3KTDEA(
void *Plaintext,
void *Ciphertext,
const uint8_t *Keys);
63 void Encrypt3DESBuffer(uint16_t Count,
const void *Plaintext,
void *Ciphertext,
const uint8_t *Keys);
64 void Decrypt3DESBuffer(uint16_t Count,
void *Plaintext,
const void *Ciphertext,
const uint8_t *Keys);
75 void CryptoEncrypt2KTDEA_CBCSend(uint16_t Count,
const void *Input,
void *Output,
void *IV,
const uint8_t *Keys);
76 void CryptoDecrypt2KTDEA_CBCSend(uint16_t Count,
const void *Input,
void *Output,
void *IV,
const uint8_t *Keys);
86 void CryptoEncrypt2KTDEA_CBCReceive(uint16_t Count,
const void *Input,
void *Output,
void *IV,
const uint8_t *Keys);
87 void CryptoDecrypt2KTDEA_CBCReceive(uint16_t Count,
const void *Input,
void *Output,
void *IV,
const uint8_t *Keys);
98 void CryptoEncrypt3KTDEA_CBCSend(uint16_t Count,
const void *Plaintext,
void *Ciphertext,
void *IV,
const uint8_t *Keys);
99 void CryptoDecrypt3KTDEA_CBCReceive(uint16_t Count,
const void *Plaintext,
void *Ciphertext,
void *IV,
const uint8_t *Keys);
103 CryptoTDEAFuncType cryptFunc;
105 } CryptoTDEA_CBCSpec;
107 void CryptoTDEA_CBCSend(uint16_t Count,
void *Plaintext,
void *Ciphertext,
108 void *IV,
const uint8_t *Keys, CryptoTDEA_CBCSpec CryptoSpec);
109 void CryptoTDEA_CBCRecv(uint16_t Count,
void *Plaintext,
void *Ciphertext,
110 void *IV,
const uint8_t *Keys, CryptoTDEA_CBCSpec CryptoSpec);
112 uint8_t TransferEncryptTDEASend(uint8_t *Buffer, uint8_t Count);
113 uint8_t TransferEncryptTDEAReceive(uint8_t *Buffer, uint8_t Count);
121 INLINE
void CryptoPaddingTDEA(uint8_t *Buffer, uint8_t BytesInBuffer,
bool FirstPaddingBitSet) {
122 uint8_t PaddingByte = FirstPaddingBitSet << 7;
125 for (i = BytesInBuffer; i < CRYPTO_DES_BLOCK_SIZE; ++i) {
126 Buffer[i] = PaddingByte;