Mbed TLS v2.28.10
pkcs11.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright The Mbed TLS Contributors
10  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
11  */
12 #ifndef MBEDTLS_PKCS11_H
13 #define MBEDTLS_PKCS11_H
14 
15 #if !defined(MBEDTLS_CONFIG_FILE)
16 #include "mbedtls/config.h"
17 #else
18 #include MBEDTLS_CONFIG_FILE
19 #endif
20 
21 #if defined(MBEDTLS_PKCS11_C)
22 
23 #include "mbedtls/x509_crt.h"
24 
25 #include <pkcs11-helper-1.0/pkcs11h-certificate.h>
26 
27 #if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
28  !defined(inline) && !defined(__cplusplus)
29 #define inline __inline
30 #endif
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #if defined(MBEDTLS_DEPRECATED_REMOVED)
37 
41 typedef struct mbedtls_pkcs11_context {
42  pkcs11h_certificate_t pkcs11h_cert;
43  int len;
44 } mbedtls_pkcs11_context;
45 
46 #if defined(MBEDTLS_DEPRECATED_WARNING)
47 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
48 #else
49 #define MBEDTLS_DEPRECATED
50 #endif
51 
59 MBEDTLS_DEPRECATED void mbedtls_pkcs11_init(mbedtls_pkcs11_context *ctx);
60 
72 MBEDTLS_DEPRECATED int mbedtls_pkcs11_x509_cert_bind(mbedtls_x509_crt *cert,
73  pkcs11h_certificate_t pkcs11h_cert);
74 
88 MBEDTLS_DEPRECATED int mbedtls_pkcs11_priv_key_bind(
89  mbedtls_pkcs11_context *priv_key,
90  pkcs11h_certificate_t pkcs11_cert);
91 
101 MBEDTLS_DEPRECATED void mbedtls_pkcs11_priv_key_free(
102  mbedtls_pkcs11_context *priv_key);
103 
124 MBEDTLS_DEPRECATED int mbedtls_pkcs11_decrypt(mbedtls_pkcs11_context *ctx,
125  int mode, size_t *olen,
126  const unsigned char *input,
127  unsigned char *output,
128  size_t output_max_len);
129 
149 MBEDTLS_DEPRECATED int mbedtls_pkcs11_sign(mbedtls_pkcs11_context *ctx,
150  int mode,
151  mbedtls_md_type_t md_alg,
152  unsigned int hashlen,
153  const unsigned char *hash,
154  unsigned char *sig);
155 
162 MBEDTLS_DEPRECATED static inline int mbedtls_ssl_pkcs11_decrypt(void *ctx,
163  int mode,
164  size_t *olen,
165  const unsigned char *input,
166  unsigned char *output,
167  size_t output_max_len)
168 {
169  return mbedtls_pkcs11_decrypt((mbedtls_pkcs11_context *) ctx, mode, olen, input, output,
170  output_max_len);
171 }
172 
199 MBEDTLS_DEPRECATED static inline int mbedtls_ssl_pkcs11_sign(void *ctx,
200  int (*f_rng)(void *,
201  unsigned char *,
202  size_t),
203  void *p_rng,
204  int mode,
205  mbedtls_md_type_t md_alg,
206  unsigned int hashlen,
207  const unsigned char *hash,
208  unsigned char *sig)
209 {
210  ((void) f_rng);
211  ((void) p_rng);
212  return mbedtls_pkcs11_sign((mbedtls_pkcs11_context *) ctx, mode, md_alg,
213  hashlen, hash, sig);
214 }
215 
226 MBEDTLS_DEPRECATED static inline size_t mbedtls_ssl_pkcs11_key_len(void *ctx)
227 {
228  return ((mbedtls_pkcs11_context *) ctx)->len;
229 }
230 
231 #undef MBEDTLS_DEPRECATED
232 
233 #endif /* MBEDTLS_DEPRECATED_REMOVED */
234 
235 #ifdef __cplusplus
236 }
237 #endif
238 
239 #endif /* MBEDTLS_PKCS11_C */
240 
241 #endif /* MBEDTLS_PKCS11_H */
#define MBEDTLS_DEPRECATED
Definition: aes.h:625
Configuration options (set of defines)
X.509 certificate parsing and writing.
mbedtls_md_type_t
Supported message digests.
Definition: md.h:50