xrootd
|
00001 // $Id$ 00002 #ifndef __CRYPTO_LOCALCIPHER_H__ 00003 #define __CRYPTO_LOCALCIPHER_H__ 00004 /******************************************************************************/ 00005 /* */ 00006 /* X r d C r y p t o L o c a l C i p h e r . 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 /* Local implentation of XrdCryptoCipher based on PC1. */ 00017 /* */ 00018 /* ************************************************************************** */ 00019 00020 #include <XrdCrypto/XrdCryptoCipher.hh> 00021 00022 // ---------------------------------------------------------------------------// 00023 // 00024 // Cipher interface 00025 // 00026 // ---------------------------------------------------------------------------// 00027 class XrdCryptolocalCipher : public XrdCryptoCipher 00028 { 00029 private: 00030 bool valid; 00031 unsigned char *bpub; // Key agreement: temporary store local public info 00032 unsigned char *bpriv; // Key agreement: temporary store local private info 00033 00034 public: 00035 XrdCryptolocalCipher(const char *t = "PC1", int l = 0); 00036 XrdCryptolocalCipher(const char *t, int l, const char *k); 00037 XrdCryptolocalCipher(XrdSutBucket *b); 00038 XrdCryptolocalCipher(int len, char *pub, int lpub, const char *t = "PC1"); 00039 XrdCryptolocalCipher(const XrdCryptolocalCipher &c); 00040 virtual ~XrdCryptolocalCipher() { Cleanup(); } 00041 00042 // Finalize key computation (key agreement) 00043 bool Finalize(char *pub, int lpub, const char *t = "PC1"); 00044 void Cleanup(); 00045 00046 // Validity 00047 bool IsValid() { return valid; } 00048 00049 // Additional getters 00050 XrdSutBucket *AsBucket(); 00051 bool IsDefaultLength() const; 00052 char *Public(int &lpub); 00053 00054 // Required buffer size for encrypt / decrypt operations on l bytes 00055 int EncOutLength(int l); 00056 int DecOutLength(int l); 00057 00058 // Additional methods 00059 int Encrypt(const char *in, int lin, char *out); 00060 int Decrypt(const char *in, int lin, char *out); 00061 }; 00062 00063 #endif