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 <openssl/rand.h>
22 #include <openssl/hmac.h>
23 #include "crypto_aux.h"
25 #define BYTES_TO_BITS(val) (val * 8)
27 #define INIT_SIMPLE_TPM2B_SIZE( type ) (type).size = sizeof( type ) - 2;
29 TPM2B_NAME * GetName(TPMI_ALG_HASH hashAlg, TPM2B_PUBLIC *obj);
31 TSS2_RC swKeyDuplicate(
32 RSA* rsaKey, TPM2B_PUBLIC* parentKeyPublicPortion, UINT8* policyDigest, int digestSize,
34 TPM2B* encryptionKey, TPM2B_PUBLIC *swKeyPublic, TPM2B_PRIVATE *swKeyPrivate, TPM2B_ENCRYPTED_SECRET *encSymSeed);
37 void CreateDuplicationBlob(
39 TPM2B_PUBLIC_KEY_RSA *protector,
40 TPMT_PUBLIC * publicPortion,
42 TPM2B *plainSymSeed, TPMI_YES_NO generateInSymSeed,
43 TPM2B encryptionKey, TPMI_YES_NO generateEncryptionKey,
46 TPM2B_PRIVATE *outDuplicate,
47 TPM2B_ENCRYPTED_SECRET *encSymSeed);
50 void CreateSwDataObject(
51 BYTE* auth, UINT16 authSize,
53 BYTE * dataToSeal, UINT16 dataSize,
54 BYTE * policyDigest, UINT16 policyDigestSize,
55 TPMT_PUBLIC * outPublic,
56 TPMT_SENSITIVE *outSens);
58 void CreateDuplicationBlob2B(
60 TPM2B_PUBLIC_KEY_RSA *protector,
61 TPM2B_PUBLIC * public2B,
62 TPM2B_SENSITIVE *sens2B,
63 TPM2B *plainSymSeed, TPMI_YES_NO generateInSymSeed,
64 TPM2B 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);