Mercurial > projects > dcrypt
comparison dcrypt/crypto/params/ParametersWithIV.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 | 71aae178f89a |
children | 8b5eaf3c2979 |
comparison
equal
deleted
inserted
replaced
13:7ea528b61802 | 14:5ce3012f1def |
---|---|
10 | 10 |
11 public import dcrypt.crypto.params.CipherParameters; | 11 public import dcrypt.crypto.params.CipherParameters; |
12 | 12 |
13 /** Wrap cipher parameters and IV. */ | 13 /** Wrap cipher parameters and IV. */ |
14 class ParametersWithIV : CipherParameters { | 14 class ParametersWithIV : CipherParameters { |
15 private ubyte[] m_iv; | 15 private ubyte[] _iv; |
16 private CipherParameters m_params; | 16 private CipherParameters _params; |
17 | 17 |
18 /** | 18 /** |
19 * Params: | 19 * Params: |
20 * params = Parameters to wrap. | 20 * params = Parameters to wrap. |
21 * iv = IV to be held. | 21 * iv = IV to be held. |
22 */ | 22 */ |
23 this (CipherParameters params=null, ubyte[] iv_=null) { | 23 this (CipherParameters params=null, ubyte[] iv=null) { |
24 if (params) | 24 _params = params; |
25 m_params = params; | 25 _iv = cast(ubyte[]) iv; |
26 ubyte[] iv = cast(ubyte[]) iv_; | |
27 if (iv) | |
28 m_iv = iv; | |
29 } | 26 } |
30 | 27 |
31 /** Returns: The IV. */ | 28 /** Returns: The IV. */ |
32 ubyte[] iv() { | 29 ubyte[] iv() { |
33 return m_iv; | 30 return _iv; |
34 } | 31 } |
35 | 32 |
36 /** | 33 /** |
37 * Set the IV held by this object. | 34 * Set the IV held by this object. |
38 * | 35 * |
39 * Params: | 36 * Params: |
40 * newIV = The new IV for this parameter object. | 37 * newIV = The new IV for this parameter object. |
41 * Returns: The new IV. | 38 * Returns: The new IV. |
42 */ | 39 */ |
43 ubyte[] iv(void[] newIV_) { | 40 ubyte[] iv(void[] newIV) {; |
44 ubyte[] newIV = cast(ubyte[]) newIV_; | 41 return _iv = cast(ubyte[]) newIV; |
45 return m_iv = newIV; | |
46 } | 42 } |
47 | 43 |
48 /** Returns: The parameters for this object. */ | 44 /** Returns: The parameters for this object. */ |
49 CipherParameters parameters() { | 45 CipherParameters parameters() { |
50 return m_params; | 46 return _params; |
51 } | 47 } |
52 | 48 |
53 /** | 49 /** |
54 * Set the parameters held by this object. | 50 * Set the parameters held by this object. |
55 * | 51 * |
56 * Params: | 52 * Params: |
57 * newParams = The new parameters to be held. | 53 * newParams = The new parameters to be held. |
58 * Returns: The new parameters. | 54 * Returns: The new parameters. |
59 */ | 55 */ |
60 CipherParameters parameters(CipherParameters newParams) { | 56 CipherParameters parameters(CipherParameters newParams) { |
61 return m_params = newParams; | 57 return _params = newParams; |
62 } | 58 } |
63 } | 59 } |