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

/indra/llmessage/llcipher.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 56 lines | 11 code | 7 blank | 38 comment | 0 complexity | 513c6b1fd13e9cfb33a6cadf410e256b MD5 | raw file
 1/** 
 2 * @file llcipher.h
 3 * @brief Abstract base class for encryption ciphers.
 4 *
 5 * $LicenseInfo:firstyear=2003&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LLCIPHER_H
28#define LLCIPHER_H
29
30//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31// Class LLCipher
32//
33// Abstract base class for a cipher object.
34//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35
36class LLCipher
37{
38public:
39	virtual ~LLCipher() {}
40
41	// encrypt src and place result into dst. returns TRUE if
42	// Returns number of bytes written into dst, or 0 on error.
43	virtual U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) = 0;
44
45	// decrypt src and place result into dst. 
46	// Returns number of bytes written into dst, or 0 on error.
47	virtual U32 decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) = 0;
48
49	// returns the minimum amount of space required to encrypt for a 
50	// unencrypted source buffer of length len.
51	// *NOTE: This is estimated space and you should check the return value
52	// of the encrypt function.
53	virtual U32 requiredEncryptionSpace(U32 src_len) const = 0 ;
54};
55
56#endif