The AsconXof implementation only supports a single shot output of the Xof and internally issues a reset() after doOutput(). That is to say that doOutput() simply functions identically to doFinal(). All other Xof implementations allow partial output via the doOutput() method. The following sample code shows how I would expect it to work.
public class AsconMulti {
/**
* The secure random.
*/
private static final SecureRandom RANDOM = new SecureRandom();
/**
* DataLength.
*/
private static final int DATALEN = 1429;
/**
* Partial length.
*/
private static final int PARTIALLEN = 317;
/**
* Main.
* @param pArgs the arguments
*/
public static void main(final String[] pArgs) {
checkXof(new AsconXof128());
checkXof(new AsconCXof128());
}
/**
* Check xof.
* @param pXof the xof
*/
private static void checkXof(final Xof pXof) {
/* Create the data */
final byte[] myData = new byte[DATALEN];
RANDOM.nextBytes(myData);
/* Update the Xof with the data */
pXof.update(myData, 0, DATALEN);
/* Extract Xof as single block */
final byte[] myFull = new byte[DATALEN];
pXof.doFinal(myFull, 0, DATALEN);
/* Update the Xof with the data */
pXof.update(myData, 0, DATALEN);
final byte[] myPart = new byte[DATALEN];
/* Create the xof as partial blocks */
for (int myPos = 0; myPos < DATALEN; myPos += PARTIALLEN) {
final int myLen = Math.min(PARTIALLEN, DATALEN - myPos);
pXof.doOutput(myPart, myPos, myLen);
}
pXof.doFinal(myPart, 0, 0);
/* Check that they are identical */
if (!Arrays.equals(myPart, myFull)) {
System.out.println("Mismatch on partial vs full xof");
}
}
}
The AsconXof implementation only supports a single shot output of the Xof and internally issues a reset() after doOutput(). That is to say that doOutput() simply functions identically to doFinal(). All other Xof implementations allow partial output via the doOutput() method. The following sample code shows how I would expect it to work.