GordianKnot Digests
Overview
Digests are supported via the GordianDigestFactory interface.
GordianKnot supports most Digests available from BouncyCastle plus some additional algorithms.
JCA provides a subset of available algorithms as indicated
Digests
A digest is created by specifying a GordianDigestSpec which comprises the digestType/OutputLength plus StateLength if applicable. The digest can be used in much the same way as a JCA Digest, allowing reset, update and finalise methods.
Sample
/* Access factory */
final GordianFactory myBaseFactory = GordianGenerator.createFactory();
final GordianDigestFactory myDigestFactory = myBaseFactory.getDigestFactory();
/* Create digest */
final GordianDigestSpec mySpec = GordianDigestSpecBuilder.sha2(GordianLength.LEN_256);
final GordianDigest myDigest = myDigestFactory.createDigest(mySpec);
/* Calculate digest */
final byte[] myMessage = ...
myDigest.update(myMessage);
final byte[] myResult = myDigest.finish();
Extensible Output functions
Some digests can operate as extensible output functions, although the functionality is not available in JCA.
The **GordianDigestSpec** for the digest will indicate whether the digest supports Xof or not via the **isXof()** call. If the digest supports Xof then the digest will present the **GordianXof** interface
Sample
/* Access factory */ final GordianFactory myBaseFactory = GordianGenerator.createFactory(); final GordianDigestFactory myDigestFactory = myBaseFactory.getDigestFactory(); /* Create digest */ final GordianDigestSpec mySpec = GordianDigestSpecBuilder.blake2X(GordianLength.LEN_256); final GordianXof myXof = (GordianXof) myDigestFactory.createDigest(mySpec); /* Calculate digest */ final byte[] myMessage = ... myDigest.update(myMessage); final byte[] myOutput = new byte[200]; myDigest.output(myOutput, 0, 100); myDigest.output(myOutput, 100, 100);Algorithms
The following algorithms are supported.
| Algorithm | StateLength/Variants | OutputLengths | JCA | Xof | Notes |
|---|---|---|---|---|---|
| SHA2 | 512 | 224,256,384,512 | Y | ||
| 256 | 224,256 | Y | |||
| Tiger | 192 | Y | |||
| WHIRLPOOL | 512 | Y | |||
| Streebog | 512 | 512 | Y | GOST3411-2012 | |
| 256 | 256 | Y | |||
| GOST | 256 | Y | GOST3411-94 | ||
| RipeMD | 128 | 128,160 | Y | ||
| 256 | 256,320 | Y | |||
| SHA3 | 224,256,384,512 | Y | |||
| Skein | 256 | 128,160,224,256 | Y | ||
| 512 | 128,160,224,256,384,512 | Y | |||
| 1024 | 384,512,1024 | Y | |||
| SM3 | 256 | Y | |||
| Blake2s | 256 | 128,160,224,256 | Y | Y | |
| Blake2b | 512 | 160,256,384,512 | Y | Y | |
| Blake3 | 512 | 256,512 | Y | Y | |
| SHA1 | 160 | Y | |||
| MD2 | 128 | Y | |||
| MD4 | 128 | Y | |||
| MD5 | 128 | Y | |||
| SHAKE | 128 | 128,160,224,256 | Y | ||
| 256 | 256,384,512 | Y | |||
| Kupyna | 256,384,512 | Y | DSTU7564 | ||
| JH | 224,256,384,512 | ||||
| Groestl | 224,256,384,512 | ||||
| CubeHash | 224,256,384,512 | ||||
| Kangaroo | 128 | 128,160,224,256 | Kangaroo12 | ||
| 256 | 256,384,512 | Marsupilami14 | |||
| Haraka | 256, 512 | 256 | Y | Note that input must be same length as stateLength | |
| Ascon | 256 | Y | |||
| ISAP | 256 | ||||
| PhotonBeetle | 256 | ||||
| Sparkle | 256, 384 | ||||
| Xoodyak | 256 |
