PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 6ms 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
 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
30#ifndef LLBLOWFISHCIPHER_H
31#define LLBLOWFISHCIPHER_H
32
33#include "llcipher.h"
34
35
36class LLBlowfishCipher : public LLCipher
37{
38public:
39	// Secret may be up to 56 bytes in length per Blowfish spec.
40	LLBlowfishCipher(const U8* secret, size_t secret_size);
41	virtual ~LLBlowfishCipher();
42
43	// See llcipher.h for documentation.
44	/*virtual*/ U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len);
45	/*virtual*/ U32 decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len);
46	/*virtual*/ U32 requiredEncryptionSpace(U32 src_len) const;
47
48#ifdef _DEBUG
49	static BOOL testHarness();
50#endif
51
52private:
53	U8* mSecret;
54	size_t mSecretSize;
55};
56
57#endif // LL_LLCRYPTO_H