Mercurial > projects > dcrypt
comparison dcrypt/crypto/params/SymmetricKey.d @ 14:5ce3012f1def
Removed some redundancy in code. Added NotSupportedError, a base PRNG class and a class which creates a PRNG from a hash function. Changed the MAC class' finalization methods to digest and hexDigest instead of finish and hexFinish respectively. Also added a base Checksum class, crc32 and adler32 in dcrypt.misc as per request.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Tue, 18 Nov 2008 18:03:40 -0500 |
parents | 0e08791a1418 |
children | 8b5eaf3c2979 |
comparison
equal
deleted
inserted
replaced
13:7ea528b61802 | 14:5ce3012f1def |
---|---|
7 */ | 7 */ |
8 | 8 |
9 module dcrypt.crypto.params.SymmetricKey; | 9 module dcrypt.crypto.params.SymmetricKey; |
10 | 10 |
11 import dcrypt.crypto.params.CipherParameters; | 11 import dcrypt.crypto.params.CipherParameters; |
12 import dcrypt.crypto.errors.InvalidParameterError; | |
12 | 13 |
13 /** Object representing and wrapping a symmetric key in bytes. */ | 14 /** Object representing and wrapping a symmetric key in bytes. */ |
14 class SymmetricKey : CipherParameters { | 15 class SymmetricKey : CipherParameters { |
15 private ubyte[] m_key; | 16 private ubyte[] _key; |
16 | 17 |
17 /** | 18 /** |
18 * Params: | 19 * Params: |
19 * key = Key to be held. | 20 * key = Key to be held. |
20 */ | 21 */ |
21 this(void[] key_=null) { | 22 this(void[] key=null) { |
22 ubyte[] key = cast(ubyte[]) key_; | 23 _key = cast(ubyte[]) key; |
23 if (key) | |
24 m_key = key; | |
25 } | 24 } |
26 | 25 |
27 /** Returns: Key in ubytes held by this object. */ | 26 /** Returns: Key in ubytes held by this object. */ |
28 ubyte[] key() { | 27 ubyte[] key() { |
29 return m_key; | 28 return _key; |
30 } | 29 } |
31 | 30 |
32 /** | 31 /** |
33 * Set the key held by this object. | 32 * Set the key held by this object. |
34 * | 33 * |
35 * Params: | 34 * Params: |
36 * newKey = New key to be held. | 35 * newKey = New key to be held. |
37 * Returns: The new key. | 36 * Returns: The new key. |
38 */ | 37 */ |
39 ubyte[] key(void[] newKey_) { | 38 ubyte[] key(void[] newKey) { |
40 ubyte[] newKey = cast(ubyte[])newKey_; | 39 return _key = cast(ubyte[]) newKey; |
41 return m_key = newKey; | |
42 } | 40 } |
43 } | 41 } |