Upgrade Duplicate utility to the latest tss
[aaf/sshsm.git] / tpm-util / duplicate / include / tpm_duplication_aux.h
1 /*
2  * Copyright 2018 Intel Corporation
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 // Author: Arun Kumar Sekar
17
18 #ifndef     TPM_DUP_AUX
19 #define     TPM_DUP_AUX
20
21 #include <openssl/rand.h>
22 #include <openssl/hmac.h>
23 #include "crypto_aux.h"
24
25 #define BYTES_TO_BITS(val) (val * 8)
26
27 #define INIT_SIMPLE_TPM2B_SIZE( type ) (type).size = sizeof( type ) - 2;
28
29 TPM2B_NAME * GetName(TPMI_ALG_HASH hashAlg, TPM2B_PUBLIC *obj);
30
31 TSS2_RC swKeyDuplicate(
32           RSA* rsaKey, TPM2B_PUBLIC* parentKeyPublicPortion, UINT8* policyDigest, int digestSize,
33       /* OUT */
34       TPM2B* encryptionKey, TPM2B_PUBLIC *swKeyPublic, TPM2B_PRIVATE *swKeyPrivate,  TPM2B_ENCRYPTED_SECRET *encSymSeed);
35
36
37 void CreateDuplicationBlob(
38                 //IN
39                 TPM2B_PUBLIC_KEY_RSA *protector,
40                 TPMT_PUBLIC * publicPortion,
41                 TPMT_SENSITIVE *sens,
42                 TPM2B *plainSymSeed, TPMI_YES_NO generateInSymSeed,
43                 TPM2B encryptionKey, TPMI_YES_NO generateEncryptionKey,
44
45                 //OUT
46                 TPM2B_PRIVATE *outDuplicate,
47                 TPM2B_ENCRYPTED_SECRET *encSymSeed);
48
49
50 void CreateSwDataObject(
51                 BYTE* auth, UINT16 authSize,
52                 RSA * rsakey,
53                 BYTE * dataToSeal, UINT16 dataSize,
54                 BYTE * policyDigest, UINT16 policyDigestSize,
55                 TPMT_PUBLIC * outPublic,
56         TPMT_SENSITIVE *outSens);
57
58 void CreateDuplicationBlob2B(
59         //IN
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,
65
66                 //OUT
67                 TPM2B_PRIVATE *outDuplicate,
68                 TPM2B_ENCRYPTED_SECRET *encSymSeed);
69
70 void CreateSwDataObject2B(
71                 //IN
72                 BYTE* auth, UINT16 authSize,
73                 RSA * rsaKey,
74                 BYTE * policyDigest, UINT16 policyDigestSize,
75                 //OUT
76                 TPM2B_PUBLIC * outPublic,
77         TPM2B_SENSITIVE *outSens);
78
79
80 #endif //TPM_DUP_AUX
81