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
21 #include <sapi/tpm20.h>
22 #include <openssl/rand.h>
23 #include <openssl/hmac.h>
24 #include "crypto_aux.h"
26 #define BYTES_TO_BITS(val) (val * 8)
28 #define INIT_SIMPLE_TPM2B_SIZE( type ) (type).t.size = sizeof( type ) - 2;
30 TPM2B_NAME * GetName(TPMI_ALG_HASH hashAlg, TPM2B_PUBLIC *obj, TPM2B_NAME *outName);
32 TSS2_RC swKeyDuplicate(
34 RSA* rsaKey, TPM2B_PUBLIC* parentKeyPublicPortion, UINT8* policyDigest, int digestSize,
36 TPM2B_DATA* encryptionKey, TPM2B_PUBLIC *swKeyPublic, TPM2B_PRIVATE *swKeyPrivate, TPM2B_ENCRYPTED_SECRET *encSymSeed);
38 void CreateDuplicationBlob(
40 TPM2B_PUBLIC_KEY_RSA *protector,
41 TPMT_PUBLIC * publicPortion,
43 TPM2B_ENCRYPTED_SECRET *plainSymSeed, TPMI_YES_NO generateInSymSeed,
44 TPM2B_DATA *encryptionKey, TPMI_YES_NO generateEncryptionKey,
47 TPM2B_PRIVATE *outDuplicate,
48 TPM2B_ENCRYPTED_SECRET *encSymSeed);
51 void CreateSwDataObject(
52 BYTE* auth, UINT16 authSize,
54 BYTE * dataToSeal, UINT16 dataSize,
55 BYTE * policyDigest, UINT16 policyDigestSize,
56 TPMT_PUBLIC * outPublic,
57 TPMT_SENSITIVE *outSens);
59 void CreateDuplicationBlob2B(
61 TPM2B_PUBLIC_KEY_RSA *protector,
62 TPM2B_PUBLIC * publicPortion,
63 TPM2B_SENSITIVE *sens,
64 TPM2B_ENCRYPTED_SECRET *plainSymSeed, TPMI_YES_NO generateInSymSeed,
65 TPM2B_DATA *encryptionKey, TPMI_YES_NO generateEncryptionKey,
67 TPM2B_PRIVATE *outDuplicate,
68 TPM2B_ENCRYPTED_SECRET *encSymSeed);
70 void CreateSwDataObject2B(
72 BYTE* auth, UINT16 authSize,
74 BYTE * policyDigest, UINT16 policyDigestSize,
76 TPM2B_PUBLIC * outPublic,
77 TPM2B_SENSITIVE *outSens);