xrootd
|
00001 // $Id$ 00002 #ifndef __CRYPTO_SSLRSA_H__ 00003 #define __CRYPTO_SSLRSA_H__ 00004 /******************************************************************************/ 00005 /* */ 00006 /* X r d C r y p t o S s l R S A . h h */ 00007 /* */ 00008 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00009 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */ 00010 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00011 /* DE-AC03-76-SFO0515 with the Department of Energy */ 00012 /******************************************************************************/ 00013 00014 /* ************************************************************************** */ 00015 /* */ 00016 /* OpenSSL implementation of XrdCryptoRSA */ 00017 /* */ 00018 /* ************************************************************************** */ 00019 00020 #include <XrdCrypto/XrdCryptoRSA.hh> 00021 00022 #include <openssl/evp.h> 00023 00024 // ---------------------------------------------------------------------------// 00025 // 00026 // RSA interface 00027 // 00028 // ---------------------------------------------------------------------------// 00029 class XrdCryptosslRSA : public XrdCryptoRSA 00030 { 00031 private: 00032 EVP_PKEY *fEVP; // The key pair 00033 int publen; // Length of export public key 00034 int prilen; // Length of export private key 00035 00036 public: 00037 XrdCryptosslRSA(int bits = XrdCryptoMinRSABits, int exp = XrdCryptoDefRSAExp); 00038 XrdCryptosslRSA(const char *pub, int lpub = 0); 00039 XrdCryptosslRSA(EVP_PKEY *key, bool check = 1); 00040 XrdCryptosslRSA(const XrdCryptosslRSA &r); 00041 virtual ~XrdCryptosslRSA(); 00042 00043 // Access underlying data (in opaque form) 00044 XrdCryptoRSAdata Opaque() { return fEVP; } 00045 00046 // Dump information 00047 void Dump(); 00048 00049 // Output lengths 00050 int GetOutlen(int lin); // Length of encrypted buffers 00051 int GetPublen(); // Length of export public key 00052 int GetPrilen(); // Length of export private key 00053 00054 // Import / Export methods 00055 int ImportPublic(const char *in, int lin); 00056 int ExportPublic(char *out, int lout); 00057 int ImportPrivate(const char *in, int lin); 00058 int ExportPrivate(char *out, int lout); 00059 00060 // Encryption / Decryption methods 00061 int EncryptPrivate(const char *in, int lin, char *out, int lout); 00062 int DecryptPublic(const char *in, int lin, char *out, int lout); 00063 int EncryptPublic(const char *in, int lin, char *out, int lout); 00064 int DecryptPrivate(const char *in, int lin, char *out, int lout); 00065 }; 00066 00067 #endif