mbed TLS v2.28.2
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{
55 pkcs11h_certificate_t pkcs11h_cert;
56 int len;
57} mbedtls_pkcs11_context;
58
59#if defined(MBEDTLS_DEPRECATED_WARNING)
60#define MBEDTLS_DEPRECATED __attribute__((deprecated))
61#else
62#define MBEDTLS_DEPRECATED
63#endif
64
72MBEDTLS_DEPRECATED void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx );
73
85MBEDTLS_DEPRECATED int mbedtls_pkcs11_x509_cert_bind( mbedtls_x509_crt *cert,
86 pkcs11h_certificate_t pkcs11h_cert );
87
101MBEDTLS_DEPRECATED int mbedtls_pkcs11_priv_key_bind(
102 mbedtls_pkcs11_context *priv_key,
103 pkcs11h_certificate_t pkcs11_cert );
104
114MBEDTLS_DEPRECATED void mbedtls_pkcs11_priv_key_free(
115 mbedtls_pkcs11_context *priv_key );
116
137MBEDTLS_DEPRECATED int mbedtls_pkcs11_decrypt( mbedtls_pkcs11_context *ctx,
138 int mode, size_t *olen,
139 const unsigned char *input,
140 unsigned char *output,
141 size_t output_max_len );
142
162MBEDTLS_DEPRECATED int mbedtls_pkcs11_sign( mbedtls_pkcs11_context *ctx,
163 int mode,
164 mbedtls_md_type_t md_alg,
165 unsigned int hashlen,
166 const unsigned char *hash,
167 unsigned char *sig );
168
175MBEDTLS_DEPRECATED static inline int mbedtls_ssl_pkcs11_decrypt( void *ctx,
176 int mode, size_t *olen,
177 const unsigned char *input, unsigned char *output,
178 size_t output_max_len )
179{
180 return mbedtls_pkcs11_decrypt( (mbedtls_pkcs11_context *) ctx, mode, olen, input, output,
181 output_max_len );
182}
183
210MBEDTLS_DEPRECATED static inline int mbedtls_ssl_pkcs11_sign( void *ctx,
211 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
212 int mode, mbedtls_md_type_t md_alg, unsigned int hashlen,
213 const unsigned char *hash, unsigned char *sig )
214{
215 ((void) f_rng);
216 ((void) p_rng);
217 return mbedtls_pkcs11_sign( (mbedtls_pkcs11_context *) ctx, mode, md_alg,
218 hashlen, hash, sig );
219}
220
231MBEDTLS_DEPRECATED static inline size_t mbedtls_ssl_pkcs11_key_len( void *ctx )
232{
233 return ( (mbedtls_pkcs11_context *) ctx )->len;
234}
235
236#undef MBEDTLS_DEPRECATED
237
238#endif /* MBEDTLS_DEPRECATED_REMOVED */
239
240#ifdef __cplusplus
241}
242#endif
243
244#endif /* MBEDTLS_PKCS11_C */
245
246#endif /* MBEDTLS_PKCS11_H */
#define MBEDTLS_DEPRECATED
Definition: aes.h:639
Configuration options (set of defines)
mbedtls_md_type_t
Supported message digests.
Definition: md.h:62
X.509 certificate parsing and writing.