tpm2-tss  3.2.1
TPM Software stack 2.0 TCG spec compliant implementation
esys_crypto_mbed.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright: 2020, Andreas Droescher
4  * All rights reserved.
5  ******************************************************************************/
6 
7 #ifndef ESYS_CRYPTO_MBED_H
8 #define ESYS_CRYPTO_MBED_H
9 
10 #include <stddef.h>
11 #include "tss2_tpm2_types.h"
12 #include "tss2-sys/sysapi_util.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 TSS2_RC iesys_cryptmbed_hash_start(
19  ESYS_CRYPTO_CONTEXT_BLOB **context,
20  TPM2_ALG_ID hashAlg,
21  void *userdata);
22 
23 TSS2_RC iesys_cryptmbed_hash_update(
24  ESYS_CRYPTO_CONTEXT_BLOB *context,
25  const uint8_t *buffer, size_t size,
26  void *userdata);
27 
28 TSS2_RC iesys_cryptmbed_hash_finish(
29  ESYS_CRYPTO_CONTEXT_BLOB **context,
30  uint8_t *buffer,
31  size_t *size,
32  void *userdata);
33 
34 void iesys_cryptmbed_hash_abort(
35  ESYS_CRYPTO_CONTEXT_BLOB **context,
36  void *userdata);
37 
38 #define _iesys_crypto_rsa_pk_encrypt iesys_cryptmbed_pk_encrypt
39 #define _iesys_crypto_hash_start iesys_cryptmbed_hash_start
40 #define _iesys_crypto_hash_update iesys_cryptmbed_hash_update
41 #define _iesys_crypto_hash_finish iesys_cryptmbed_hash_finish
42 #define _iesys_crypto_hash_abort iesys_cryptmbed_hash_abort
43 
44 TSS2_RC iesys_cryptmbed_hmac_start(
45  ESYS_CRYPTO_CONTEXT_BLOB **context,
46  TPM2_ALG_ID hmacAlg,
47  const uint8_t *key,
48  size_t size,
49  void *userdata);
50 
51 TSS2_RC iesys_cryptmbed_hmac_update(
52  ESYS_CRYPTO_CONTEXT_BLOB *context,
53  const uint8_t *buffer,
54  size_t size,
55  void *userdata);
56 
57 TSS2_RC iesys_cryptmbed_hmac_finish(
58  ESYS_CRYPTO_CONTEXT_BLOB **context,
59  uint8_t *buffer,
60  size_t *size,
61  void *userdata);
62 
63 void iesys_cryptmbed_hmac_abort(
64  ESYS_CRYPTO_CONTEXT_BLOB **context,
65  void *userdata);
66 
67 #define _iesys_crypto_hmac_start iesys_cryptmbed_hmac_start
68 #define _iesys_crypto_hmac_update iesys_cryptmbed_hmac_update
69 #define _iesys_crypto_hmac_finish iesys_cryptmbed_hmac_finish
70 #define _iesys_crypto_hmac_abort iesys_cryptmbed_hmac_abort
71 
72 TSS2_RC iesys_cryptmbed_random2b(
73  TPM2B_NONCE *nonce,
74  size_t num_bytes,
75  void *userdata);
76 
77 TSS2_RC iesys_cryptmbed_pk_encrypt(
78  TPM2B_PUBLIC *key,
79  size_t in_size,
80  BYTE *in_buffer,
81  size_t max_out_size,
82  BYTE *out_buffer,
83  size_t *out_size,
84  const char *label,
85  void *userdata);
86 
87 
88 TSS2_RC iesys_cryptmbed_sym_aes_encrypt(
89  uint8_t *key,
90  TPM2_ALG_ID tpm_sym_alg,
91  TPMI_AES_KEY_BITS key_bits,
92  TPM2_ALG_ID tpm_mode,
93  uint8_t *dst,
94  size_t dst_size,
95  uint8_t *iv,
96  void *userdata);
97 
98 TSS2_RC iesys_cryptmbed_sym_aes_decrypt(
99  uint8_t *key,
100  TPM2_ALG_ID tpm_sym_alg,
101  TPMI_AES_KEY_BITS key_bits,
102  TPM2_ALG_ID tpm_mode,
103  uint8_t *dst,
104  size_t dst_size,
105  uint8_t *iv,
106  void *userdata);
107 
108 TSS2_RC iesys_cryptmbed_get_ecdh_point(
109  TPM2B_PUBLIC *key,
110  size_t max_out_size,
111  TPM2B_ECC_PARAMETER *Z,
112  TPMS_ECC_POINT *Q,
113  BYTE * out_buffer,
114  size_t * out_size,
115  void *userdata);
116 
117 TSS2_RC iesys_cryptmbed_init(void *userdata);
118 
119 #define _iesys_crypto_get_random2b iesys_cryptmbed_random2b
120 #define _iesys_crypto_get_ecdh_point iesys_cryptmbed_get_ecdh_point
121 #define _iesys_crypto_aes_encrypt iesys_cryptmbed_sym_aes_encrypt
122 #define _iesys_crypto_aes_decrypt iesys_cryptmbed_sym_aes_decrypt
123 #define _iesys_crypto_sm4_encrypt NULL
124 #define _iesys_crypto_sm4_decrypt NULL
125 
126 #define _iesys_crypto_init iesys_cryptmbed_init
127 
128 #ifdef __cplusplus
129 } /* extern "C" */
130 #endif
131 
132 #endif /* ESYS_CRYPTO_MBED_H */
Definition: esys_crypto_mbed.c:34