Mercurial > projects > dcrypt
diff dcrypt/crypto/ciphers/AES.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 | 8c7f8fecdd75 |
children | 4589f8c5eb3c |
line wrap: on
line diff
--- a/dcrypt/crypto/ciphers/AES.d Fri Sep 12 05:20:43 2008 -0400 +++ b/dcrypt/crypto/ciphers/AES.d Tue Nov 18 18:03:40 2008 -0500 @@ -640,9 +640,7 @@ s0, s1, s2, s3; // State uint[] w; // Expanded key ubyte[] workingKey; - - bool initialized, - encrypt; + } // end private char[] name() { @@ -650,7 +648,7 @@ } uint rounds() { - if (!initialized) + if (!_initialized) throw new NotInitializedError(name()~": Cipher not initialized."); return ROUNDS; } @@ -664,7 +662,7 @@ if (!keyParams) throw new InvalidParameterError( name()~": Invalid parameter passed to init"); - this.encrypt = encrypt; + _encrypt = encrypt; uint len = keyParams.key.length; if (len != 16 && len != 24 && len != 32) @@ -674,7 +672,7 @@ setup(workingKey); - initialized = true; + _initialized = true; } private void encryptBlock() { @@ -801,7 +799,7 @@ } uint update(void[] input_, void[] output_) { - if (!initialized) + if (!_initialized) throw new NotInitializedError(name()~": Cipher not initialized."); ubyte[] input = cast(ubyte[]) input_, @@ -818,7 +816,7 @@ s2 = w[2] ^ Util.ubytesToUintBig(input, 8); s3 = w[3] ^ Util.ubytesToUintBig(input, 12); - if (encrypt) encryptBlock(); else decryptBlock(); + if (_encrypt) encryptBlock(); else decryptBlock(); Util.uintToUbytesBig(s0, output, 0); Util.uintToUbytesBig(s1, output, 4); @@ -855,7 +853,7 @@ w[i] = w[i-nk] ^ t; } - if (!encrypt) { + if (!_encrypt) { for (uint i = 0; i <= 4*ROUNDS; i+=4) w[i..i+4].reverse; w.reverse; @@ -922,4 +920,4 @@ } } } -} \ No newline at end of file +}