• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 The Chromium OS Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6 
7 #ifndef __TPM2_CPRISYM_FP_H
8 #define __TPM2_CPRISYM_FP_H
9 
10 LIB_EXPORT CRYPT_RESULT _cpri__AESDecryptCBC(
11     BYTE *dOut,            // OUT: the decrypted data
12     UINT32 keySizeInBits,  // IN: key size in bit
13     BYTE *key,  // IN: key buffer. The size of this buffer in bytes is
14                 // (keySizeInBits + 7) / 8
15     BYTE *iv,   // IN/OUT: IV for decryption. The size of this buffer is 16 byte
16     UINT32 dInSize,  // IN: data size
17     BYTE *dIn        // IN: data buffer
18     );
19 LIB_EXPORT CRYPT_RESULT
20 _cpri__AESDecryptCFB(BYTE *dOut,            // OUT: the decrypted data
21                      UINT32 keySizeInBits,  // IN: key size in bit
22                      BYTE *key,  // IN: key buffer. The size of this buffer in
23                                  // bytes is (keySizeInBits + 7) / 8
24                      BYTE *iv,   // IN/OUT: IV for decryption.
25                      UINT32 dInSize,  // IN: data size
26                      BYTE *dIn        // IN: data buffer
27                      );
28 //
29 //       _cpri__AESDecryptCTR()
30 //
31 // Counter mode decryption uses the same algorithm as encryption. The
32 // _cpri__AESDecryptCTR() function is implemented as a macro call to
33 // _cpri__AESEncryptCTR().
34 #define _cpri__AESDecryptCTR(dOut, keySize, key, iv, dInSize, dIn)       \
35   _cpri__AESEncryptCTR(((BYTE *)dOut), ((UINT32)keySize), ((BYTE *)key), \
36                        ((BYTE *)iv), ((UINT32)dInSize), ((BYTE *)dIn))
37 LIB_EXPORT CRYPT_RESULT
38 _cpri__AESDecryptECB(BYTE *dOut,            // OUT: the clear text data
39                      UINT32 keySizeInBits,  // IN: key size in bit
40                      BYTE *key,  // IN: key buffer. The size of this buffer in
41                                  // bytes is (keySizeInBits + 7) / 8
42                      UINT32 dInSize,  // IN: data size
43                      BYTE *dIn        // IN: cipher text buffer
44                      );
45 
46 //
47 //       _cpri__AESDecryptOFB()
48 //
49 // OFB encryption and decryption use the same algorithms for both. The
50 // _cpri__AESDecryptOFB() function is implemented as a macro call to
51 // _cpri__AESEncrytOFB().
52 //
53 #define _cpri__AESDecryptOFB(dOut, keySizeInBits, key, iv, dInSize, dIn)       \
54   _cpri__AESEncryptOFB(((BYTE *)dOut), ((UINT32)keySizeInBits), ((BYTE *)key), \
55                        ((BYTE *)iv), ((UINT32)dInSize), ((BYTE *)dIn))
56 
57 //
58 //    _cpri__SM4DecryptCTR()
59 //
60 // Counter mode decryption uses the same algorithm as encryption. The
61 // _cpri__SM4DecryptCTR() function is implemented as a macro call to
62 // _cpri__SM4EncryptCTR().
63 //
64 #define _cpri__SM4DecryptCTR(dOut, keySize, key, iv, dInSize, dIn)       \
65   _cpri__SM4EncryptCTR(((BYTE *)dOut), ((UINT32)keySize), ((BYTE *)key), \
66                        ((BYTE *)iv), ((UINT32)dInSize), ((BYTE *)dIn))
67 
68 //
69 //       _cpri__SM4DecryptOFB()
70 //
71 // OFB encryption and decryption use the same algorithms for both. The
72 // _cpri__SM4DecryptOFB() function is implemented as a macro call to
73 // _cpri__SM4EncrytOFB().
74 //
75 #define _cpri__SM4DecryptOFB(dOut, keySizeInBits, key, iv, dInSize, dIn)       \
76   _cpri__SM4EncryptOFB(((BYTE *)dOut), ((UINT32)keySizeInBits), ((BYTE *)key), \
77                        ((BYTE *)iv), ((UINT32)dInSize), ((BYTE *)dIn))
78 
79 LIB_EXPORT CRYPT_RESULT _cpri__AESEncryptCBC(
80     BYTE *dOut,            // OUT:
81     UINT32 keySizeInBits,  // IN: key size in bit
82     BYTE *key,       // IN: key buffer. The size of this buffer in bytes is
83                      // (keySizeInBits + 7) / 8
84     BYTE *iv,        // IN/OUT: IV for decryption.
85     UINT32 dInSize,  // IN: data size (is required to be a multiple of 16 bytes)
86     BYTE *dIn        // IN: data buffer
87     );
88 LIB_EXPORT CRYPT_RESULT
89 _cpri__AESEncryptCFB(BYTE *dOut,            // OUT: the encrypted
90                      UINT32 keySizeInBits,  // IN: key size in bit
91                      BYTE *key,  // IN: key buffer. The size of this buffer in
92                                  // bytes is (keySizeInBits + 7) / 8
93                      BYTE *iv,   // IN/OUT: IV for decryption.
94                      UINT32 dInSize,  // IN: data size
95                      BYTE *dIn        // IN: data buffer
96                      );
97 LIB_EXPORT CRYPT_RESULT
98 _cpri__AESEncryptCTR(BYTE *dOut,            // OUT: the encrypted data
99                      UINT32 keySizeInBits,  // IN: key size in bit
100                      BYTE *key,  // IN: key buffer. The size of this buffer in
101                                  // bytes is (keySizeInBits + 7) / 8
102                      BYTE *iv,   // IN/OUT: IV for decryption.
103                      UINT32 dInSize,  // IN: data size
104                      BYTE *dIn        // IN: data buffer
105                      );
106 LIB_EXPORT CRYPT_RESULT
107 _cpri__AESEncryptECB(BYTE *dOut,            // OUT: encrypted data
108                      UINT32 keySizeInBits,  // IN: key size in bit
109                      BYTE *key,  // IN: key buffer. The size of this buffer in
110                                  // bytes is (keySizeInBits + 7) / 8
111                      UINT32 dInSize,  // IN: data size
112                      BYTE *dIn        // IN: clear text buffer
113                      );
114 LIB_EXPORT CRYPT_RESULT _cpri__AESEncryptOFB(
115     BYTE *dOut,            // OUT: the encrypted/decrypted data
116     UINT32 keySizeInBits,  // IN: key size in bit
117     BYTE *key,  // IN: key buffer. The size of this buffer in bytes is
118                 // (keySizeInBits + 7) / 8
119     BYTE *iv,   // IN/OUT: IV for decryption. The size of this buffer is 16 byte
120     UINT32 dInSize,  // IN: data size
121     BYTE *dIn        // IN: data buffer
122     );
123 LIB_EXPORT INT16 _cpri__GetSymmetricBlockSize(
124     TPM_ALG_ID symmetricAlg,  // IN: the symmetric algorithm
125     UINT16 keySizeInBits      // IN: the key size
126     );
127 LIB_EXPORT BOOL _cpri__SymStartup(void);
128 
129 #endif  // __TPM2_CPRISYM_FP_H
130