|
xrootd
|
00001 #ifndef __CRYPTO_LOCALCIPHER_H__ 00002 #define __CRYPTO_LOCALCIPHER_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C r y p t o L o c a l C i p h e r . h h */ 00006 /* */ 00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Gerri Ganis for CERN */ 00009 /* */ 00010 /* This file is part of the XRootD software suite. */ 00011 /* */ 00012 /* XRootD is free software: you can redistribute it and/or modify it under */ 00013 /* the terms of the GNU Lesser General Public License as published by the */ 00014 /* Free Software Foundation, either version 3 of the License, or (at your */ 00015 /* option) any later version. */ 00016 /* */ 00017 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00018 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00019 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00020 /* License for more details. */ 00021 /* */ 00022 /* You should have received a copy of the GNU Lesser General Public License */ 00023 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00024 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00025 /* */ 00026 /* The copyright holder's institutional names and contributor's names may not */ 00027 /* be used to endorse or promote products derived from this software without */ 00028 /* specific prior written permission of the institution or contributor. */ 00029 /******************************************************************************/ 00030 00031 /* ************************************************************************** */ 00032 /* */ 00033 /* Local implentation of XrdCryptoCipher based on PC1. */ 00034 /* */ 00035 /* ************************************************************************** */ 00036 00037 #include "XrdCrypto/XrdCryptoCipher.hh" 00038 00039 // ---------------------------------------------------------------------------// 00040 // 00041 // Cipher interface 00042 // 00043 // ---------------------------------------------------------------------------// 00044 class XrdCryptolocalCipher : public XrdCryptoCipher 00045 { 00046 private: 00047 bool valid; 00048 unsigned char *bpub; // Key agreement: temporary store local public info 00049 unsigned char *bpriv; // Key agreement: temporary store local private info 00050 00051 public: 00052 XrdCryptolocalCipher(const char *t = "PC1", int l = 0); 00053 XrdCryptolocalCipher(const char *t, int l, const char *k); 00054 XrdCryptolocalCipher(XrdSutBucket *b); 00055 XrdCryptolocalCipher(int len, char *pub, int lpub, const char *t = "PC1"); 00056 XrdCryptolocalCipher(const XrdCryptolocalCipher &c); 00057 virtual ~XrdCryptolocalCipher() { Cleanup(); } 00058 00059 // Finalize key computation (key agreement) 00060 bool Finalize(char *pub, int lpub, const char *t = "PC1"); 00061 void Cleanup(); 00062 00063 // Validity 00064 bool IsValid() { return valid; } 00065 00066 // Additional getters 00067 XrdSutBucket *AsBucket(); 00068 bool IsDefaultLength() const; 00069 char *Public(int &lpub); 00070 00071 // Required buffer size for encrypt / decrypt operations on l bytes 00072 int EncOutLength(int l); 00073 int DecOutLength(int l); 00074 00075 // Additional methods 00076 int Encrypt(const char *in, int lin, char *out); 00077 int Decrypt(const char *in, int lin, char *out); 00078 }; 00079 00080 #endif
1.7.6.1