Mercurial > projects > dcrypt
diff dcrypt/crypto/modes/CTR.d @ 23:4589f8c5eb3c
Replaced dcrypt.crypto.Util with dcrypt.misc.Bitwise and dcrypt.misc.ByteConverter. Altered all dependent files to reflect changes.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Sat, 14 Feb 2009 19:58:20 -0500 |
parents | 8c7f8fecdd75 |
children | 8b5eaf3c2979 |
line wrap: on
line diff
--- a/dcrypt/crypto/modes/CTR.d Sat Jan 10 13:17:58 2009 -0500 +++ b/dcrypt/crypto/modes/CTR.d Sat Feb 14 19:58:20 2009 -0500 @@ -15,7 +15,7 @@ /** This class implements the counter (CTR/SIC/ICM) block mode, treating the counter as a big endian integer. */ class CTR : BlockCipher { - private BlockCipher m_cipher; + private BlockCipher wrappedCipher; private ubyte[] iv, counter, counterOutput; @@ -26,21 +26,21 @@ * cipher = Block cipher to wrap. */ this (BlockCipher cipher) { - m_cipher = cipher; + wrappedCipher = cipher; } /** Returns: The underlying cipher we are wrapping. */ BlockCipher cipher() { - return m_cipher; + return wrappedCipher; } char[] name() { - return m_cipher.name~"/CTR"; + return wrappedCipher.name~"/CTR"; } /** * Throws: dcrypt.crypto.errors.InvalidParameterError if params aren't - * an instance of dcrypt.crypto.params.ParametersWithIV. + * an instance of dcrypt.crypto.params.ParametersWithIV. */ void init(bool encrypt, CipherParameters params) { ParametersWithIV ivParams = cast(ParametersWithIV)params; @@ -52,7 +52,7 @@ throw new InvalidParameterError( name()~": IV must be same length as cipher block size"); - m_cipher.init(true, ivParams.parameters); + wrappedCipher.init(true, ivParams.parameters); iv = ivParams.iv[0..blockSize]; counter = new ubyte[blockSize]; @@ -76,7 +76,7 @@ throw new ShortBufferError(name()~": Output buffer too short"); // Encrypt the counter - m_cipher.update(counter, counterOutput); + wrappedCipher.update(counter, counterOutput); // XOR output with plaintext to create ciphertext for (int i = 0; i < len; i++) @@ -92,11 +92,11 @@ } uint blockSize() { - return m_cipher.blockSize; + return wrappedCipher.blockSize; } void reset() { counter[] = iv; - m_cipher.reset(); + wrappedCipher.reset(); } }