diff a/test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/ChaCha20NoReuse.java b/test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/ChaCha20NoReuse.java --- a/test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/ChaCha20NoReuse.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/ChaCha20NoReuse.java @@ -1,7 +1,7 @@ /* - * 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. @@ -23,11 +23,10 @@ /** * @test * @bug 8153029 * @library /test/lib - * @build jdk.test.lib.Convert * @run main ChaCha20NoReuse * @summary ChaCha20 Cipher Implementation (key/nonce reuse protection) */ import java.util.*; @@ -37,11 +36,10 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import javax.crypto.AEADBadTagException; import javax.crypto.SecretKey; import java.security.InvalidKeyException; -import jdk.test.lib.Convert; public class ChaCha20NoReuse { private static final String ALG_CC20 = "ChaCha20"; private static final String ALG_CC20_P1305 = "ChaCha20-Poly1305"; @@ -74,29 +72,26 @@ 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;