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

net.sourceforge.plantuml.argon2.algorithm.Finalize Maven / Gradle / Ivy

There is a newer version: 1.2025.0
Show newest version
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.argon2.algorithm;

import net.sourceforge.plantuml.argon2.Argon2;
import net.sourceforge.plantuml.argon2.model.Block;
import net.sourceforge.plantuml.argon2.model.Instance;

public class Finalize {

	public static void finalize(Instance instance, Argon2 argon2) {

		Block finalBlock = instance.memory[instance.getLaneLength() - 1];

		/* XOR the last blocks */
		for (int i = 1; i < instance.getLanes(); i++) {
			int lastBlockInLane = i * instance.getLaneLength() + (instance.getLaneLength() - 1);
			finalBlock.xorWith(instance.memory[lastBlockInLane]);
		}

		byte[] finalBlockBytes = finalBlock.toBytes();
		byte[] finalResult = Functions.blake2bLong(finalBlockBytes, argon2.getOutputLength());

		argon2.setOutput(finalResult);

		if (argon2.isClearMemory()) {
			instance.clear();
			argon2.clear();
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy