Loading...
Searching...
No Matches
XrdCryptoRSA.hh
Go to the documentation of this file.
#ifndef __CRYPTO_RSA_H__
#define __CRYPTO_RSA_H__
/******************************************************************************/
/* */
/* X r d C r y p t o R S A . h h */
/* */
/* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
/* Produced by Gerri Ganis for CERN */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
/* ************************************************************************** */
/* */
/* Abstract interface for RSA PKI functionality. */
/* Allows to plug-in modules based on different crypto implementation */
/* (OpenSSL, Botan, ...) */
/* */
/* ************************************************************************** */
#include "XrdSut/XrdSutBucket.hh"
#include "XrdOuc/XrdOucString.hh"
#include "XrdCrypto/XrdCryptoAux.hh"
typedef void * XrdCryptoRSAdata;
// ---------------------------------------------------------------------------//
//
// RSA interface
//
// ---------------------------------------------------------------------------//
class XrdCryptoRSA
{
public:
XrdCryptoRSA() { status = kInvalid; }
virtual ~XrdCryptoRSA() {}
// Status
enum ERSAStatus { kInvalid = 0, kPublic = 1, kComplete = 2};
ERSAStatus status;
const char *Status(ERSAStatus t = kInvalid) const
{ return ((t == kInvalid) ? cstatus[status] : cstatus[t]); }
// Access underlying data (in opaque form)
virtual XrdCryptoRSAdata Opaque();
// Dump information
virtual void Dump();
// Validity
bool IsValid() { return (status != kInvalid); }
// Output lengths
virtual int GetOutlen(int lin); // Length of encrypted buffers
virtual int GetPublen(); // Length of export public key
virtual int GetPrilen(); // Length of export private key
// Import / Export methods
virtual int ImportPublic(const char *in, int lin);
virtual int ExportPublic(char *out, int lout);
int ExportPublic(XrdOucString &exp);
virtual int ImportPrivate(const char *in, int lin);
virtual int ExportPrivate(char *out, int lout);
int ExportPrivate(XrdOucString &exp);
// Encryption / Decryption methods
virtual int EncryptPrivate(const char *in, int lin, char *out, int lout);
virtual int DecryptPublic(const char *in, int lin, char *out, int lout);
virtual int EncryptPublic(const char *in, int lin, char *out, int lout);
virtual int DecryptPrivate(const char *in, int lin, char *out, int lout);
int EncryptPrivate(XrdSutBucket &buck);
int DecryptPublic (XrdSutBucket &buck);
int EncryptPublic (XrdSutBucket &buck);
int DecryptPrivate(XrdSutBucket &buck);
private:
static const char *cstatus[3]; // Names of status
};
#endif
XrdCryptoAux.hh
XrdCryptoRSAdata
void * XrdCryptoRSAdata
Definition XrdCryptoRSA.hh:43
XrdOucString.hh
XrdSutBucket.hh
XrdCryptoRSA::ImportPublic
virtual int ImportPublic(const char *in, int lin)
Definition XrdCryptoRSA.cc:83
XrdCryptoRSA::ExportPrivate
virtual int ExportPrivate(char *out, int lout)
Definition XrdCryptoRSA.cc:107
XrdCryptoRSA::status
ERSAStatus status
Definition XrdCryptoRSA.hh:58
XrdCryptoRSA::EncryptPublic
virtual int EncryptPublic(const char *in, int lin, char *out, int lout)
Definition XrdCryptoRSA.cc:165
XrdCryptoRSA::Opaque
virtual XrdCryptoRSAdata Opaque()
Definition XrdCryptoRSA.cc:51
XrdCryptoRSA::EncryptPrivate
virtual int EncryptPrivate(const char *in, int lin, char *out, int lout)
Definition XrdCryptoRSA.cc:157
XrdCryptoRSA::GetOutlen
virtual int GetOutlen(int lin)
Definition XrdCryptoRSA.cc:59
XrdCryptoRSA::GetPublen
virtual int GetPublen()
Definition XrdCryptoRSA.cc:67
XrdCryptoRSA::ImportPrivate
virtual int ImportPrivate(const char *in, int lin)
Definition XrdCryptoRSA.cc:99
XrdCryptoRSA::DecryptPublic
virtual int DecryptPublic(const char *in, int lin, char *out, int lout)
Definition XrdCryptoRSA.cc:181
XrdCryptoRSA::Dump
virtual void Dump()
Definition XrdCryptoRSA.cc:44
XrdCryptoRSA::GetPrilen
virtual int GetPrilen()
Definition XrdCryptoRSA.cc:75
XrdCryptoRSA::Status
const char * Status(ERSAStatus t=kInvalid) const
Definition XrdCryptoRSA.hh:59
XrdCryptoRSA::IsValid
bool IsValid()
Definition XrdCryptoRSA.hh:69
XrdCryptoRSA::~XrdCryptoRSA
virtual ~XrdCryptoRSA()
Definition XrdCryptoRSA.hh:54
XrdCryptoRSA::ERSAStatus
ERSAStatus
Definition XrdCryptoRSA.hh:57
XrdCryptoRSA::kInvalid
@ kInvalid
Definition XrdCryptoRSA.hh:57
XrdCryptoRSA::kPublic
@ kPublic
Definition XrdCryptoRSA.hh:57
XrdCryptoRSA::kComplete
@ kComplete
Definition XrdCryptoRSA.hh:57
XrdCryptoRSA::ExportPublic
virtual int ExportPublic(char *out, int lout)
Definition XrdCryptoRSA.cc:91
XrdCryptoRSA::XrdCryptoRSA
XrdCryptoRSA()
Definition XrdCryptoRSA.hh:53
XrdCryptoRSA::DecryptPrivate
virtual int DecryptPrivate(const char *in, int lin, char *out, int lout)
Definition XrdCryptoRSA.cc:173
XrdOucString
Definition XrdOucString.hh:252
XrdSutBucket
Definition XrdSutBucket.hh:44