tpm2-tss 3.2.1
TPM Software stack 2.0 TCG spec compliant implementation
esys_crypto_ossl.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*******************************************************************************
3 * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
4 * All rights reserved.
5 ******************************************************************************/
6#ifndef ESYS_CRYPTO_OSSL_H
7#define ESYS_CRYPTO_OSSL_H
8
9#include <stddef.h>
10#include "tss2_tpm2_types.h"
11#include "tss2-sys/sysapi_util.h"
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#define OSSL_FREE(S,TYPE) if((S) != NULL) {TYPE##_free((void*) (S)); (S)=NULL;}
18
20
23 TPM2_ALG_ID hashAlg);
24
27 const uint8_t *buffer, size_t size);
28
31 TPM2B *b);
32
35 uint8_t *buffer,
36 size_t *size);
37
40 TPM2B *b);
41
42void iesys_cryptossl_hash_abort(IESYS_CRYPTO_CONTEXT_BLOB **context);
43
44#define iesys_crypto_pk_encrypt iesys_cryptossl_pk_encrypt
45#define iesys_crypto_hash_start iesys_cryptossl_hash_start
46#define iesys_crypto_hash_update iesys_cryptossl_hash_update
47#define iesys_crypto_hash_update2b iesys_cryptossl_hash_update2b
48#define iesys_crypto_hash_finish iesys_cryptossl_hash_finish
49#define iesys_crypto_hash_finish2b iesys_cryptossl_hash_finish2b
50#define iesys_crypto_hash_abort iesys_cryptossl_hash_abort
51
54 TPM2_ALG_ID hmacAlg,
55 const uint8_t *key,
56 size_t size);
57
58TSS2_RC iesys_cryptossl_hmac_start2b(
60 TPM2_ALG_ID hmacAlg,
61 TPM2B *b);
62
65 const uint8_t *buffer,
66 size_t size);
67
70 TPM2B *b);
71
74 uint8_t *buffer,
75 size_t *size);
76
79 TPM2B *b);
80
82
83#define iesys_crypto_hmac_start iesys_cryptossl_hmac_start
84#define iesys_crypto_hmac_start2b iesys_cryptossl_hmac_start2b
85#define iesys_crypto_hmac_update iesys_cryptossl_hmac_update
86#define iesys_crypto_hmac_update2b iesys_cryptossl_hmac_update2b
87#define iesys_crypto_hmac_finish iesys_cryptossl_hmac_finish
88#define iesys_crypto_hmac_finish2b iesys_cryptossl_hmac_finish2b
89#define iesys_crypto_hmac_abort iesys_cryptossl_hmac_abort
90
91TSS2_RC iesys_cryptossl_random2b(TPM2B_NONCE *nonce, size_t num_bytes);
92
94 TPM2B_PUBLIC *key,
95 size_t in_size,
96 BYTE *in_buffer,
97 size_t max_out_size,
98 BYTE *out_buffer,
99 size_t *out_size,
100 const char *label);
101
102
103TSS2_RC iesys_cryptossl_sym_aes_encrypt(
104 uint8_t *key,
105 TPM2_ALG_ID tpm_sym_alg,
106 TPMI_AES_KEY_BITS key_bits,
107 TPM2_ALG_ID tpm_mode,
108 uint8_t *dst,
109 size_t dst_size,
110 uint8_t *iv);
111
112TSS2_RC iesys_cryptossl_sym_aes_decrypt(
113 uint8_t *key,
114 TPM2_ALG_ID tpm_sym_alg,
115 TPMI_AES_KEY_BITS key_bits,
116 TPM2_ALG_ID tpm_mode,
117 uint8_t *dst,
118 size_t dst_size,
119 uint8_t *iv);
120
122 TPM2B_PUBLIC *key,
123 size_t max_out_size,
124 TPM2B_ECC_PARAMETER *Z,
125 TPMS_ECC_POINT *Q,
126 BYTE * out_buffer,
127 size_t * out_size);
128
129#define iesys_crypto_random2b iesys_cryptossl_random2b
130#define iesys_crypto_get_ecdh_point iesys_cryptossl_get_ecdh_point
131#define iesys_crypto_sym_aes_encrypt iesys_cryptossl_sym_aes_encrypt
132#define iesys_crypto_sym_aes_decrypt iesys_cryptossl_sym_aes_decrypt
133
134TSS2_RC iesys_cryptossl_init();
135
136#define iesys_crypto_init iesys_cryptossl_init
137
138#ifdef __cplusplus
139} /* extern "C" */
140#endif
141
142#endif /* ESYS_CRYPTO_OSSL_H */
TSS2_RC iesys_cryptossl_hmac_start(IESYS_CRYPTO_CONTEXT_BLOB **context, TPM2_ALG_ID hmacAlg, const uint8_t *key, size_t size)
Definition: esys_crypto_ossl.c:369
TSS2_RC iesys_cryptossl_hmac_finish(IESYS_CRYPTO_CONTEXT_BLOB **context, uint8_t *buffer, size_t *size)
Definition: esys_crypto_ossl.c:498
TSS2_RC iesys_cryptossl_hash_update2b(IESYS_CRYPTO_CONTEXT_BLOB *context, TPM2B *b)
Definition: esys_crypto_ossl.c:268
TSS2_RC iesys_cryptossl_hmac_update2b(IESYS_CRYPTO_CONTEXT_BLOB *context, TPM2B *b)
Definition: esys_crypto_ossl.c:475
TSS2_RC iesys_cryptossl_hash_finish(IESYS_CRYPTO_CONTEXT_BLOB **context, uint8_t *buffer, size_t *size)
Definition: esys_crypto_ossl.c:291
TSS2_RC iesys_cryptossl_hmac_update(IESYS_CRYPTO_CONTEXT_BLOB *context, const uint8_t *buffer, size_t size)
Definition: esys_crypto_ossl.c:442
void iesys_cryptossl_hmac_abort(IESYS_CRYPTO_CONTEXT_BLOB **context)
Definition: esys_crypto_ossl.c:561
TSS2_RC iesys_cryptossl_hmac_finish2b(IESYS_CRYPTO_CONTEXT_BLOB **context, TPM2B *b)
Definition: esys_crypto_ossl.c:543
TSS2_RC iesys_cryptossl_random2b(TPM2B_NONCE *nonce, size_t num_bytes)
Definition: esys_crypto_ossl.c:591
TSS2_RC iesys_cryptossl_hash_update(IESYS_CRYPTO_CONTEXT_BLOB *context, const uint8_t *buffer, size_t size)
Definition: esys_crypto_ossl.c:234
TSS2_RC iesys_cryptossl_hash_finish2b(IESYS_CRYPTO_CONTEXT_BLOB **context, TPM2B *b)
TSS2_RC iesys_cryptossl_hash_start(IESYS_CRYPTO_CONTEXT_BLOB **context, TPM2_ALG_ID hashAlg)
Definition: esys_crypto_ossl.c:182
TSS2_RC iesys_cryptossl_pk_encrypt(TPM2B_PUBLIC *key, size_t in_size, BYTE *in_buffer, size_t max_out_size, BYTE *out_buffer, size_t *out_size, const char *label)
Definition: esys_crypto_ossl.c:638
TSS2_RC iesys_cryptossl_get_ecdh_point(TPM2B_PUBLIC *key, size_t max_out_size, TPM2B_ECC_PARAMETER *Z, TPMS_ECC_POINT *Q, BYTE *out_buffer, size_t *out_size)
Definition: esys_crypto_ossl.c:903
Definition: esys_crypto_mbed.c:28