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 
19 
20 TSS2_RC iesys_cryptmbed_hash_start(
21  IESYS_CRYPTO_CONTEXT_BLOB **context,
22  TPM2_ALG_ID hashAlg);
23 
24 TSS2_RC iesys_cryptmbed_hash_update(
26  const uint8_t *buffer, size_t size);
27 
28 TSS2_RC iesys_cryptmbed_hash_update2b(
30  TPM2B *b);
31 
32 TSS2_RC iesys_cryptmbed_hash_finish(
33  IESYS_CRYPTO_CONTEXT_BLOB **context,
34  uint8_t *buffer,
35  size_t *size);
36 
37 TSS2_RC iesys_cryptmbed_hash_finish2b(
38  IESYS_CRYPTO_CONTEXT_BLOB **context,
39  TPM2B *b);
40 
41 void iesys_cryptmbed_hash_abort(IESYS_CRYPTO_CONTEXT_BLOB **context);
42 
43 #define iesys_crypto_pk_encrypt iesys_cryptmbed_pk_encrypt
44 #define iesys_crypto_hash_start iesys_cryptmbed_hash_start
45 #define iesys_crypto_hash_update iesys_cryptmbed_hash_update
46 #define iesys_crypto_hash_update2b iesys_cryptmbed_hash_update2b
47 #define iesys_crypto_hash_finish iesys_cryptmbed_hash_finish
48 #define iesys_crypto_hash_finish2b iesys_cryptmbed_hash_finish2b
49 #define iesys_crypto_hash_abort iesys_cryptmbed_hash_abort
50 
51 TSS2_RC iesys_cryptmbed_hmac_start(
52  IESYS_CRYPTO_CONTEXT_BLOB **context,
53  TPM2_ALG_ID hmacAlg,
54  const uint8_t *key,
55  size_t size);
56 
57 TSS2_RC iesys_cryptmbed_hmac_start2b(
58  IESYS_CRYPTO_CONTEXT_BLOB **context,
59  TPM2_ALG_ID hmacAlg,
60  TPM2B *b);
61 
62 TSS2_RC iesys_cryptmbed_hmac_update(
64  const uint8_t *buffer,
65  size_t size);
66 
67 TSS2_RC iesys_cryptmbed_hmac_update2b(
69  TPM2B *b);
70 
71 TSS2_RC iesys_cryptmbed_hmac_finish(
72  IESYS_CRYPTO_CONTEXT_BLOB **context,
73  uint8_t *buffer,
74  size_t *size);
75 
76 TSS2_RC iesys_cryptmbed_hmac_finish2b(
77  IESYS_CRYPTO_CONTEXT_BLOB **context,
78  TPM2B *b);
79 
80 void iesys_cryptmbed_hmac_abort(IESYS_CRYPTO_CONTEXT_BLOB **context);
81 
82 #define iesys_crypto_hmac_start iesys_cryptmbed_hmac_start
83 #define iesys_crypto_hmac_start2b iesys_cryptmbed_hmac_start2b
84 #define iesys_crypto_hmac_update iesys_cryptmbed_hmac_update
85 #define iesys_crypto_hmac_update2b iesys_cryptmbed_hmac_update2b
86 #define iesys_crypto_hmac_finish iesys_cryptmbed_hmac_finish
87 #define iesys_crypto_hmac_finish2b iesys_cryptmbed_hmac_finish2b
88 #define iesys_crypto_hmac_abort iesys_cryptmbed_hmac_abort
89 
90 TSS2_RC iesys_cryptmbed_random2b(TPM2B_NONCE *nonce, size_t num_bytes);
91 
92 TSS2_RC iesys_cryptmbed_pk_encrypt(
93  TPM2B_PUBLIC *key,
94  size_t in_size,
95  BYTE *in_buffer,
96  size_t max_out_size,
97  BYTE *out_buffer,
98  size_t *out_size,
99  const char *label);
100 
101 
102 TSS2_RC iesys_cryptmbed_sym_aes_encrypt(
103  uint8_t *key,
104  TPM2_ALG_ID tpm_sym_alg,
105  TPMI_AES_KEY_BITS key_bits,
106  TPM2_ALG_ID tpm_mode,
107  uint8_t *dst,
108  size_t dst_size,
109  uint8_t *iv);
110 
111 TSS2_RC iesys_cryptmbed_sym_aes_decrypt(
112  uint8_t *key,
113  TPM2_ALG_ID tpm_sym_alg,
114  TPMI_AES_KEY_BITS key_bits,
115  TPM2_ALG_ID tpm_mode,
116  uint8_t *dst,
117  size_t dst_size,
118  uint8_t *iv);
119 
120 TSS2_RC iesys_cryptmbed_get_ecdh_point(
121  TPM2B_PUBLIC *key,
122  size_t max_out_size,
123  TPM2B_ECC_PARAMETER *Z,
124  TPMS_ECC_POINT *Q,
125  BYTE * out_buffer,
126  size_t * out_size);
127 
128 #define iesys_crypto_random2b iesys_cryptmbed_random2b
129 #define iesys_crypto_get_ecdh_point iesys_cryptmbed_get_ecdh_point
130 #define iesys_crypto_sym_aes_encrypt iesys_cryptmbed_sym_aes_encrypt
131 #define iesys_crypto_sym_aes_decrypt iesys_cryptmbed_sym_aes_decrypt
132 
133 #define iesys_crypto_init(...) TSS2_RC_SUCCESS;
134 
135 #ifdef __cplusplus
136 } /* extern "C" */
137 #endif
138 
139 #endif /* ESYS_CRYPTO_MBED_H */
Definition: esys_crypto_mbed.c:28