xrootd
XrdCryptosslRSA.hh
Go to the documentation of this file.
1 // $Id$
2 #ifndef __CRYPTO_SSLRSA_H__
3 #define __CRYPTO_SSLRSA_H__
4 /******************************************************************************/
5 /* */
6 /* X r d C r y p t o S s l R S A . h h */
7 /* */
8 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
9 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */
10 /* Produced by Andrew Hanushevsky for Stanford University under contract */
11 /* DE-AC03-76-SFO0515 with the Department of Energy */
12 /******************************************************************************/
13 
14 /* ************************************************************************** */
15 /* */
16 /* OpenSSL implementation of XrdCryptoRSA */
17 /* */
18 /* ************************************************************************** */
19 
21 
22 #include <openssl/evp.h>
23 
24 // ---------------------------------------------------------------------------//
25 //
26 // RSA interface
27 //
28 // ---------------------------------------------------------------------------//
30 {
31 private:
32  EVP_PKEY *fEVP; // The key pair
33  int publen; // Length of export public key
34  int prilen; // Length of export private key
35 
36 public:
38  XrdCryptosslRSA(const char *pub, int lpub = 0);
39  XrdCryptosslRSA(EVP_PKEY *key, bool check = 1);
41  virtual ~XrdCryptosslRSA();
42 
43  // Access underlying data (in opaque form)
45 
46  // Dump information
47  void Dump();
48 
49  // Output lengths
50  int GetOutlen(int lin); // Length of encrypted buffers
51  int GetPublen(); // Length of export public key
52  int GetPrilen(); // Length of export private key
53 
54  // Import / Export methods
55  int ImportPublic(const char *in, int lin);
56  int ExportPublic(char *out, int lout);
57  int ImportPrivate(const char *in, int lin);
58  int ExportPrivate(char *out, int lout);
59 
60  // Encryption / Decryption methods
61  int EncryptPrivate(const char *in, int lin, char *out, int lout);
62  int DecryptPublic(const char *in, int lin, char *out, int lout);
63  int EncryptPublic(const char *in, int lin, char *out, int lout);
64  int DecryptPrivate(const char *in, int lin, char *out, int lout);
65 };
66 
67 #endif