00001
00002
00003 #ifndef BASE_CRYPTO_CRYPTOKEYPAIRRSA_H
00004 #define BASE_CRYPTO_CRYPTOKEYPAIRRSA_H
00005
00006 #include <openssl/rsa.h>
00007 #include "CryptoKeypair.h"
00008
00009 namespace base_crypto {
00016 class PPBASE_CRYPTO_EXPORT CryptoKeypairRSA: public CryptoKeypair {
00017 public:
00019 CryptoKeypairRSA();
00020
00021 private:
00023 virtual ~CryptoKeypairRSA();
00024
00026 virtual void create(unsigned keylen);
00027
00029 virtual keypairMethod getMethodId() const;
00030
00032 virtual const char *getMethodName() const;
00033
00035 virtual unsigned getPrivateKey(unsigned char **rbuf) const;
00036
00038 virtual unsigned getPublicKey(unsigned char **rbuf) const;
00039
00041 virtual unsigned getSize() const;
00042
00044 virtual void readPrivateKey(FILE *file, bool pem);
00045
00047 virtual void readPrivateKey(const char *fname, bool pem);
00048
00050 virtual void readPublicKey(FILE *file, bool pem);
00051
00053 virtual void readPublicKey(const char *fname, bool pem);
00054
00056 virtual void setPrivateKey(const unsigned char *buf, unsigned len);
00057
00059 virtual void setPublicKey(const unsigned char *buf, unsigned len);
00060
00062 virtual unsigned sign(const unsigned char *data, unsigned len, CryptoChecksum::checksumMethod type, unsigned char *sig);
00063
00065 virtual bool verify(const unsigned char *data, unsigned datalen, CryptoChecksum::checksumMethod method,
00066 const unsigned char *sig, unsigned siglen);
00067
00069 virtual void writePrivateKey(FILE *file, bool pem);
00070
00072 virtual void writePrivateKey(const char *fname, bool pem);
00073
00075 virtual void writePublicKey(FILE *file, bool pem);
00076
00078 virtual void writePublicKey(const char *fname, bool pem);
00079
00080 RSA *_ctx;
00081 };
00082 }
00083
00084 #endif