Added SILC Server library.
[silc.git] / lib / silccrypt / silcpkcs.h
index e1ed9fc7284b41a1d3a5b5e10e0e37d66a99db27..eeaa240586c1a6878d280ba68fca094b2c778c68 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2003 Pekka Riikonen
+  Copyright (C) 1997 - 2005 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
  ***/
 typedef struct SilcPKCSStruct *SilcPKCS;
 
+/****d* silccrypt/SilcPKCSAPI/SilcPKCSType
+ *
+ * NAME
+ *
+ *    typedef enum { ... } SilcPKCSType
+ *
+ * DESCRIPTION
+ *
+ *    Public key cryptosystem types.  These are defined by the SILC
+ *    Key Exchange protocol.
+ *
+ * SOURCE
+ */
+typedef enum {
+  SILC_PKCS_SILC    = 1,       /* SILC PKCS (mandatory) */
+  SILC_PKCS_SSH2    = 2,       /* SSH2 PKCS (not supported) */
+  SILC_PKCS_X509V3  = 3,       /* X.509v3 PKCS (not supported) */
+  SILC_PKCS_OPENPGP = 4,       /* OpenPGP PKCS (not supported) */
+  SILC_PKCS_SPKI    = 5,       /* SPKI PKCS (not supported) */
+} SilcPKCSType;
+/***/
+
 /* The default SILC PKCS (Public Key Cryptosystem) object to represent
    any PKCS in SILC. */
 typedef struct SilcPKCSObjectStruct {
   char *name;
+  SilcPKCSType type;
   int (*init)(void *, SilcUInt32, SilcRng);
   void (*clear_keys)(void *);
   unsigned char *(*get_public_key)(void *, SilcUInt32 *);
@@ -303,7 +326,8 @@ SilcBool silc_pkcs_unregister_all(void);
  *
  * SYNOPSIS
  *
- *    SilcBool silc_pkcs_alloc(const unsigned char *name, SilcPKCS *new_pkcs);
+ *    SilcBool silc_pkcs_alloc(const unsigned char *name,
+ *                             SilcPKCSType type, SilcPKCS *new_pkcs);
  *
  * DESCRIPTION
  *
@@ -311,7 +335,8 @@ SilcBool silc_pkcs_unregister_all(void);
  *    to the 'new_pkcs' argument.  Returns FALSE on error.
  *
  ***/
-SilcBool silc_pkcs_alloc(const unsigned char *name, SilcPKCS *new_pkcs);
+SilcBool silc_pkcs_alloc(const unsigned char *name,
+                        SilcPKCSType type, SilcPKCS *new_pkcs);
 
 /****f* silccrypt/SilcPKCSAPI/silc_pkcs_free
  *
@@ -366,7 +391,7 @@ char *silc_pkcs_get_supported(void);
  *
  ***/
 SilcBool silc_pkcs_generate_key(SilcPKCS pkcs, SilcUInt32 bits_key_len,
-                           SilcRng rng);
+                               SilcRng rng);
 
 /****f* silccrypt/SilcPKCSAPI/silc_pkcs_get_key_len
  *
@@ -501,8 +526,9 @@ SilcUInt32 silc_pkcs_private_key_data_set(SilcPKCS pkcs, unsigned char *prv,
  *    Encrypts. Returns FALSE on error.
  *
  ***/
-SilcBool silc_pkcs_encrypt(SilcPKCS pkcs, unsigned char *src, SilcUInt32 src_len,
-                      unsigned char *dst, SilcUInt32 *dst_len);
+SilcBool silc_pkcs_encrypt(SilcPKCS pkcs, unsigned char *src,
+                          SilcUInt32 src_len,
+                          unsigned char *dst, SilcUInt32 *dst_len);
 
 /****f* silccrypt/SilcPKCSAPI/silc_pkcs_decrypt
  *
@@ -517,8 +543,9 @@ SilcBool silc_pkcs_encrypt(SilcPKCS pkcs, unsigned char *src, SilcUInt32 src_len
  *    Decrypts.  Returns FALSE on error.
  *
  ***/
-SilcBool silc_pkcs_decrypt(SilcPKCS pkcs, unsigned char *src, SilcUInt32 src_len,
-                      unsigned char *dst, SilcUInt32 *dst_len);
+SilcBool silc_pkcs_decrypt(SilcPKCS pkcs, unsigned char *src,
+                          SilcUInt32 src_len,
+                          unsigned char *dst, SilcUInt32 *dst_len);
 
 /****f* silccrypt/SilcPKCSAPI/silc_pkcs_sign
  *
@@ -534,7 +561,7 @@ SilcBool silc_pkcs_decrypt(SilcPKCS pkcs, unsigned char *src, SilcUInt32 src_len
  *
  ***/
 SilcBool silc_pkcs_sign(SilcPKCS pkcs, unsigned char *src, SilcUInt32 src_len,
-                   unsigned char *dst, SilcUInt32 *dst_len);
+                       unsigned char *dst, SilcUInt32 *dst_len);
 
 /****f* silccrypt/SilcPKCSAPI/silc_pkcs_verify
  *
@@ -551,8 +578,8 @@ SilcBool silc_pkcs_sign(SilcPKCS pkcs, unsigned char *src, SilcUInt32 src_len,
  *
  ***/
 SilcBool silc_pkcs_verify(SilcPKCS pkcs, unsigned char *signature,
-                     SilcUInt32 signature_len, unsigned char *data,
-                     SilcUInt32 data_len);
+                         SilcUInt32 signature_len, unsigned char *data,
+                         SilcUInt32 data_len);
 
 /****f* silccrypt/SilcPKCSAPI/silc_pkcs_sign_with_hash
  *
@@ -569,8 +596,8 @@ SilcBool silc_pkcs_verify(SilcPKCS pkcs, unsigned char *signature,
  *
  ***/
 SilcBool silc_pkcs_sign_with_hash(SilcPKCS pkcs, SilcHash hash,
-                             unsigned char *src, SilcUInt32 src_len,
-                             unsigned char *dst, SilcUInt32 *dst_len);
+                                 unsigned char *src, SilcUInt32 src_len,
+                                 unsigned char *dst, SilcUInt32 *dst_len);
 
 /****f* silccrypt/SilcPKCSAPI/silc_pkcs_verify_with_hash
  *
@@ -589,10 +616,10 @@ SilcBool silc_pkcs_sign_with_hash(SilcPKCS pkcs, SilcHash hash,
  *
  ***/
 SilcBool silc_pkcs_verify_with_hash(SilcPKCS pkcs, SilcHash hash,
-                               unsigned char *signature,
-                               SilcUInt32 signature_len,
-                               unsigned char *data,
-                               SilcUInt32 data_len);
+                                   unsigned char *signature,
+                                   SilcUInt32 signature_len,
+                                   unsigned char *data,
+                                   SilcUInt32 data_len);
 
 /****f* silccrypt/SilcPKCSAPI/silc_pkcs_encode_identifier
  *