29 #ifndef POLARSSL_PKCS11_H
30 #define POLARSSL_PKCS11_H
32 #if !defined(POLARSSL_CONFIG_FILE)
35 #include POLARSSL_CONFIG_FILE
38 #if defined(POLARSSL_PKCS11_C)
42 #include <pkcs11-helper-1.0/pkcs11h-certificate.h>
44 #if defined(_MSC_VER) && !defined(inline)
45 #define inline _inline
47 #if defined(__ARMCC_VERSION) && !defined(inline)
48 #define inline __inline
60 pkcs11h_certificate_t pkcs11h_cert;
72 int pkcs11_x509_cert_init(
x509_crt *cert, pkcs11h_certificate_t pkcs11h_cert );
84 int pkcs11_priv_key_init( pkcs11_context *priv_key,
85 pkcs11h_certificate_t pkcs11_cert );
93 void pkcs11_priv_key_free( pkcs11_context *priv_key );
112 int pkcs11_decrypt( pkcs11_context *ctx,
113 int mode,
size_t *olen,
114 const unsigned char *input,
115 unsigned char *output,
116 size_t output_max_len );
134 int pkcs11_sign( pkcs11_context *ctx,
137 unsigned int hashlen,
138 const unsigned char *hash,
139 unsigned char *sig );
144 static inline int ssl_pkcs11_decrypt(
void *ctx,
int mode,
size_t *olen,
145 const unsigned char *input,
unsigned char *output,
146 size_t output_max_len )
148 return pkcs11_decrypt( (pkcs11_context *) ctx, mode, olen, input, output,
152 static inline int ssl_pkcs11_sign(
void *ctx,
153 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng,
154 int mode,
md_type_t md_alg,
unsigned int hashlen,
155 const unsigned char *hash,
unsigned char *sig )
159 return pkcs11_sign( (pkcs11_context *) ctx, mode, md_alg,
160 hashlen, hash, sig );
163 static inline size_t ssl_pkcs11_key_len(
void *ctx )
165 return ( (pkcs11_context *) ctx )->len;