Arun kumar Sekar | 2ac5633 | 2018-03-30 11:20:30 -0700 | [diff] [blame] | 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 <sapi/tpm20.h> |
| 22 | #include <openssl/rand.h> |
| 23 | #include <openssl/hmac.h> |
| 24 | #include "crypto_aux.h" |
| 25 | |
| 26 | #define BYTES_TO_BITS(val) (val * 8) |
| 27 | |
| 28 | #define INIT_SIMPLE_TPM2B_SIZE( type ) (type).t.size = sizeof( type ) - 2; |
| 29 | |
| 30 | TPM2B_NAME * GetName(TPMI_ALG_HASH hashAlg, TPM2B_PUBLIC *obj, TPM2B_NAME *outName); |
| 31 | |
| 32 | TSS2_RC swKeyDuplicate( |
| 33 | /* IN */ |
| 34 | RSA* rsaKey, TPM2B_PUBLIC* parentKeyPublicPortion, UINT8* policyDigest, int digestSize, |
| 35 | /* OUT */ |
| 36 | TPM2B_DATA* encryptionKey, TPM2B_PUBLIC *swKeyPublic, TPM2B_PRIVATE *swKeyPrivate, TPM2B_ENCRYPTED_SECRET *encSymSeed); |
| 37 | |
| 38 | void CreateDuplicationBlob( |
| 39 | //IN |
| 40 | TPM2B_PUBLIC_KEY_RSA *protector, |
| 41 | TPMT_PUBLIC * publicPortion, |
| 42 | TPMT_SENSITIVE *sens, |
| 43 | TPM2B_ENCRYPTED_SECRET *plainSymSeed, TPMI_YES_NO generateInSymSeed, |
| 44 | TPM2B_DATA *encryptionKey, TPMI_YES_NO generateEncryptionKey, |
| 45 | |
| 46 | //OUT |
| 47 | TPM2B_PRIVATE *outDuplicate, |
| 48 | TPM2B_ENCRYPTED_SECRET *encSymSeed); |
| 49 | |
| 50 | |
| 51 | void CreateSwDataObject( |
| 52 | BYTE* auth, UINT16 authSize, |
| 53 | RSA * rsakey, |
| 54 | BYTE * dataToSeal, UINT16 dataSize, |
| 55 | BYTE * policyDigest, UINT16 policyDigestSize, |
| 56 | TPMT_PUBLIC * outPublic, |
| 57 | TPMT_SENSITIVE *outSens); |
| 58 | |
| 59 | void CreateDuplicationBlob2B( |
| 60 | //IN |
| 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, |
| 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 | |