X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccrypt%2Frsa.h;h=6a9506a4aadf5896080f723d632d9a18808c4b29;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hp=5f8262fa80f85c7194c6c8bec9b2c1b3c9e060b9;hpb=d47a87b03b846e2333ef57b2c0d81f1644992964;p=silc.git diff --git a/lib/silccrypt/rsa.h b/lib/silccrypt/rsa.h index 5f8262fa..6a9506a4 100644 --- a/lib/silccrypt/rsa.h +++ b/lib/silccrypt/rsa.h @@ -2,15 +2,14 @@ rsa.h - Author: Pekka Riikonen + Author: Pekka Riikonen - Copyright (C) 1997 - 2000 Pekka Riikonen + Copyright (C) 1997 - 2007 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 @@ -21,21 +20,31 @@ #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); - - -#endif +/* RSA Public Key */ +typedef struct { + SilcMPInt n; /* modulus */ + SilcMPInt e; /* public exponent */ + int bits; /* bits in key */ +} RsaPublicKey; + +/* RSA Private Key */ +typedef struct { + 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 (aka u, aka qInv) */ + int bits; /* bits in key */ +} RsaPrivateKey; + +SilcBool silc_rsa_generate_keys(SilcUInt32 bits, SilcMPInt *p, SilcMPInt *q, + void **ret_public_key, void **ret_private_key); +SilcBool silc_rsa_public_operation(RsaPublicKey *key, SilcMPInt *src, + SilcMPInt *dst); +SilcBool silc_rsa_private_operation(RsaPrivateKey *key, SilcMPInt *src, + SilcMPInt *dst); + +#endif /* RSA_H */