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.SymmetricKey;
|
|
10
|
|
11 import dcrypt.crypto.params.CipherParameters;
|
|
12
|
|
13 /** Object representing and wrapping a symmetric key in bytes. */
|
|
14 class SymmetricKey : CipherParameters {
|
|
15 private ubyte[] m_key;
|
|
16
|
|
17 /**
|
|
18 * Params:
|
|
19 * key = Key to be held.
|
|
20 */
|
|
21 this(void[] key_=null) {
|
|
22 ubyte[] key = cast(ubyte[]) key_;
|
|
23 if (key)
|
|
24 m_key = key;
|
|
25 }
|
|
26
|
|
27 /** Returns: Key in ubytes held by this object. */
|
|
28 ubyte[] key() {
|
|
29 return m_key;
|
|
30 }
|
|
31
|
|
32 /**
|
|
33 * Set the key held by this object.
|
|
34 *
|
|
35 * Params:
|
|
36 * newKey = New key to be held.
|
|
37 * Returns: The new key.
|
|
38 */
|
|
39 ubyte[] key(void[] newKey_) {
|
|
40 ubyte[] newKey = cast(ubyte[])newKey_;
|
|
41 return m_key = newKey;
|
|
42 }
|
|
43 }
|