tpm2-tss 4.2.0
TPM Software stack 2.0 TCG spec compliant implementation
esys_crypto_mbed.h
1/* SPDX-FileCopyrightText: 2020, Andreas Droescher */
2/* SPDX-License-Identifier: BSD-2-Clause */
3
4#ifndef ESYS_CRYPTO_MBED_H
5#define ESYS_CRYPTO_MBED_H
6
7#include "tss2-sys/sysapi_util.h"
8#include "tss2_tpm2_types.h"
9#include <stddef.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15TSS2_RC
16iesys_cryptmbed_hash_start(ESYS_CRYPTO_CONTEXT_BLOB **context, TPM2_ALG_ID hashAlg, void *userdata);
17
18TSS2_RC iesys_cryptmbed_hash_update(ESYS_CRYPTO_CONTEXT_BLOB *context,
19 const uint8_t *buffer,
20 size_t size,
21 void *userdata);
22
23TSS2_RC iesys_cryptmbed_hash_finish(ESYS_CRYPTO_CONTEXT_BLOB **context,
24 uint8_t *buffer,
25 size_t *size,
26 void *userdata);
27
28void iesys_cryptmbed_hash_abort(ESYS_CRYPTO_CONTEXT_BLOB **context, void *userdata);
29
30#define iesys_crypto_rsa_pk_encrypt_internal iesys_cryptmbed_pk_encrypt
31#define iesys_crypto_hash_start_internal iesys_cryptmbed_hash_start
32#define iesys_crypto_hash_update_internal iesys_cryptmbed_hash_update
33#define iesys_crypto_hash_finish_internal iesys_cryptmbed_hash_finish
34#define iesys_crypto_hash_abort_internal iesys_cryptmbed_hash_abort
35
36TSS2_RC iesys_cryptmbed_hmac_start(ESYS_CRYPTO_CONTEXT_BLOB **context,
37 TPM2_ALG_ID hmacAlg,
38 const uint8_t *key,
39 size_t size,
40 void *userdata);
41
42TSS2_RC iesys_cryptmbed_hmac_update(ESYS_CRYPTO_CONTEXT_BLOB *context,
43 const uint8_t *buffer,
44 size_t size,
45 void *userdata);
46
47TSS2_RC iesys_cryptmbed_hmac_finish(ESYS_CRYPTO_CONTEXT_BLOB **context,
48 uint8_t *buffer,
49 size_t *size,
50 void *userdata);
51
52void iesys_cryptmbed_hmac_abort(ESYS_CRYPTO_CONTEXT_BLOB **context, void *userdata);
53
54#define iesys_crypto_hmac_start_internal iesys_cryptmbed_hmac_start
55#define iesys_crypto_hmac_update_internal iesys_cryptmbed_hmac_update
56#define iesys_crypto_hmac_finish_internal iesys_cryptmbed_hmac_finish
57#define iesys_crypto_hmac_abort_internal iesys_cryptmbed_hmac_abort
58
59TSS2_RC iesys_cryptmbed_random2b(TPM2B_NONCE *nonce, size_t num_bytes, void *userdata);
60
61TSS2_RC iesys_cryptmbed_pk_encrypt(TPM2B_PUBLIC *key,
62 size_t in_size,
63 BYTE *in_buffer,
64 size_t max_out_size,
65 BYTE *out_buffer,
66 size_t *out_size,
67 const char *label,
68 void *userdata);
69
70TSS2_RC iesys_cryptmbed_sym_aes_encrypt(uint8_t *key,
71 TPM2_ALG_ID tpm_sym_alg,
72 TPMI_AES_KEY_BITS key_bits,
73 TPM2_ALG_ID tpm_mode,
74 uint8_t *dst,
75 size_t dst_size,
76 uint8_t *iv,
77 void *userdata);
78
79TSS2_RC iesys_cryptmbed_sym_aes_decrypt(uint8_t *key,
80 TPM2_ALG_ID tpm_sym_alg,
81 TPMI_AES_KEY_BITS key_bits,
82 TPM2_ALG_ID tpm_mode,
83 uint8_t *dst,
84 size_t dst_size,
85 uint8_t *iv,
86 void *userdata);
87
88TSS2_RC iesys_cryptmbed_get_ecdh_point(TPM2B_PUBLIC *key,
89 size_t max_out_size,
90 TPM2B_ECC_PARAMETER *Z,
91 TPMS_ECC_POINT *Q,
92 BYTE *out_buffer,
93 size_t *out_size,
94 void *userdata);
95
96TSS2_RC iesys_cryptmbed_init(void *userdata);
97
98#define iesys_crypto_get_random2b_internal iesys_cryptmbed_random2b
99#define iesys_crypto_get_ecdh_point_internal iesys_cryptmbed_get_ecdh_point
100#define iesys_crypto_aes_encrypt_internal iesys_cryptmbed_sym_aes_encrypt
101#define iesys_crypto_aes_decrypt_internal iesys_cryptmbed_sym_aes_decrypt
102#define iesys_crypto_sm4_encrypt_internal NULL
103#define iesys_crypto_sm4_decrypt_internal NULL
104
105#define iesys_crypto_init_internal iesys_cryptmbed_init
106
107#ifdef __cplusplus
108} /* extern "C" */
109#endif
110
111#endif /* ESYS_CRYPTO_MBED_H */
Definition esys_crypto_mbed.c:32