Mbed TLS v2.28.5
Loading...
Searching...
No Matches
pkcs11.h
Go to the documentation of this file.
1
8/*
9 * Copyright The Mbed TLS Contributors
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License"); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 */
24#ifndef MBEDTLS_PKCS11_H
25#define MBEDTLS_PKCS11_H
26
27#if !defined(MBEDTLS_CONFIG_FILE)
28#include "mbedtls/config.h"
29#else
30#include MBEDTLS_CONFIG_FILE
31#endif
32
33#if defined(MBEDTLS_PKCS11_C)
34
35#include "mbedtls/x509_crt.h"
36
37#include <pkcs11-helper-1.0/pkcs11h-certificate.h>
38
39#if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
40 !defined(inline) && !defined(__cplusplus)
41#define inline __inline
42#endif
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#if defined(MBEDTLS_DEPRECATED_REMOVED)
49
53typedef struct mbedtls_pkcs11_context {
54 pkcs11h_certificate_t pkcs11h_cert;
55 int len;
56} mbedtls_pkcs11_context;
57
58#if defined(MBEDTLS_DEPRECATED_WARNING)
59#define MBEDTLS_DEPRECATED __attribute__((deprecated))
60#else
61#define MBEDTLS_DEPRECATED
62#endif
63
71MBEDTLS_DEPRECATED void mbedtls_pkcs11_init(mbedtls_pkcs11_context *ctx);
72
84MBEDTLS_DEPRECATED int mbedtls_pkcs11_x509_cert_bind(mbedtls_x509_crt *cert,
85 pkcs11h_certificate_t pkcs11h_cert);
86
100MBEDTLS_DEPRECATED int mbedtls_pkcs11_priv_key_bind(
101 mbedtls_pkcs11_context *priv_key,
102 pkcs11h_certificate_t pkcs11_cert);
103
113MBEDTLS_DEPRECATED void mbedtls_pkcs11_priv_key_free(
114 mbedtls_pkcs11_context *priv_key);
115
136MBEDTLS_DEPRECATED int mbedtls_pkcs11_decrypt(mbedtls_pkcs11_context *ctx,
137 int mode, size_t *olen,
138 const unsigned char *input,
139 unsigned char *output,
140 size_t output_max_len);
141
161MBEDTLS_DEPRECATED int mbedtls_pkcs11_sign(mbedtls_pkcs11_context *ctx,
162 int mode,
163 mbedtls_md_type_t md_alg,
164 unsigned int hashlen,
165 const unsigned char *hash,
166 unsigned char *sig);
167
174MBEDTLS_DEPRECATED static inline int mbedtls_ssl_pkcs11_decrypt(void *ctx,
175 int mode,
176 size_t *olen,
177 const unsigned char *input,
178 unsigned char *output,
179 size_t output_max_len)
180{
181 return mbedtls_pkcs11_decrypt((mbedtls_pkcs11_context *) ctx, mode, olen, input, output,
182 output_max_len);
183}
184
211MBEDTLS_DEPRECATED static inline int mbedtls_ssl_pkcs11_sign(void *ctx,
212 int (*f_rng)(void *,
213 unsigned char *,
214 size_t),
215 void *p_rng,
216 int mode,
217 mbedtls_md_type_t md_alg,
218 unsigned int hashlen,
219 const unsigned char *hash,
220 unsigned char *sig)
221{
222 ((void) f_rng);
223 ((void) p_rng);
224 return mbedtls_pkcs11_sign((mbedtls_pkcs11_context *) ctx, mode, md_alg,
225 hashlen, hash, sig);
226}
227
238MBEDTLS_DEPRECATED static inline size_t mbedtls_ssl_pkcs11_key_len(void *ctx)
239{
240 return ((mbedtls_pkcs11_context *) ctx)->len;
241}
242
243#undef MBEDTLS_DEPRECATED
244
245#endif /* MBEDTLS_DEPRECATED_REMOVED */
246
247#ifdef __cplusplus
248}
249#endif
250
251#endif /* MBEDTLS_PKCS11_C */
252
253#endif /* MBEDTLS_PKCS11_H */
#define MBEDTLS_DEPRECATED
Definition aes.h:637
Configuration options (set of defines)
mbedtls_md_type_t
Supported message digests.
Definition md.h:62
X.509 certificate parsing and writing.