26 #ifndef POLARSSL_PKCS11_H
27 #define POLARSSL_PKCS11_H
29 #if !defined(POLARSSL_CONFIG_FILE)
32 #include POLARSSL_CONFIG_FILE
35 #if defined(POLARSSL_PKCS11_C)
39 #include <pkcs11-helper-1.0/pkcs11h-certificate.h>
41 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
42 !defined(inline) && !defined(__cplusplus)
43 #define inline __inline
54 pkcs11h_certificate_t pkcs11h_cert;
66 int pkcs11_x509_cert_init(
x509_crt *cert, pkcs11h_certificate_t pkcs11h_cert );
78 int pkcs11_priv_key_init( pkcs11_context *priv_key,
79 pkcs11h_certificate_t pkcs11_cert );
87 void pkcs11_priv_key_free( pkcs11_context *priv_key );
106 int pkcs11_decrypt( pkcs11_context *ctx,
107 int mode,
size_t *olen,
108 const unsigned char *input,
109 unsigned char *output,
110 size_t output_max_len );
128 int pkcs11_sign( pkcs11_context *ctx,
131 unsigned int hashlen,
132 const unsigned char *hash,
133 unsigned char *sig );
138 static inline int ssl_pkcs11_decrypt(
void *ctx,
int mode,
size_t *olen,
139 const unsigned char *input,
unsigned char *output,
140 size_t output_max_len )
142 return pkcs11_decrypt( (pkcs11_context *) ctx, mode, olen, input, output,
146 static inline int ssl_pkcs11_sign(
void *ctx,
147 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng,
148 int mode,
md_type_t md_alg,
unsigned int hashlen,
149 const unsigned char *hash,
unsigned char *sig )
153 return pkcs11_sign( (pkcs11_context *) ctx, mode, md_alg,
154 hashlen, hash, sig );
157 static inline size_t ssl_pkcs11_key_len(
void *ctx )
159 return ( (pkcs11_context *) ctx )->len;
Configuration options (set of defines)
Container for an X.509 certificate.
X.509 certificate parsing and writing.