All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.pqc.crypto.sphincsplus.HarakaS256Digest Maven / Gradle / Ivy

Go to download

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.8 and up.

There is a newer version: 1.78.1
Show newest version
package org.bouncycastle.pqc.crypto.sphincsplus;

import org.bouncycastle.crypto.Digest;

/**
 * Haraka-512 v2, https://eprint.iacr.org/2016/098.pdf
 * 

* Haraka512-256 with reference to Python Reference Impl from: https://github.com/sphincs/sphincsplus *

*/ class HarakaS256Digest extends HarakaSBase implements Digest { public HarakaS256Digest(HarakaSXof base) { haraka256_rc = base.haraka256_rc; } public String getAlgorithmName() { return "HarakaS-256"; } @Override public int getDigestSize() { return 32; } public void update(byte in) { if (off + 1 > 32) { throw new IllegalArgumentException("total input cannot be more than 32 bytes"); } buffer[off++] = in; } public void update(byte[] in, int inOff, int len) { if (off + len > 32) { throw new IllegalArgumentException("total input cannot be more than 32 bytes"); } System.arraycopy(in, inOff, buffer, off, len); off += len; } public int doFinal(byte[] output, int outOff) { byte[] s = new byte[64]; haraka256Perm(s); System.arraycopy(s, 0, output, outOff, output.length - outOff); reset(); return output.length; } public void reset() { super.reset(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy