Added SILC_ASN1_ANY_PRIMITIVE to encode/decode any pre-encoded
[silc.git] / lib / silccrypt / rsa_internal.h
index 1f218a853fec72622116d98ae86b219d4f522982..f3daa12652de771391a8610d562ca1a2bb80c789 100644 (file)
@@ -2,15 +2,14 @@
 
   rsa_internal.h
 
-  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+  Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2000 Pekka Riikonen
+  Copyright (C) 1997 - 2003 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
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-  
+  the Free Software Foundation; version 2 of the License.
+
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 /* RSA Keys, includes both Private and Public key */
 typedef struct {
   int bits;                    /* bits in key */
-  SilcInt p;                   /* prime p */
-  SilcInt q;                   /* prime q */
-  SilcInt n;                   /* modulus */
-  SilcInt e;                   /* public exponent */
-  SilcInt d;                   /* private exponent */
+  SilcMPInt n;                 /* modulus */
+  SilcMPInt e;                 /* public exponent */
+  SilcMPInt d;                 /* private exponent (no CRT) */
+  SilcMPInt p;                 /* p */
+  SilcMPInt q;                 /* q */
+  SilcMPInt dP;                        /* CRT, d mod p - 1 */
+  SilcMPInt dQ;                        /* CRT, d mod q - 1 */
+  SilcMPInt pQ;                        /* CRT, p * (p ^ -1 mod q) mod n */
+  SilcMPInt qP;                        /* CRT, q * (q ^ -1 mod p) mod n */
+  unsigned int pub_set : 1;    /* TRUE if n and e is set */
+  unsigned int prv_set : 1;    /* TRUE if d is set */
+  unsigned int crt     : 1;    /* TRUE if CRT is used */
 } RsaKey;
 
-void rsa_generate_keys(RsaKey *key, uint32 bits, 
-                      SilcInt *p, SilcInt *q);
-void rsa_clear_keys(RsaKey *key);
-void rsa_en_de_crypt(SilcInt *cm, SilcInt *mc, 
-                    SilcInt *expo, SilcInt *modu);
+SilcBool rsa_generate_keys(RsaKey *key, SilcUInt32 bits,
+                      SilcMPInt *p, SilcMPInt *q);
+SilcBool rsa_clear_keys(RsaKey *key);
+SilcBool rsa_public_operation(RsaKey *key, SilcMPInt *src, SilcMPInt *dst);
+SilcBool rsa_private_operation(RsaKey *key, SilcMPInt *src, SilcMPInt *dst);
 
 #endif