PageRenderTime 33ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/llblowfishcipher.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 57 lines | 19 code | 8 blank | 30 comment | 0 complexity | f70a6d98cbfac575ba4e77d997ef47cf MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llblowfishcipher.h
  3. * @brief A symmetric block cipher, designed in 1993 by Bruce Schneier.
  4. * We use it because it has an 8 byte block size, allowing encryption of
  5. * two UUIDs and a timestamp (16x2 + 4 = 36 bytes) with only 40 bytes of
  6. * output. AES has a block size of 32 bytes, so this would require 64 bytes.
  7. *
  8. * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  9. * Second Life Viewer Source Code
  10. * Copyright (C) 2010, Linden Research, Inc.
  11. *
  12. * This library is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation;
  15. * version 2.1 of the License only.
  16. *
  17. * This library is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with this library; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. *
  26. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  27. * $/LicenseInfo$
  28. */
  29. #ifndef LLBLOWFISHCIPHER_H
  30. #define LLBLOWFISHCIPHER_H
  31. #include "llcipher.h"
  32. class LLBlowfishCipher : public LLCipher
  33. {
  34. public:
  35. // Secret may be up to 56 bytes in length per Blowfish spec.
  36. LLBlowfishCipher(const U8* secret, size_t secret_size);
  37. virtual ~LLBlowfishCipher();
  38. // See llcipher.h for documentation.
  39. /*virtual*/ U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len);
  40. /*virtual*/ U32 decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len);
  41. /*virtual*/ U32 requiredEncryptionSpace(U32 src_len) const;
  42. #ifdef _DEBUG
  43. static BOOL testHarness();
  44. #endif
  45. private:
  46. U8* mSecret;
  47. size_t mSecretSize;
  48. };
  49. #endif // LL_LLCRYPTO_H