*
* DESCRIPTION
*
- * Public key cryptosystem types. These are defined by the SILC
- * Key Exchange protocol.
+ * Supported public key cryptosystem types.
*
* SOURCE
*/
*
* SOURCE
*/
-typedef struct {
+typedef struct SilcPublicKeyStruct {
const SilcPKCSObject *pkcs; /* PKCS */
void *public_key; /* PKCS specific public key */
} *SilcPublicKey;
*
* SOURCE
*/
-typedef struct {
+typedef struct SilcPrivateKeyStruct {
const SilcPKCSObject *pkcs; /* PKCS */
void *private_key; /* PKCS specific private key */
} *SilcPrivateKey;
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);
+ /* Public key routines. */
+ int (*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_free)(void *public_key);
/* Private key routines */
- SilcBool (*import_private_key)(unsigned char *key,
- SilcUInt32 key_len,
- void **ret_private_key);
+ int (*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);
unsigned char *signature,
SilcUInt32 signature_size,
SilcUInt32 *ret_signature_len,
+ SilcBool compute_hash,
SilcHash hash);
SilcBool (*verify)(void *public_key,
unsigned char *signature,
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);
+ /* Imports from public key binary data. Returns the amount of bytes
+ imported from `key' or 0 on error. */
+ int (*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,
void **ret_private_key);
- /* Imports from private key binary data */
- SilcBool (*import_private_key)(unsigned char *key,
- SilcUInt32 key_len,
- void **ret_private_key);
+ /* Imports from private key binary data. Returns the amount of bytes
+ imported from `key' or 0 on error. */
+ int (*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,
unsigned char *signature,
SilcUInt32 signature_size,
SilcUInt32 *ret_signature_len,
+ SilcBool compute_hash,
SilcHash hash);
SilcBool (*verify)(void *public_key,
unsigned char *signature,
SilcHash hash);
};
-/* Marks for all PKCS in silc. This can be used in silc_pkcs_unregister
- to unregister all PKCS at once. */
+/* Marks for all PKCS in. This can be used in silc_pkcs_unregister to
+ unregister all PKCS at once. */
#define SILC_ALL_PKCS ((SilcPKCSObject *)1)
#define SILC_ALL_PKCS_ALG ((SilcPKCSAlgorithm *)1)
* SilcBool silc_pkcs_sign(SilcPrivateKey private_key,
* unsigned char *src, SilcUInt32 src_len,
* unsigned char *dst, SilcUInt32 dst_size,
- * SilcUInt32 *dst_len, SilcHash hash);
+ * SilcUInt32 *dst_len, SilcBool compute_hash,
+ * SilcHash hash);
*
* DESCRIPTION
*
* Generates signature with the private key. Returns FALSE on error.
- * If `hash' is non-NULL the `src' will be hashed before signing.
+ * If `compute_hash' is TRUE the `hash' will be used to compute a
+ * digest over the `src'. The `hash' must always be valid.
*
***/
SilcBool silc_pkcs_sign(SilcPrivateKey private_key,
unsigned char *src, SilcUInt32 src_len,
unsigned char *dst, SilcUInt32 dst_size,
- SilcUInt32 *dst_len, SilcHash hash);
+ SilcUInt32 *dst_len, SilcBool compute_hash,
+ SilcHash hash);
/****f* silccrypt/SilcPKCSAPI/silc_pkcs_verify
*