00001 #ifndef __RSA_H__ 00002 #define __RSA_H__ 00003 00004 #include <openssl/rsa.h> 00005 #include <openssl/crypto.h> 00006 #include <openssl/x509.h> 00007 #include <openssl/pem.h> 00008 #include <openssl/ssl.h> 00009 #include <openssl/err.h> 00010 #include <openssl/rand.h> 00011 #include <openssl/x509v3.h> 00012 00013 #include "Cert.h" 00014 00015 class Rsa 00016 { 00017 public: 00018 #define RSA_BLOCK_SIZE 128 00019 00020 static const int blockSize; 00021 00022 Rsa(); 00023 ~Rsa(); 00024 00025 bool loadKey(Cert &cert); 00026 00027 bool loadKey(char* file, char* pass); 00028 00029 int publicEncrypt (unsigned char* in, int inlen, unsigned char* out); 00030 00031 int privateDecrypt(unsigned char* in, int inlen, unsigned char* out); 00032 00033 int privateEncrypt(unsigned char* in, int inlen, unsigned char* out); 00034 00035 int publicDecrypt (unsigned char* in, int inlen, unsigned char* out); 00036 00037 private: 00038 RSA* m_rsa; 00039 }; 00040 00041 #endif // __RSA_H__