X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccrypt%2Frsa.h;h=1302f3b4c52f2ca0a0395eb1a400f51f28ed8d6e;hb=bd548b5771a325d3dc051887d3fd0225550d4418;hp=a697fef493a8c6d51bddfc33d221e5964a6c9d11;hpb=c257b555225193e54d85daf541d29578b3c93882;p=crypto.git diff --git a/lib/silccrypt/rsa.h b/lib/silccrypt/rsa.h index a697fef4..1302f3b4 100644 --- a/lib/silccrypt/rsa.h +++ b/lib/silccrypt/rsa.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2003 Pekka Riikonen + Copyright (C) 1997 - 2008 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 @@ -20,26 +20,33 @@ #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 { + SilcHash hash; /* Default hash */ + SilcMPInt n; /* modulus */ + SilcMPInt e; /* public exponent */ + int bits; /* bits in key */ +} RsaPublicKey; + +/* RSA Private Key */ +typedef struct { + SilcHash hash; /* Default hash */ + 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 */