0
|
1 /**
|
|
2 * This file is part of the dcrypt project.
|
|
3 *
|
|
4 * Copyright: Copyright (C) dcrypt contributors 2008. All rights reserved.
|
|
5 * License: MIT
|
|
6 * Authors: Thomas Dixon
|
|
7 */
|
|
8
|
|
9 module dcrypt.crypto.params.ParametersWithIV;
|
|
10
|
|
11 public import dcrypt.crypto.params.CipherParameters;
|
|
12
|
|
13 /** Wrap cipher parameters and IV. */
|
|
14 class ParametersWithIV : CipherParameters {
|
|
15 private ubyte[] m_iv;
|
|
16 private CipherParameters m_params;
|
|
17
|
|
18 /**
|
|
19 * Params:
|
|
20 * params = Parameters to wrap.
|
|
21 * iv = IV to be held.
|
|
22 */
|
|
23 this(CipherParameters params=null, ubyte[] iv_=null) {
|
|
24 if (params)
|
|
25 m_params = params;
|
|
26 ubyte[] iv = cast(ubyte[]) iv_;
|
|
27 if (iv)
|
|
28 m_iv = iv;
|
|
29 }
|
|
30
|
|
31 /** Returns: The IV. */
|
|
32 ubyte[] iv() {
|
|
33 return m_iv;
|
|
34 }
|
|
35
|
|
36 /**
|
|
37 * Set the IV held by this object.
|
|
38 *
|
|
39 * Params:
|
|
40 * newIV = The new IV for this parameter object.
|
|
41 * Returns: The new IV.
|
|
42 */
|
|
43 ubyte[] iv(void[] newIV_) {
|
|
44 ubyte[] newIV = cast(ubyte[]) newIV_;
|
|
45 return m_iv = newIV;
|
|
46 }
|
|
47
|
|
48 /** Returns: The parameters for this object. */
|
|
49 CipherParameters parameters() {
|
|
50 return m_params;
|
|
51 }
|
|
52
|
|
53 /**
|
|
54 * Set the parameters held by this object.
|
|
55 *
|
|
56 * Params:
|
|
57 * newParams = The new parameters to be held.
|
|
58 * Returns: The new parameters.
|
|
59 */
|
|
60 CipherParameters parameters(CipherParameters newParams) {
|
|
61 return m_params = newParams;
|
|
62 }
|
|
63 }
|