annotate dcrypt/crypto/MAC.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 3de3a2de13a0
children 0de48552be35
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
1 /**
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
2 * This file is part of the dcrypt project.
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
3 *
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
4 * Copyright: Copyright (C) dcrypt contributors 2008. All rights reserved.
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
5 * License: MIT
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
6 * Authors: Thomas Dixon
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
7 */
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
8
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
9 module dcrypt.crypto.MAC;
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
10
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
11 public import dcrypt.crypto.params.CipherParameters;
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
12 public import dcrypt.crypto.errors.InvalidParameterError;
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
13 import dcrypt.misc.Util;
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
14
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
15 /** Base MAC class */
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
16 abstract class MAC {
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
17 /**
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
18 * Initialize a MAC.
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
19 *
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
20 * Params:
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
21 * params = Parameters to be passed to the MAC. (Key, etc.)
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
22 */
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
23 void init(CipherParameters params);
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
24
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
25 /**
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
26 * Introduce data into the MAC.
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
27 *
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
28 * Params:
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
29 * input_ = Data to be processed.
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
30 */
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
31 void update(void[] input_);
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
32
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
33 /** Returns: The name of this MAC. */
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
34 char[] name();
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
35
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
36 /** Reset MAC to its state immediately subsequent the last init. */
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
37 void reset();
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
38
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
39 /** Returns: The block size in bytes that this MAC will operate on. */
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
40 uint blockSize();
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
41
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
42 /** Returns: The output size of the MAC in bytes. */
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
43 uint macSize();
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
44
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
45 /** Returns: The computed MAC. */
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: 4
diff changeset
46 ubyte[] digest();
4
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
47
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
48 /** Returns: The computed MAC in hexadecimal. */
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: 4
diff changeset
49 char[] hexDigest() {
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: 4
diff changeset
50 return Util.ubytesToHex(digest());
4
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
51 }
3de3a2de13a0 Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
Thomas Dixon <reikon@reikon.us>
parents:
diff changeset
52 }