+ char *scheme;
+
+ /* Supported hash functions, comma separated list */
+ char *hash;
+
+ /* Generate new key pair. Returns PKCS algorithm specific public key
+ and private key contexts. */
+ SilcBool (*generate_key)(SilcUInt32 keylen,
+ SilcRng rng,
+ void **ret_public_key,
+ void **ret_private_key);
+
+ /* Public key routines */
+ SilcBool (*import_public_key)(unsigned char *key,
+ SilcUInt32 key_len,
+ void **ret_public_key);
+ unsigned char *(*export_public_key)(void *public_key,
+ SilcUInt32 *ret_len);
+ SilcUInt32 (*public_key_bitlen)(void *public_key);
+ void *(*public_key_copy)(void *public_key);
+ SilcBool (*public_key_compare)(void *key1, void *key2);
+ void (*public_key_free)(void *public_key);
+
+ /* Private key routines */
+ SilcBool (*import_private_key)(unsigned char *key,
+ SilcUInt32 key_len,
+ void **ret_private_key);
+ unsigned char *(*export_private_key)(void *private_key,
+ SilcUInt32 *ret_len);
+ SilcUInt32 (*private_key_bitlen)(void *public_key);
+ void (*private_key_free)(void *private_key);
+
+ /* Encrypt and decrypt operations */
+ SilcBool (*encrypt)(void *public_key,
+ unsigned char *src,
+ SilcUInt32 src_len,
+ unsigned char *dst,
+ SilcUInt32 dst_size,
+ SilcUInt32 *ret_dst_len,
+ SilcRng rng);
+ SilcBool (*decrypt)(void *private_key,
+ unsigned char *src,
+ SilcUInt32 src_len,
+ unsigned char *dst,
+ SilcUInt32 dst_size,
+ SilcUInt32 *ret_dst_len);
+
+ /* Signature and verification operations */
+ SilcBool (*sign)(void *private_key,
+ unsigned char *src,
+ SilcUInt32 src_len,
+ unsigned char *signature,
+ SilcUInt32 signature_size,
+ SilcUInt32 *ret_signature_len,
+ SilcHash hash);
+ SilcBool (*verify)(void *public_key,
+ unsigned char *signature,
+ SilcUInt32 signature_len,
+ unsigned char *data,
+ SilcUInt32 data_len,
+ SilcHash hash);
+} SilcPKCSAlgorithm;
+
+/* The PKCS (Public Key Cryptosystem) object to represent any PKCS. */
+struct SilcPKCSObjectStruct {
+ /* PKCS type */
+ SilcPKCSType type;
+
+ /* Public key routines */
+
+ /* Returns PKCS algorithm context from public key */
+ const SilcPKCSAlgorithm *(*get_algorithm)(void *public_key);
+
+ /* Imports from public key file */
+ SilcBool (*import_public_key_file)(unsigned char *filedata,
+ SilcUInt32 filedata_len,
+ SilcPKCSFileEncoding encoding,
+ void **ret_public_key);
+
+ /* Imports from public key binary data */
+ SilcBool (*import_public_key)(unsigned char *key,
+ SilcUInt32 key_len,
+ void **ret_public_key);
+
+ /* Exports public key to file */
+ unsigned char *(*export_public_key_file)(void *public_key,
+ SilcPKCSFileEncoding encoding,
+ SilcUInt32 *ret_len);
+
+ /* Export public key as binary data */
+ unsigned char *(*export_public_key)(void *public_key,
+ SilcUInt32 *ret_len);
+
+ /* Returns key length in bits */
+ SilcUInt32 (*public_key_bitlen)(void *public_key);
+
+ /* Copy public key */
+ void *(*public_key_copy)(void *public_key);
+
+ /* Compares public keys */
+ SilcBool (*public_key_compare)(void *key1, void *key2);
+
+ /* Free public key */
+ void (*public_key_free)(void *public_key);
+
+ /* Private key routines */
+
+ /* Imports from private key file */
+ SilcBool (*import_private_key_file)(unsigned char *filedata,
+ SilcUInt32 filedata_len,
+ const char *passphrase,
+ SilcUInt32 passphrase_len,
+ SilcPKCSFileEncoding encoding,
+ void **ret_private_key);
+
+ /* Imports from private key binary data */
+ SilcBool (*import_private_key)(unsigned char *key,
+ SilcUInt32 key_len,
+ void **ret_private_key);
+
+ /* Exports private key to file */
+ unsigned char *(*export_private_key_file)(void *private_key,
+ const char *passphrase,
+ SilcUInt32 passphrase_len,
+ SilcPKCSFileEncoding encoding,
+ SilcRng rng,
+ SilcUInt32 *ret_len);
+
+ /* Export private key as binary data */
+ unsigned char *(*export_private_key)(void *private_key,
+ SilcUInt32 *ret_len);
+
+ /* Returns key length in bits */
+ SilcUInt32 (*private_key_bitlen)(void *private_key);
+
+ /* Free private key */
+ void (*private_key_free)(void *private_key);
+
+ /* Encrypt and decrypt operations */
+ SilcBool (*encrypt)(void *public_key,
+ unsigned char *src,
+ SilcUInt32 src_len,
+ unsigned char *dst,
+ SilcUInt32 dst_size,
+ SilcUInt32 *ret_dst_len,
+ SilcRng rng);
+ SilcBool (*decrypt)(void *private_key,
+ unsigned char *src,
+ SilcUInt32 src_len,
+ unsigned char *dst,
+ SilcUInt32 dst_size,
+ SilcUInt32 *ret_dst_len);
+
+ /* Signature and verification operations */
+ SilcBool (*sign)(void *private_key,
+ unsigned char *src,
+ SilcUInt32 src_len,
+ unsigned char *signature,
+ SilcUInt32 signature_size,
+ SilcUInt32 *ret_signature_len,
+ SilcHash hash);
+ SilcBool (*verify)(void *public_key,
+ unsigned char *signature,
+ SilcUInt32 signature_len,
+ unsigned char *data,
+ SilcUInt32 data_len,
+ SilcHash hash);
+};