29 #ifndef POLARSSL_PKCS11_H
30 #define POLARSSL_PKCS11_H
34 #if defined(POLARSSL_PKCS11_C)
38 #include <pkcs11-helper-1.0/pkcs11h-certificate.h>
40 #if defined(_MSC_VER) && !defined(inline)
41 #define inline _inline
43 #if defined(__ARMCC_VERSION) && !defined(inline)
44 #define inline __inline
52 pkcs11h_certificate_t pkcs11h_cert;
64 int pkcs11_x509_cert_init(
x509_cert *cert, pkcs11h_certificate_t pkcs11h_cert );
76 int pkcs11_priv_key_init( pkcs11_context *priv_key,
77 pkcs11h_certificate_t pkcs11_cert );
85 void pkcs11_priv_key_free( pkcs11_context *priv_key );
103 int pkcs11_decrypt( pkcs11_context *ctx,
104 int mode,
size_t *olen,
105 const unsigned char *input,
106 unsigned char *output,
107 size_t output_max_len );
125 int pkcs11_sign( pkcs11_context *ctx,
128 unsigned int hashlen,
129 const unsigned char *hash,
130 unsigned char *sig );
135 static inline int ssl_pkcs11_decrypt(
void *ctx,
int mode,
size_t *olen,
136 const unsigned char *input,
unsigned char *output,
137 size_t output_max_len )
139 return pkcs11_decrypt( (pkcs11_context *) ctx, mode, olen, input, output,
143 static inline int ssl_pkcs11_sign(
void *ctx,
144 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng,
145 int mode,
int hash_id,
unsigned int hashlen,
146 const unsigned char *hash,
unsigned char *sig )
150 return pkcs11_sign( (pkcs11_context *) ctx, mode, hash_id,
151 hashlen, hash, sig );
154 static inline size_t ssl_pkcs11_key_len(
void *ctx )
156 return ( (pkcs11_context *) ctx )->len;