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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
1 /**
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
2 * This file is part of the dcrypt project.
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
3 *
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
4 * Copyright: Copyright (C) dcrypt contributors 2008. All rights reserved.
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
5 * License: MIT
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
6 * Authors: Thomas Dixon
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
7 */
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
8
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
9 module dcrypt.crypto.params.SymmetricKey;
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
10
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
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
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
13
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
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
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
18
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
19 /**
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
20 * Params:
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
21 * key = Key to be held.
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
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
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
26 }
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
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
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
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
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
41 }
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
42
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
43 /**
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
44 * Set the key held by this object.
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
45 *
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
46 * Params:
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
47 * newKey = New key to be held.
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
48 * Returns: The new key.
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
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
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
53 }
0e08791a1418 Initial import.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
54 }