xref: /aosp_15_r20/external/ms-tpm-20-ref/TPMCmd/tpm/include/prototypes/CryptEccCrypt_fp.h (revision 5c591343844d1f9da7da26467c4bf7efc8a7a413)
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: Feb 28, 2020  Time: 03:04:48PM
38  */
39 
40 #ifndef    _CRYPT_ECC_CRYPT_FP_H_
41 #define    _CRYPT_ECC_CRYPT_FP_H_
42 
43 #if CC_ECC_Encrypt || CC_ECC_Encrypt
44 
45 //*** CryptEccSelectScheme()
46 // This function is used by TPM2_ECC_Decrypt and TPM2_ECC_Encrypt.  It sets scheme
47 // either the input scheme or the key scheme. If they key scheme is not TPM_ALG_NULL
48 // then the input scheme must be TPM_ALG_NULL or the same as the key scheme. If
49 // not, then the function returns FALSE.
50 //  Return Type: BOOL
51 //      TRUE        'scheme' is set
52 //      FALSE       'scheme' is not valid (it may have been changed).
53 BOOL
54 CryptEccSelectScheme(
55     OBJECT              *key,           //IN: key containing default scheme
56     TPMT_KDF_SCHEME     *scheme         // IN: a decrypt scheme
57 );
58 
59 //*** CryptEccEncrypt()
60 //This function performs ECC-based data obfuscation. The only scheme that is currently
61 // supported is MGF1 based. See Part 1, Annex D for details.
62 //  Return Type: TPM_RC
63 //      TPM_RC_CURVE            unsupported curve
64 //      TPM_RC_HASH             hash not allowed
65 //      TPM_RC_SCHEME           'scheme' is not supported
66 //      TPM_RC_NO_RESULT        internal error in big number processing
67 LIB_EXPORT TPM_RC
68 CryptEccEncrypt(
69     OBJECT                  *key,           // IN: public key of recipient
70     TPMT_KDF_SCHEME         *scheme,        // IN: scheme to use.
71     TPM2B_MAX_BUFFER        *plainText,     // IN: the text to obfuscate
72     TPMS_ECC_POINT          *c1,            // OUT: public ephemeral key
73     TPM2B_MAX_BUFFER        *c2,            // OUT: obfuscated text
74     TPM2B_DIGEST            *c3             // OUT: digest of ephemeral key
75                                             //      and plainText
76 );
77 
78 //*** CryptEccDecrypt()
79 // This function performs ECC decryption and integrity check of the input data.
80 //  Return Type: TPM_RC
81 //      TPM_RC_CURVE            unsupported curve
82 //      TPM_RC_HASH             hash not allowed
83 //      TPM_RC_SCHEME           'scheme' is not supported
84 //      TPM_RC_NO_RESULT        internal error in big number processing
85 //      TPM_RC_VALUE            C3 did not match hash of recovered data
86 LIB_EXPORT TPM_RC
87 CryptEccDecrypt(
88     OBJECT                  *key,           // IN: key used for data recovery
89     TPMT_KDF_SCHEME         *scheme,        // IN: scheme to use.
90     TPM2B_MAX_BUFFER        *plainText,     // OUT: the recovered text
91     TPMS_ECC_POINT          *c1,            // IN: public ephemeral key
92     TPM2B_MAX_BUFFER        *c2,            // IN: obfuscated text
93     TPM2B_DIGEST            *c3             // IN: digest of ephemeral key
94                                             //      and plainText
95 );
96 #endif  // CC_ECC_Encrypt || CC_ECC_Encrypt
97 
98 #endif  // _CRYPT_ECC_CRYPT_FP_H_
99