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,
136 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng,
137 int mode,
size_t *olen,
const unsigned char *input,
138 unsigned char *output,
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,
int hash_id,
unsigned int hashlen,
149 const unsigned char *hash,
unsigned char *sig )
153 return pkcs11_sign( (pkcs11_context *) ctx, mode, hash_id,
154 hashlen, hash, sig );
157 static inline size_t ssl_pkcs11_key_len(
void *ctx )
159 return ( (pkcs11_context *) ctx )->len;