mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Added MAC function to crypto component.
This commit is contained in:
@@ -403,6 +403,20 @@ class CryptoComponentImpl implements CryptoComponent {
|
||||
return digest.digest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] mac(SecretKey macKey, byte[]... inputs) {
|
||||
Digest mac = new Blake2sDigest(macKey.getBytes());
|
||||
byte[] length = new byte[INT_32_BYTES];
|
||||
for (byte[] input : inputs) {
|
||||
ByteUtils.writeUint32(input.length, length, 0);
|
||||
mac.update(length, 0, length.length);
|
||||
mac.update(input, 0, input.length);
|
||||
}
|
||||
byte[] output = new byte[mac.getDigestSize()];
|
||||
mac.doFinal(output, 0);
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encryptWithPassword(byte[] input, String password) {
|
||||
AuthenticatedCipher cipher = new XSalsa20Poly1305AuthenticatedCipher();
|
||||
|
||||
Reference in New Issue
Block a user