< prev index next > test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/ChaCha20Poly1305ParamTest.java
Print this page
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
/**
* @test
* @bug 8153029
* @library /test/lib
- * @build jdk.test.lib.Convert
* @run main ChaCha20Poly1305ParamTest
* @summary ChaCha20 Cipher Implementation (parameters)
*/
import java.util.*;
import javax.crypto.AEADBadTagException;
import java.security.spec.AlgorithmParameterSpec;
import java.security.AlgorithmParameters;
import java.security.NoSuchAlgorithmException;
import java.nio.ByteBuffer;
- import jdk.test.lib.Convert;
public class ChaCha20Poly1305ParamTest {
public static class TestData {
public TestData(String name, String keyStr, String nonceStr, int ctr,
int dir, String inputStr, String aadStr, String outStr) {
testName = Objects.requireNonNull(name);
- key = Convert.hexStringToByteArray(Objects.requireNonNull(keyStr));
- nonce = Convert.hexStringToByteArray(
- Objects.requireNonNull(nonceStr));
+ Hex.Decoder decoder = Hex.decoder();
+ key = decoder.decode(keyStr);
+ nonce = decoder.decode(nonceStr);
if ((counter = ctr) < 0) {
throw new IllegalArgumentException(
"counter must be 0 or greater");
}
direction = dir;
if ((direction != Cipher.ENCRYPT_MODE) &&
(direction != Cipher.DECRYPT_MODE)) {
throw new IllegalArgumentException(
"Direction must be ENCRYPT_MODE or DECRYPT_MODE");
}
- input = Convert.hexStringToByteArray(
- Objects.requireNonNull(inputStr));
- aad = (aadStr != null) ?
- Convert.hexStringToByteArray(aadStr) : null;
- expOutput = Convert.hexStringToByteArray(
- Objects.requireNonNull(outStr));
+ input = decoder.decode(inputStr);
+ aad = (aadStr != null) ? decoder.decode(aadStr) : null;
+ expOutput = decoder.decode(outStr);
}
public final String testName;
public final byte[] key;
public final byte[] nonce;
< prev index next >