xrootd
XrdCryptolocalCipher.hh
Go to the documentation of this file.
1 // $Id$
2 #ifndef __CRYPTO_LOCALCIPHER_H__
3 #define __CRYPTO_LOCALCIPHER_H__
4 /******************************************************************************/
5 /* */
6 /* X r d C r y p t o L o c a l C i p h e r . 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 /* Local implentation of XrdCryptoCipher based on PC1. */
17 /* */
18 /* ************************************************************************** */
19 
21 
22 // ---------------------------------------------------------------------------//
23 //
24 // Cipher interface
25 //
26 // ---------------------------------------------------------------------------//
28 {
29 private:
30  bool valid;
31  unsigned char *bpub; // Key agreement: temporary store local public info
32  unsigned char *bpriv; // Key agreement: temporary store local private info
33 
34 public:
35  XrdCryptolocalCipher(const char *t = "PC1", int l = 0);
36  XrdCryptolocalCipher(const char *t, int l, const char *k);
38  XrdCryptolocalCipher(int len, char *pub, int lpub, const char *t = "PC1");
40  virtual ~XrdCryptolocalCipher() { Cleanup(); }
41 
42  // Finalize key computation (key agreement)
43  bool Finalize(char *pub, int lpub, const char *t = "PC1");
44  void Cleanup();
45 
46  // Validity
47  bool IsValid() { return valid; }
48 
49  // Additional getters
51  bool IsDefaultLength() const;
52  char *Public(int &lpub);
53 
54  // Required buffer size for encrypt / decrypt operations on l bytes
55  int EncOutLength(int l);
56  int DecOutLength(int l);
57 
58  // Additional methods
59  int Encrypt(const char *in, int lin, char *out);
60  int Decrypt(const char *in, int lin, char *out);
61 };
62 
63 #endif