mbed TLS v2.23.0
pkcs11.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
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  * This file is part of mbed TLS (https://tls.mbed.org)
25  */
26 #ifndef MBEDTLS_PKCS11_H
27 #define MBEDTLS_PKCS11_H
28 
29 #if !defined(MBEDTLS_CONFIG_FILE)
30 #include "mbedtls/config.h"
31 #else
32 #include MBEDTLS_CONFIG_FILE
33 #endif
34 
35 #if defined(MBEDTLS_PKCS11_C)
36 
37 #include "mbedtls/x509_crt.h"
38 
39 #include <pkcs11-helper-1.0/pkcs11h-certificate.h>
40 
41 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
42  !defined(inline) && !defined(__cplusplus)
43 #define inline __inline
44 #endif
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #if defined(MBEDTLS_DEPRECATED_REMOVED)
51 
55 typedef struct mbedtls_pkcs11_context
56 {
57  pkcs11h_certificate_t pkcs11h_cert;
58  int len;
59 } mbedtls_pkcs11_context;
60 
61 #if defined(MBEDTLS_DEPRECATED_WARNING)
62 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
63 #else
64 #define MBEDTLS_DEPRECATED
65 #endif
66 
74 MBEDTLS_DEPRECATED void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx );
75 
87 MBEDTLS_DEPRECATED int mbedtls_pkcs11_x509_cert_bind( mbedtls_x509_crt *cert,
88  pkcs11h_certificate_t pkcs11h_cert );
89 
103 MBEDTLS_DEPRECATED int mbedtls_pkcs11_priv_key_bind(
104  mbedtls_pkcs11_context *priv_key,
105  pkcs11h_certificate_t pkcs11_cert );
106 
116 MBEDTLS_DEPRECATED void mbedtls_pkcs11_priv_key_free(
117  mbedtls_pkcs11_context *priv_key );
118 
139 MBEDTLS_DEPRECATED int mbedtls_pkcs11_decrypt( mbedtls_pkcs11_context *ctx,
140  int mode, size_t *olen,
141  const unsigned char *input,
142  unsigned char *output,
143  size_t output_max_len );
144 
164 MBEDTLS_DEPRECATED int mbedtls_pkcs11_sign( mbedtls_pkcs11_context *ctx,
165  int mode,
166  mbedtls_md_type_t md_alg,
167  unsigned int hashlen,
168  const unsigned char *hash,
169  unsigned char *sig );
170 
177 MBEDTLS_DEPRECATED static inline int mbedtls_ssl_pkcs11_decrypt( void *ctx,
178  int mode, size_t *olen,
179  const unsigned char *input, unsigned char *output,
180  size_t output_max_len )
181 {
182  return mbedtls_pkcs11_decrypt( (mbedtls_pkcs11_context *) ctx, mode, olen, input, output,
183  output_max_len );
184 }
185 
212 MBEDTLS_DEPRECATED static inline int mbedtls_ssl_pkcs11_sign( void *ctx,
213  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
214  int mode, mbedtls_md_type_t md_alg, unsigned int hashlen,
215  const unsigned char *hash, unsigned char *sig )
216 {
217  ((void) f_rng);
218  ((void) p_rng);
219  return mbedtls_pkcs11_sign( (mbedtls_pkcs11_context *) ctx, mode, md_alg,
220  hashlen, hash, sig );
221 }
222 
233 MBEDTLS_DEPRECATED static inline size_t mbedtls_ssl_pkcs11_key_len( void *ctx )
234 {
235  return ( (mbedtls_pkcs11_context *) ctx )->len;
236 }
237 
238 #undef MBEDTLS_DEPRECATED
239 
240 #endif /* MBEDTLS_DEPRECATED_REMOVED */
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #endif /* MBEDTLS_PKCS11_C */
247 
248 #endif /* MBEDTLS_PKCS11_H */
mbedtls_md_type_t
mbedtls_md_type_t
Supported message digests.
Definition: md.h:58
mbedtls_x509_crt
Definition: x509_crt.h:55
config.h
Configuration options (set of defines)
MBEDTLS_DEPRECATED
#define MBEDTLS_DEPRECATED
Definition: aes.h:626
x509_crt.h
X.509 certificate parsing and writing.