MerkleDamgard

Extending MerkleDamgard to create a custom hash function requires the implementation of a number of abstract methods. These include:

public uint digestSize();
protected void reset();
protected void createDigest(ubyte[] buf);
protected uint blockSize();
protected uint addSize();
protected void padMessage(ubyte[] data);
protected void transform(ubyte[] data);

In addition there exist two further abstract methods; these methods have empty default implementations since in some cases they are not required$(CLN)

protected abstract void padLength(ubyte[] data, ulong length);
protected abstract void extend();

The method padLength() is required to implement the SHA series of Hash functions and also the Tiger algorithm. Method extend() is required only to implement the MD2 digest.

The basic sequence of internal events is as follows:

  • transform(), 0 or more times
  • padMessage()
  • padLength()
  • transform()
  • extend()
  • createDigest()
  • reset()

Constructors

this
this()

Construct a digest

Members

Functions

binaryDigest
ubyte[] binaryDigest(ubyte[] buf)

Complete the digest

blockSize
uint blockSize()

Digest block size

createDigest
void createDigest(ubyte[] buf)

Constructs the digest

extend
void extend()

Final processing of digest.

padLength
void padLength(ubyte[] data, ulong length)

Performs the length padding

padMessage
void padMessage(ubyte[] data)

Pads the digest data

reset
void reset()

Initialize the digest

transform
void transform(const(ubyte[]) data)

Performs the digest on a block of data

update
MerkleDamgard update(const(void[]) input)

Digest additional data

Properties

addSize
uint addSize [@property getter]

Length padding size

Static functions

bigEndian32
void bigEndian32(const(ubyte[]) input, uint[] output)

Converts 8 bit to 32 bit Big Endian

bigEndian64
void bigEndian64(const(ubyte[]) input, ulong[] output)

Converts 8 bit to 64 bit Big Endian

littleEndian32
void littleEndian32(const(ubyte[]) input, uint[] output)

Converts 8 bit to 32 bit Little Endian

littleEndian64
void littleEndian64(const(ubyte[]) input, ulong[] output)

Converts 8 bit to 64 bit Little Endian

rotateLeft
uint rotateLeft(uint x, uint n)

Rotate left by n

Meta