Mercurial > projects > dcrypt
annotate dcrypt/crypto/params/SymmetricKey.d @ 33:b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Thu, 14 May 2009 01:33:11 -0400 |
parents | 8b5eaf3c2979 |
children |
rev | line source |
---|---|
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; | |
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.
Thomas Dixon <reikon@reikon.us>
parents:
0
diff
changeset
|
12 import dcrypt.crypto.errors.InvalidParameterError; |
0 | 13 |
14 /** Object representing and wrapping a symmetric key in bytes. */ | |
27
8b5eaf3c2979
Fixed error in hash message padding reported by Glenn Haecker.
Thomas Dixon <reikon@reikon.us>
parents:
14
diff
changeset
|
15 class SymmetricKey : CipherParameters |
8b5eaf3c2979
Fixed error in hash message padding reported by Glenn Haecker.
Thomas Dixon <reikon@reikon.us>
parents:
14
diff
changeset
|
16 { |
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.
Thomas Dixon <reikon@reikon.us>
parents:
0
diff
changeset
|
17 private ubyte[] _key; |
0 | 18 |
19 /** | |
20 * Params: | |
21 * key = Key to be held. | |
22 */ | |
27
8b5eaf3c2979
Fixed error in hash message padding reported by Glenn Haecker.
Thomas Dixon <reikon@reikon.us>
parents:
14
diff
changeset
|
23 this(void[] key=null) |
8b5eaf3c2979
Fixed error in hash message padding reported by Glenn Haecker.
Thomas Dixon <reikon@reikon.us>
parents:
14
diff
changeset
|
24 { |
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.
Thomas Dixon <reikon@reikon.us>
parents:
0
diff
changeset
|
25 _key = cast(ubyte[]) key; |
0 | 26 } |
27 | |
33
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
28 /** Play nice with D2's idea of const. */ |
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
29 version (D_Version2) |
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
30 { |
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
31 this (string key) |
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
32 { |
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
33 this(cast(ubyte[])key); |
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
34 } |
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
35 } |
b9f8aa42a547
More changes suggested by Glenn Haecker for D2 compatibility.
Thomas Dixon <reikon@reikon.us>
parents:
27
diff
changeset
|
36 |
0 | 37 /** Returns: Key in ubytes held by this object. */ |
27
8b5eaf3c2979
Fixed error in hash message padding reported by Glenn Haecker.
Thomas Dixon <reikon@reikon.us>
parents:
14
diff
changeset
|
38 ubyte[] key() |
8b5eaf3c2979
Fixed error in hash message padding reported by Glenn Haecker.
Thomas Dixon <reikon@reikon.us>
parents:
14
diff
changeset
|
39 { |
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.
Thomas Dixon <reikon@reikon.us>
parents:
0
diff
changeset
|
40 return _key; |
0 | 41 } |
42 | |
43 /** | |
44 * Set the key held by this object. | |
45 * | |
46 * Params: | |
47 * newKey = New key to be held. | |
48 * Returns: The new key. | |
49 */ | |
27
8b5eaf3c2979
Fixed error in hash message padding reported by Glenn Haecker.
Thomas Dixon <reikon@reikon.us>
parents:
14
diff
changeset
|
50 ubyte[] key(void[] newKey) |
8b5eaf3c2979
Fixed error in hash message padding reported by Glenn Haecker.
Thomas Dixon <reikon@reikon.us>
parents:
14
diff
changeset
|
51 { |
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.
Thomas Dixon <reikon@reikon.us>
parents:
0
diff
changeset
|
52 return _key = cast(ubyte[]) newKey; |
0 | 53 } |
54 } |