2 * Copyright 2018 Intel Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 // Author: Arun Kumar Sekar
22 #include <tss2/tss2_sys.h>
23 #include <tss2/tss2_tcti_mssim.h>
24 #include <tss2/tss2_tpm2_types.h>
25 #include <tss2/tpm2b.h>
26 #include <openssl/rsa.h>
27 #include <openssl/aes.h>
28 #include <openssl/sha.h>
29 #include <openssl/hmac.h>
30 #include <openssl/evp.h>
34 int RSA_OAEP_Enc(TPM2B_PUBLIC_KEY_RSA *plain, // plain text to encrypt
35 //Size of plain (0 <= pl <= kl - (2 * hashLen + 2)
36 TPM2B_PUBLIC_KEY_RSA *cipher, // must be same size as key in bytes
37 TPM2B_PUBLIC_KEY_RSA *key, // Key in big endian byte array
38 TPM2B_DATA *encoding_params // Null terminated string like
39 // ((unsigned char*)"DUPLICATE")
40 // length of encoding parameter includes \0
41 // (10 in DUPLICATE case..)
44 void AES_128_CFB_enc_dec(
47 const TPM2B *const key,
48 const TPM2B *const ivIn,
50 const TPMI_YES_NO enc);
54 TPM2_RC KDFa( TPMI_ALG_HASH hashAlg, TPM2B *key, char *label,
55 TPM2B *contextU, TPM2B *contextV, UINT16 bits, TPM2B_MAX_BUFFER *resultKey );
57 UINT32 OpenSslHmac( TPMI_ALG_HASH hashAlg, TPM2B *key,TPM2B **bufferList, TPM2B_DIGEST *result );
59 void print_buff(char * data, int len, const PBYTE buff);