1 /* Microsoft Reference Implementation for TPM 2.0 2 * 3 * The copyright in this software is being made available under the BSD License, 4 * included below. This software may be subject to other third party and 5 * contributor rights, including patent rights, and no such rights are granted 6 * under this license. 7 * 8 * Copyright (c) Microsoft Corporation 9 * 10 * All rights reserved. 11 * 12 * BSD License 13 * 14 * Redistribution and use in source and binary forms, with or without modification, 15 * are permitted provided that the following conditions are met: 16 * 17 * Redistributions of source code must retain the above copyright notice, this list 18 * of conditions and the following disclaimer. 19 * 20 * Redistributions in binary form must reproduce the above copyright notice, this 21 * list of conditions and the following disclaimer in the documentation and/or 22 * other materials provided with the distribution. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 /*(Auto-generated) 36 * Created by TpmPrototypes; Version 3.0 July 18, 2017 37 * Date: Apr 2, 2019 Time: 03:18:00PM 38 */ 39 40 #ifndef _CRYPT_SYM_FP_H_ 41 #define _CRYPT_SYM_FP_H_ 42 43 //** Initialization and Data Access Functions 44 // 45 //*** CryptSymInit() 46 // This function is called to do _TPM_Init processing 47 BOOL 48 CryptSymInit( 49 void 50 ); 51 52 //*** CryptSymStartup() 53 // This function is called to do TPM2_Startup() processing 54 BOOL 55 CryptSymStartup( 56 void 57 ); 58 59 //*** CryptGetSymmetricBlockSize() 60 // This function returns the block size of the algorithm. The table of bit sizes has 61 // an entry for each allowed key size. The entry for a key size is 0 if the TPM does 62 // not implement that key size. The key size table is delimited with a negative number 63 // (-1). After the delimiter is a list of block sizes with each entry corresponding 64 // to the key bit size. For most symmetric algorithms, the block size is the same 65 // regardless of the key size but this arrangement allows them to be different. 66 // Return Type: INT16 67 // <= 0 cipher not supported 68 // > 0 the cipher block size in bytes 69 LIB_EXPORT INT16 70 CryptGetSymmetricBlockSize( 71 TPM_ALG_ID symmetricAlg, // IN: the symmetric algorithm 72 UINT16 keySizeInBits // IN: the key size 73 ); 74 75 //** Symmetric Encryption 76 // This function performs symmetric encryption based on the mode. 77 // Return Type: TPM_RC 78 // TPM_RC_SIZE 'dSize' is not a multiple of the block size for an 79 // algorithm that requires it 80 // TPM_RC_FAILURE Fatal error 81 LIB_EXPORT TPM_RC 82 CryptSymmetricEncrypt( 83 BYTE *dOut, // OUT: 84 TPM_ALG_ID algorithm, // IN: the symmetric algorithm 85 UINT16 keySizeInBits, // IN: key size in bits 86 const BYTE *key, // IN: key buffer. The size of this buffer 87 // in bytes is (keySizeInBits + 7) / 8 88 TPM2B_IV *ivInOut, // IN/OUT: IV for decryption. 89 TPM_ALG_ID mode, // IN: Mode to use 90 INT32 dSize, // IN: data size (may need to be a 91 // multiple of the blockSize) 92 const BYTE *dIn // IN: data buffer 93 ); 94 95 //*** CryptSymmetricDecrypt() 96 // This function performs symmetric decryption based on the mode. 97 // Return Type: TPM_RC 98 // TPM_RC_FAILURE A fatal error 99 // TPM_RCS_SIZE 'dSize' is not a multiple of the block size for an 100 // algorithm that requires it 101 LIB_EXPORT TPM_RC 102 CryptSymmetricDecrypt( 103 BYTE *dOut, // OUT: decrypted data 104 TPM_ALG_ID algorithm, // IN: the symmetric algorithm 105 UINT16 keySizeInBits, // IN: key size in bits 106 const BYTE *key, // IN: key buffer. The size of this buffer 107 // in bytes is (keySizeInBits + 7) / 8 108 TPM2B_IV *ivInOut, // IN/OUT: IV for decryption. 109 TPM_ALG_ID mode, // IN: Mode to use 110 INT32 dSize, // IN: data size (may need to be a 111 // multiple of the blockSize) 112 const BYTE *dIn // IN: data buffer 113 ); 114 115 //*** CryptSymKeyValidate() 116 // Validate that a provided symmetric key meets the requirements of the TPM 117 // Return Type: TPM_RC 118 // TPM_RC_KEY_SIZE Key size specifiers do not match 119 // TPM_RC_KEY Key is not allowed 120 TPM_RC 121 CryptSymKeyValidate( 122 TPMT_SYM_DEF_OBJECT *symDef, 123 TPM2B_SYM_KEY *key 124 ); 125 126 #endif // _CRYPT_SYM_FP_H_ 127