~ubuntu-branches/debian/jessie/armory/jessie

« back to all changes in this revision

Viewing changes to cppForSwig/cryptopp/salsa.h

  • Committer: Package Import Robot
  • Author(s): Joseph Bisch
  • Date: 2014-10-07 10:22:45 UTC
  • Revision ID: package-import@ubuntu.com-20141007102245-2s3x3rhjxg689hek
Tags: upstream-0.92.3
ImportĀ upstreamĀ versionĀ 0.92.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// salsa.h - written and placed in the public domain by Wei Dai
 
2
 
 
3
#ifndef CRYPTOPP_SALSA_H
 
4
#define CRYPTOPP_SALSA_H
 
5
 
 
6
#include "strciphr.h"
 
7
 
 
8
NAMESPACE_BEGIN(CryptoPP)
 
9
 
 
10
//! _
 
11
struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::UNIQUE_IV, 8>
 
12
{
 
13
        static const char *StaticAlgorithmName() {return "Salsa20";}
 
14
};
 
15
 
 
16
class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<word32, 16>
 
17
{
 
18
protected:
 
19
        void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
 
20
        void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
 
21
        void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
 
22
        bool CipherIsRandomAccess() const {return true;}
 
23
        void SeekToIteration(lword iterationCount);
 
24
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64
 
25
        unsigned int GetAlignment() const;
 
26
        unsigned int GetOptimalBlockSize() const;
 
27
#endif
 
28
 
 
29
        FixedSizeAlignedSecBlock<word32, 16> m_state;
 
30
        int m_rounds;
 
31
};
 
32
 
 
33
/// <a href="http://www.cryptolounge.org/wiki/Salsa20">Salsa20</a>, variable rounds: 8, 12 or 20 (default 20)
 
34
struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation
 
35
{
 
36
        typedef SymmetricCipherFinal<ConcretePolicyHolder<Salsa20_Policy, AdditiveCipherTemplate<> >, Salsa20_Info> Encryption;
 
37
        typedef Encryption Decryption;
 
38
};
 
39
 
 
40
//! _
 
41
struct XSalsa20_Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_IV, 24>
 
42
{
 
43
        static const char *StaticAlgorithmName() {return "XSalsa20";}
 
44
};
 
45
 
 
46
class CRYPTOPP_NO_VTABLE XSalsa20_Policy : public Salsa20_Policy
 
47
{
 
48
public:
 
49
        void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
 
50
        void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
 
51
 
 
52
protected:
 
53
        FixedSizeSecBlock<word32, 8> m_key;
 
54
};
 
55
 
 
56
/// <a href="http://www.cryptolounge.org/wiki/XSalsa20">XSalsa20</a>, variable rounds: 8, 12 or 20 (default 20)
 
57
struct XSalsa20 : public XSalsa20_Info, public SymmetricCipherDocumentation
 
58
{
 
59
        typedef SymmetricCipherFinal<ConcretePolicyHolder<XSalsa20_Policy, AdditiveCipherTemplate<> >, XSalsa20_Info> Encryption;
 
60
        typedef Encryption Decryption;
 
61
};
 
62
 
 
63
NAMESPACE_END
 
64
 
 
65
#endif