aboutsummaryrefslogtreecommitdiff
path: root/TPMCmd/tpm/include/wolf/TpmToWolfSym.h
diff options
context:
space:
mode:
Diffstat (limited to 'TPMCmd/tpm/include/wolf/TpmToWolfSym.h')
-rw-r--r--TPMCmd/tpm/include/wolf/TpmToWolfSym.h40
1 files changed, 17 insertions, 23 deletions
diff --git a/TPMCmd/tpm/include/wolf/TpmToWolfSym.h b/TPMCmd/tpm/include/wolf/TpmToWolfSym.h
index 7695a2d..d970bd8 100644
--- a/TPMCmd/tpm/include/wolf/TpmToWolfSym.h
+++ b/TPMCmd/tpm/include/wolf/TpmToWolfSym.h
@@ -35,23 +35,18 @@
//** Introduction
//
-// This header file is used to 'splice' the OpenSSL library into the TPM code.
-//
-// The support required of a library are a hash module, a block cipher module and
-// portions of a big number library.
+// This header file is used to 'splice' the wolfcrypt library into the TPM code.
#ifndef _TPM_TO_WOLF_SYM_H_
#define _TPM_TO_WOLF_SYM_H_
#if SYM_LIB == WOLF
-#include <openssl/aes.h>
-#include <openssl/des.h>
-#include <openssl/bn.h>
-#include <openssl/ossl_typ.h>
+#include <wolfSSL/wolfCrypt/aes.h>
+#include <wolfSSL/wolfCrypt/des3.h>
//***************************************************************
-//** Links to the OpenSSL AES code
+//** Links to the wolfCrypt AES code
//***************************************************************
#ifdef TPM_ALG_SM4
@@ -65,9 +60,9 @@
// Define the order of parameters to the library functions that do block encryption
// and decryption.
typedef void(*TpmCryptSetSymKeyCall_t)(
- const BYTE *in,
+ void *keySchedule,
BYTE *out,
- void *keySchedule
+ const BYTE *in
);
// The Crypt functions that call the block encryption function use the parameters
@@ -75,24 +70,24 @@ typedef void(*TpmCryptSetSymKeyCall_t)(
// 1) keySchedule
// 2) in buffer
// 3) out buffer
-// Since open SSL uses the order in encryptoCall_t above, need to swizzle the
+// Since wolfcrypt uses the order in encryptoCall_t above, need to swizzle the
// values to the order required by the library.
#define SWIZZLE(keySchedule, in, out) \
- (const BYTE *)(in), (BYTE *)(out), (void *)(keySchedule)
+ (void *)(keySchedule), (BYTE *)(out), (const BYTE *)(in)
// Macros to set up the encryption/decryption key schedules
//
// AES:
#define TpmCryptSetEncryptKeyAES(key, keySizeInBits, schedule) \
- AES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES *)(schedule))
+ wc_AesSetKeyDirect((tpmKeyScheduleAES *)(schedule), key, BITS_TO_BYTES(keySizeInBits), 0, AES_ENCRYPTION)
#define TpmCryptSetDecryptKeyAES(key, keySizeInBits, schedule) \
- AES_set_decrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES *)(schedule))
+ wc_AesSetKeyDirect((tpmKeyScheduleAES *)(schedule), key, BITS_TO_BYTES(keySizeInBits), 0, AES_DECRYPTION)
// TDES:
#define TpmCryptSetEncryptKeyTDES(key, keySizeInBits, schedule) \
- TDES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule))
+ TDES_setup_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule))
#define TpmCryptSetDecryptKeyTDES(key, keySizeInBits, schedule) \
- TDES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule))
+ TDES_setup_decrypt_key((key), (keySizeInBits), (tpmKeyScheduleTDES *)(schedule))
// Macros to alias encryption calls to specific algorithms. This should be used
// sparingly. Currently, only used by CryptRand.c
@@ -100,19 +95,18 @@ typedef void(*TpmCryptSetSymKeyCall_t)(
// When using these calls, to call the AES block encryption code, the caller
// should use:
// TpmCryptEncryptAES(SWIZZLE(keySchedule, in, out));
-#define TpmCryptEncryptAES AES_encrypt
-#define TpmCryptDecryptAES AES_decrypt
-#define tpmKeyScheduleAES AES_KEY
-
+#define TpmCryptEncryptAES wc_AesEncryptDirect
+#define TpmCryptDecryptAES wc_AesDecryptDirect
+#define tpmKeyScheduleAES Aes
#define TpmCryptEncryptTDES TDES_encrypt
#define TpmCryptDecryptTDES TDES_decrypt
-#define tpmKeyScheduleTDES DES_key_schedule
+#define tpmKeyScheduleTDES Des3
typedef union tpmCryptKeySchedule_t tpmCryptKeySchedule_t;
#ifdef TPM_ALG_TDES
-#include "TpmToOsslDesSupport_fp.h"
+#include "TpmToWolfDesSupport_fp.h"
#endif
// This definition would change if there were something to report