XrdCryptoRSA.hh

Go to the documentation of this file.
00001 // $Id: XrdCryptoRSA.hh 22437 2008-03-04 14:35:16Z rdm $
00002 #ifndef __CRYPTO_RSA_H__
00003 #define __CRYPTO_RSA_H__
00004 /******************************************************************************/
00005 /*                                                                            */
00006 /*                       X r d C r y p t o 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 /* Abstract interface for RSA PKI functionality.                              */
00017 /* Allows to plug-in modules based on different crypto implementation         */
00018 /* (OpenSSL, Botan, ...)                                                      */
00019 /*                                                                            */
00020 /* ************************************************************************** */
00021 
00022 #include <XrdSut/XrdSutBucket.hh>
00023 #include <XrdOuc/XrdOucString.hh>
00024 #include <XrdCrypto/XrdCryptoAux.hh>
00025 
00026 typedef void * XrdCryptoRSAdata;
00027 
00028 // ---------------------------------------------------------------------------//
00029 //
00030 // RSA interface
00031 //
00032 // ---------------------------------------------------------------------------//
00033 class XrdCryptoRSA
00034 {
00035 public:
00036    XrdCryptoRSA() { status = kInvalid; }
00037    virtual ~XrdCryptoRSA() {}
00038 
00039    // Status
00040    enum ERSAStatus { kInvalid = 0, kPublic = 1, kComplete = 2};
00041    ERSAStatus  status;
00042    const char *Status(ERSAStatus t = kInvalid) const
00043                  { return ((t == kInvalid) ? cstatus[status] : cstatus[t]); }
00044 
00045    // Access underlying data (in opaque form)
00046    virtual XrdCryptoRSAdata Opaque();
00047 
00048    // Dump information
00049    virtual void Dump();
00050 
00051    // Validity
00052    bool IsValid() { return (status != kInvalid); }
00053 
00054    // Output lengths
00055    virtual int GetOutlen(int lin);   // Length of encrypted buffers
00056    virtual int GetPublen();          // Length of export public key
00057    virtual int GetPrilen();          // Length of export private key
00058 
00059    // Import / Export methods
00060    virtual int ImportPublic(const char *in, int lin);
00061    virtual int ExportPublic(char *out, int lout);
00062    int ExportPublic(XrdOucString &exp);
00063    virtual int ImportPrivate(const char *in, int lin);
00064    virtual int ExportPrivate(char *out, int lout);
00065    int ExportPrivate(XrdOucString &exp);
00066 
00067    // Encryption / Decryption methods
00068    virtual int EncryptPrivate(const char *in, int lin, char *out, int lout);
00069    virtual int DecryptPublic(const char *in, int lin, char *out, int lout);
00070    virtual int EncryptPublic(const char *in, int lin, char *out, int lout);
00071    virtual int DecryptPrivate(const char *in, int lin, char *out, int lout);
00072    int EncryptPrivate(XrdSutBucket &buck);
00073    int DecryptPublic (XrdSutBucket &buck);
00074    int EncryptPublic (XrdSutBucket &buck);
00075    int DecryptPrivate(XrdSutBucket &buck);
00076 
00077 private:
00078    static const char *cstatus[3];  // Names of status
00079 };
00080 
00081 #endif

Generated on Tue Jul 5 14:46:33 2011 for ROOT_528-00b_version by  doxygen 1.5.1