updates
[silc.git] / lib / silccrypt / silcpkcs.h
index 50c1354a2693594f681f410104aba2ed3321c949..57968af9deff967e081a52bebb14cee0eb138d5d 100644 (file)
@@ -25,8 +25,6 @@
    any PKCS in SILC. */
 typedef struct SilcPKCSObjectStruct {
   char *name;
-  void *data_context;
-
   int (*init)(void *, uint32, SilcRng);
   void (*clear_keys)(void *);
   unsigned char *(*get_public_key)(void *, uint32 *);
@@ -34,8 +32,6 @@ typedef struct SilcPKCSObjectStruct {
   uint32 (*set_public_key)(void *, unsigned char *, uint32);
   int (*set_private_key)(void *, unsigned char *, uint32);
   uint32 (*context_len)();
-  uint32 (*data_context_len)();
-  int (*set_arg)(void *, void *, int, SilcInt);
   int (*encrypt)(void *, unsigned char *, uint32,
                 unsigned char *, uint32 *);
   int (*decrypt)(void *, unsigned char *, uint32,
@@ -56,9 +52,6 @@ typedef struct SilcPKCSStruct {
   uint32 (*get_key_len)(struct SilcPKCSStruct *);
 } *SilcPKCS;
 
-/* List of all PKCS in SILC. */
-extern SilcPKCSObject silc_pkcs_list[];
-
 /* SILC style public key object. Public key is read from file to this
    object. Public keys received from network must be in this format as 
    well. */
@@ -99,6 +92,16 @@ typedef struct {
 #define SILC_PKCS_FILE_BIN 0
 #define SILC_PKCS_FILE_PEM 1
 
+/* Marks for all PKCS in silc. This can be used in silc_pkcs_unregister
+   to unregister all PKCS at once. */
+#define SILC_ALL_PKCS ((SilcPKCSObject *)1)
+
+/* Static list of PKCS for silc_pkcs_register_default(). */
+extern DLLAPI SilcPKCSObject silc_default_pkcs[];
+
+/* Default PKXS in the SILC protocol */
+#define SILC_DEFAULT_PKCS "rsa"
+
 /* Macros */
 
 /* Macros used to implement the SILC PKCS API */
@@ -118,7 +121,7 @@ typedef struct {
 
    Now we wouldn't have to send the SilcRng object since the primes are 
    provided as arguments. To send them as void * they could actually be 
-   used as in anyway for real (MP_INT (SilcInt) or even something else 
+   used as in anyway for real (MP_INT (SilcMPInt) or even something else 
    (the pointer could be kludged to be something else in the module))
    (Plus, the SilcRng object management in prime generation would be
    simpler and better what it is now (in silcprimegen.c, that is)).
@@ -143,13 +146,6 @@ int silc_##pkcs##_set_private_key(void *context, unsigned char *key_data, \
                                   uint32 key_len)
 #define SILC_PKCS_API_CONTEXT_LEN(pkcs) \
 uint32 silc_##pkcs##_context_len()
-#define SILC_PKCS_API_DATA_CONTEXT_LEN(pkcs) \
-uint32 silc_##pkcs##_data_context_len()
-#define SILC_PKCS_API_SET_ARG(pkcs) \
-int silc_##pkcs##_set_arg(void *context, \
-                         void *data_context, \
-                         int argnum, \
-                         SilcInt val)
 #define SILC_PKCS_API_ENCRYPT(pkcs) \
 int silc_##pkcs##_encrypt(void *context, \
                          unsigned char *src, \
@@ -176,10 +172,13 @@ int silc_##pkcs##_verify(void *context, \
                         uint32 data_len)
 
 /* Prototypes */
-int silc_pkcs_alloc(const unsigned char *name, SilcPKCS *new_pkcs);
+bool silc_pkcs_register(SilcPKCSObject *pkcs);
+bool silc_pkcs_unregister(SilcPKCSObject *pkcs);
+bool silc_pkcs_register_default(void);
+bool silc_pkcs_alloc(const unsigned char *name, SilcPKCS *new_pkcs);
 void silc_pkcs_free(SilcPKCS pkcs);
 int silc_pkcs_is_supported(const unsigned char *name);
-char *silc_pkcs_get_supported();
+char *silc_pkcs_get_supported(void);
 uint32 silc_pkcs_get_key_len(SilcPKCS self);
 unsigned char *silc_pkcs_get_public_key(SilcPKCS pkcs, uint32 *len);
 unsigned char *silc_pkcs_get_private_key(SilcPKCS pkcs, uint32 *len);
@@ -225,6 +224,7 @@ silc_pkcs_public_key_data_encode(unsigned char *pk, uint32 pk_len,
                                 uint32 *len);
 int silc_pkcs_public_key_decode(unsigned char *data, uint32 data_len,
                                SilcPublicKey *public_key);
+bool silc_pkcs_public_key_compare(SilcPublicKey key1, SilcPublicKey key2);
 unsigned char *
 silc_pkcs_private_key_encode(SilcPrivateKey private_key, uint32 *len);
 unsigned char *