BSD style: see doc/license.txt for details
Initial release: Feb 2006
Regan Heath, Oskar Linde
This module implements the SHA-256 Algorithm described by Secure
Hash Standard, FIPS PUB 180-2
- class Sha256 : MerkleDamgard [final] ¶
-
- this() ¶
-
- void reset() [protected, override] ¶
-
Returns the cipher state to it's initial value
- void createDigest(ubyte[] buf) [protected, override] ¶
-
Returns a digest of the current cipher state, this may be the
final digest, or a digest of the state between calls to update()
- uint digestSize() [override] ¶
-
The digest size of Sha-256 is 32 bytes
- uint blockSize() [protected, override] ¶
-
the block size
Specifies the size (in bytes) of the block of data to pass to
each call to transform(). For SHA256 the blockSize is 64.
- uint addSize() [protected, override] ¶
-
the length padding size
Specifies the size (in bytes) of the padding which uses the
length of the data which has been ciphered, this padding is
carried out by the padLength method. For SHA256 the addSize is 8.
- void padMessage(ubyte[] data) [protected, override] ¶
-
data | a slice of the cipher buffer to fill with padding |
Fills the passed buffer slice with the appropriate padding for
the final call to transform(). This padding will fill the cipher
buffer up to blockSize()-addSize().
- void padLength(ubyte[] data, ulong length) [protected, override] ¶
-
Performs the length padding
data | the slice of the cipher buffer to fill with padding |
length | the length of the data which has been ciphered |
Fills the passed buffer slice with addSize() bytes of padding
based on the length in bytes of the input data which has been
ciphered.
- void transform(const(ubyte[]) input) [protected, override] ¶
-
Performs the cipher on a block of data
data | the block of data to cipher |
The actual cipher algorithm is carried out by this method on
the passed block of data. This method is called for every
blockSize() bytes of input data and once more with the remaining
data padded to blockSize().