xrootd
XrdCryptoRSA.hh
Go to the documentation of this file.
1 #ifndef __CRYPTO_RSA_H__
2 #define __CRYPTO_RSA_H__
3 /******************************************************************************/
4 /* */
5 /* X r d C r y p t o R S A . h h */
6 /* */
7 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Gerri Ganis for CERN */
9 /* */
10 /* This file is part of the XRootD software suite. */
11 /* */
12 /* XRootD is free software: you can redistribute it and/or modify it under */
13 /* the terms of the GNU Lesser General Public License as published by the */
14 /* Free Software Foundation, either version 3 of the License, or (at your */
15 /* option) any later version. */
16 /* */
17 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20 /* License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25 /* */
26 /* The copyright holder's institutional names and contributor's names may not */
27 /* be used to endorse or promote products derived from this software without */
28 /* specific prior written permission of the institution or contributor. */
29 /******************************************************************************/
30 
31 /* ************************************************************************** */
32 /* */
33 /* Abstract interface for RSA PKI functionality. */
34 /* Allows to plug-in modules based on different crypto implementation */
35 /* (OpenSSL, Botan, ...) */
36 /* */
37 /* ************************************************************************** */
38 
39 #include "XrdSut/XrdSutBucket.hh"
40 #include "XrdOuc/XrdOucString.hh"
42 
43 typedef void * XrdCryptoRSAdata;
44 
45 // ---------------------------------------------------------------------------//
46 //
47 // RSA interface
48 //
49 // ---------------------------------------------------------------------------//
51 {
52 public:
54  virtual ~XrdCryptoRSA() {}
55 
56  // Status
57  enum ERSAStatus { kInvalid = 0, kPublic = 1, kComplete = 2};
59  const char *Status(ERSAStatus t = kInvalid) const
60  { return ((t == kInvalid) ? cstatus[status] : cstatus[t]); }
61 
62  // Access underlying data (in opaque form)
63  virtual XrdCryptoRSAdata Opaque();
64 
65  // Dump information
66  virtual void Dump();
67 
68  // Validity
69  bool IsValid() { return (status != kInvalid); }
70 
71  // Output lengths
72  virtual int GetOutlen(int lin); // Length of encrypted buffers
73  virtual int GetPublen(); // Length of export public key
74  virtual int GetPrilen(); // Length of export private key
75 
76  // Import / Export methods
77  virtual int ImportPublic(const char *in, int lin);
78  virtual int ExportPublic(char *out, int lout);
79  int ExportPublic(XrdOucString &exp);
80  virtual int ImportPrivate(const char *in, int lin);
81  virtual int ExportPrivate(char *out, int lout);
82  int ExportPrivate(XrdOucString &exp);
83 
84  // Encryption / Decryption methods
85  virtual int EncryptPrivate(const char *in, int lin, char *out, int lout);
86  virtual int DecryptPublic(const char *in, int lin, char *out, int lout);
87  virtual int EncryptPublic(const char *in, int lin, char *out, int lout);
88  virtual int DecryptPrivate(const char *in, int lin, char *out, int lout);
89  int EncryptPrivate(XrdSutBucket &buck);
90  int DecryptPublic (XrdSutBucket &buck);
91  int EncryptPublic (XrdSutBucket &buck);
92  int DecryptPrivate(XrdSutBucket &buck);
93 
94 private:
95  static const char *cstatus[3]; // Names of status
96 };
97 
98 #endif
Definition: XrdCryptoRSA.hh:50
ERSAStatus status
Definition: XrdCryptoRSA.hh:58
XrdCryptoRSA()
Definition: XrdCryptoRSA.hh:53
virtual int EncryptPrivate(const char *in, int lin, char *out, int lout)
virtual int GetOutlen(int lin)
virtual int ExportPublic(char *out, int lout)
virtual int GetPrilen()
virtual int EncryptPublic(const char *in, int lin, char *out, int lout)
const char * Status(ERSAStatus t=kInvalid) const
Definition: XrdCryptoRSA.hh:59
Definition: XrdCryptoRSA.hh:57
void * XrdCryptoRSAdata
Definition: XrdCryptoRSA.hh:43
static const char * cstatus[3]
Definition: XrdCryptoRSA.hh:95
virtual int GetPublen()
virtual int DecryptPublic(const char *in, int lin, char *out, int lout)
virtual XrdCryptoRSAdata Opaque()
virtual int ExportPrivate(char *out, int lout)
bool IsValid()
Definition: XrdCryptoRSA.hh:69
Definition: XrdSutBucket.hh:43
Definition: XrdCryptoRSA.hh:57
virtual int ImportPublic(const char *in, int lin)
virtual int ImportPrivate(const char *in, int lin)
virtual int DecryptPrivate(const char *in, int lin, char *out, int lout)
virtual ~XrdCryptoRSA()
Definition: XrdCryptoRSA.hh:54
Definition: XrdOucString.hh:254
virtual void Dump()
ERSAStatus
Definition: XrdCryptoRSA.hh:57
Definition: XrdCryptoRSA.hh:57