New SILC PKCS API, enabling support for other public keys/certs.
[silc.git] / lib / silccrypt / rsa.h
index a697fef493a8c6d51bddfc33d221e5964a6c9d11..0b05728e86a1754e4f9be554b8fb8cd3e3bb50e1 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2003 Pekka Riikonen
+  Copyright (C) 1997 - 2006 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
 #ifndef RSA_H
 #define RSA_H
 
-/*
- * SILC PKCS API for RSA
- */
-
-SILC_PKCS_API_INIT(rsa);
-SILC_PKCS_API_CLEAR_KEYS(rsa);
-SILC_PKCS_API_GET_PUBLIC_KEY(rsa);
-SILC_PKCS_API_GET_PRIVATE_KEY(rsa);
-SILC_PKCS_API_SET_PUBLIC_KEY(rsa);
-SILC_PKCS_API_SET_PRIVATE_KEY(rsa);
-SILC_PKCS_API_CONTEXT_LEN(rsa);
-SILC_PKCS_API_ENCRYPT(rsa);
-SILC_PKCS_API_DECRYPT(rsa);
-SILC_PKCS_API_SIGN(rsa);
-SILC_PKCS_API_VERIFY(rsa);
-
-SILC_PKCS_API_ENCRYPT(pkcs1);
-SILC_PKCS_API_DECRYPT(pkcs1);
-SILC_PKCS_API_SIGN(pkcs1);
-SILC_PKCS_API_VERIFY(pkcs1);
-
-
-#endif
+/* RSA Public Key */
+typedef struct {
+  int bits;                    /* bits in key */
+  SilcMPInt n;                 /* modulus */
+  SilcMPInt e;                 /* public exponent */
+} RsaPublicKey;
+
+/* RSA Private Key */
+typedef struct {
+  int bits;                    /* bits in key */
+  SilcMPInt n;                 /* modulus */
+  SilcMPInt e;                 /* public exponent */
+  SilcMPInt d;                 /* private exponent */
+  SilcMPInt p;                 /* CRT, p */
+  SilcMPInt q;                 /* CRT, q */
+  SilcMPInt dP;                        /* CRT, d mod p - 1 */
+  SilcMPInt dQ;                        /* CRT, d mod q - 1 */
+  SilcMPInt qP;                        /* CRT, q ^ -1 mod p */
+} RsaPrivateKey;
+
+SilcBool rsa_generate_keys(SilcUInt32 bits, SilcMPInt *p, SilcMPInt *q,
+                          void **ret_public_key, void **ret_private_key);
+SilcBool rsa_public_operation(RsaPublicKey *key, SilcMPInt *src,
+                             SilcMPInt *dst);
+SilcBool rsa_private_operation(RsaPrivateKey *key, SilcMPInt *src,
+                              SilcMPInt *dst);
+
+#endif /* RSA_H */