8341927: Replace hardcoded security providers with new test.provider.name system property
Reviewed-by: mullan, ascarpino, rhalade
This commit is contained in:
parent
1b177ce5b7
commit
9a9ac1d005
@ -72,6 +72,9 @@ id="toc-notes-for-specific-tests">Notes for Specific Tests</a>
|
|||||||
<li><a href="#non-us-locale" id="toc-non-us-locale">Non-US
|
<li><a href="#non-us-locale" id="toc-non-us-locale">Non-US
|
||||||
locale</a></li>
|
locale</a></li>
|
||||||
<li><a href="#pkcs11-tests" id="toc-pkcs11-tests">PKCS11 Tests</a></li>
|
<li><a href="#pkcs11-tests" id="toc-pkcs11-tests">PKCS11 Tests</a></li>
|
||||||
|
<li><a href="#testing-with-alternative-security-providers"
|
||||||
|
id="toc-testing-with-alternative-security-providers">Testing with
|
||||||
|
alternative security providers</a></li>
|
||||||
<li><a href="#client-ui-tests" id="toc-client-ui-tests">Client UI
|
<li><a href="#client-ui-tests" id="toc-client-ui-tests">Client UI
|
||||||
Tests</a></li>
|
Tests</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
@ -586,6 +589,18 @@ element of the appropriate <code>@Artifact</code> class. (See
|
|||||||
JTREG="JAVA_OPTIONS=-Djdk.test.lib.artifacts.nsslib-linux_aarch64=/path/to/NSS-libs"</code></pre>
|
JTREG="JAVA_OPTIONS=-Djdk.test.lib.artifacts.nsslib-linux_aarch64=/path/to/NSS-libs"</code></pre>
|
||||||
<p>For more notes about the PKCS11 tests, please refer to
|
<p>For more notes about the PKCS11 tests, please refer to
|
||||||
test/jdk/sun/security/pkcs11/README.</p>
|
test/jdk/sun/security/pkcs11/README.</p>
|
||||||
|
<h3 id="testing-with-alternative-security-providers">Testing with
|
||||||
|
alternative security providers</h3>
|
||||||
|
<p>Some security tests use a hardcoded provider for
|
||||||
|
<code>KeyFactory</code>, <code>Cipher</code>,
|
||||||
|
<code>KeyPairGenerator</code>, <code>KeyGenerator</code>,
|
||||||
|
<code>AlgorithmParameterGenerator</code>, <code>KeyAgreement</code>,
|
||||||
|
<code>Mac</code>, <code>MessageDigest</code>, <code>SecureRandom</code>,
|
||||||
|
<code>Signature</code>, <code>AlgorithmParameters</code>,
|
||||||
|
<code>Configuration</code>, <code>Policy</code>, or
|
||||||
|
<code>SecretKeyFactory</code> objects. Specify the
|
||||||
|
<code>-Dtest.provider.name=NAME</code> property to use a different
|
||||||
|
provider for the service(s).</p>
|
||||||
<h3 id="client-ui-tests">Client UI Tests</h3>
|
<h3 id="client-ui-tests">Client UI Tests</h3>
|
||||||
<h4 id="system-key-shortcuts">System key shortcuts</h4>
|
<h4 id="system-key-shortcuts">System key shortcuts</h4>
|
||||||
<p>Some Client UI tests use key sequences which may be reserved by the
|
<p>Some Client UI tests use key sequences which may be reserved by the
|
||||||
|
@ -603,6 +603,15 @@ $ make test TEST="jtreg:sun/security/pkcs11/Secmod/AddTrustedCert.java" \
|
|||||||
For more notes about the PKCS11 tests, please refer to
|
For more notes about the PKCS11 tests, please refer to
|
||||||
test/jdk/sun/security/pkcs11/README.
|
test/jdk/sun/security/pkcs11/README.
|
||||||
|
|
||||||
|
### Testing with alternative security providers
|
||||||
|
|
||||||
|
Some security tests use a hardcoded provider for `KeyFactory`, `Cipher`,
|
||||||
|
`KeyPairGenerator`, `KeyGenerator`, `AlgorithmParameterGenerator`,
|
||||||
|
`KeyAgreement`, `Mac`, `MessageDigest`, `SecureRandom`, `Signature`,
|
||||||
|
`AlgorithmParameters`, `Configuration`, `Policy`, or `SecretKeyFactory` objects.
|
||||||
|
Specify the `-Dtest.provider.name=NAME` property to use a different provider for
|
||||||
|
the service(s).
|
||||||
|
|
||||||
### Client UI Tests
|
### Client UI Tests
|
||||||
|
|
||||||
#### System key shortcuts
|
#### System key shortcuts
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -66,7 +66,8 @@ public class CICODESFuncTest {
|
|||||||
private static final int IV_LENGTH = 8;
|
private static final int IV_LENGTH = 8;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
Provider provider = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
throw new RuntimeException("SunJCE provider does not exist.");
|
throw new RuntimeException("SunJCE provider does not exist.");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -204,9 +204,10 @@ class CipherGenerator {
|
|||||||
AlgorithmParameterSpec aps) throws NoSuchAlgorithmException,
|
AlgorithmParameterSpec aps) throws NoSuchAlgorithmException,
|
||||||
NoSuchPaddingException, InvalidKeyException,
|
NoSuchPaddingException, InvalidKeyException,
|
||||||
InvalidAlgorithmParameterException {
|
InvalidAlgorithmParameterException {
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
String providerName = System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
Provider provider = Security.getProvider(providerName);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
throw new RuntimeException("SunJCE provider does not exist.");
|
throw new RuntimeException(providerName + " provider does not exist.");
|
||||||
}
|
}
|
||||||
Cipher ci1 = Cipher.getInstance(algo, provider);
|
Cipher ci1 = Cipher.getInstance(algo, provider);
|
||||||
ci1.init(Cipher.ENCRYPT_MODE, key, aps);
|
ci1.init(Cipher.ENCRYPT_MODE, key, aps);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -69,9 +69,10 @@ public class AESPBEWrapper extends AbstractPBEWrapper {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Cipher initCipher(int mode) throws GeneralSecurityException {
|
protected Cipher initCipher(int mode) throws GeneralSecurityException {
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
String providerName = System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
Provider provider = Security.getProvider(providerName);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
throw new RuntimeException("SunJCE provider does not exist.");
|
throw new RuntimeException(providerName + ": provider does not exist.");
|
||||||
}
|
}
|
||||||
// get Cipher instance
|
// get Cipher instance
|
||||||
Cipher ci = Cipher.getInstance(transformation, provider);
|
Cipher ci = Cipher.getInstance(transformation, provider);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -58,9 +58,10 @@ public class DefaultPBEWrapper extends AbstractPBEWrapper {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Cipher initCipher(int mode) throws GeneralSecurityException {
|
protected Cipher initCipher(int mode) throws GeneralSecurityException {
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
String providerName = System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
Provider provider = Security.getProvider(providerName);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
throw new RuntimeException("SunJCE provider does not exist.");
|
throw new RuntimeException(providerName + ": provider does not exist.");
|
||||||
}
|
}
|
||||||
SecretKey key = SecretKeyFactory.getInstance(baseAlgo)
|
SecretKey key = SecretKeyFactory.getInstance(baseAlgo)
|
||||||
.generateSecret(new PBEKeySpec(password.toCharArray()));
|
.generateSecret(new PBEKeySpec(password.toCharArray()));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -89,9 +89,10 @@ public class PBKDF2Wrapper extends AbstractPBEWrapper {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Cipher initCipher(int mode) throws GeneralSecurityException {
|
protected Cipher initCipher(int mode) throws GeneralSecurityException {
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
String providerName = System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
Provider provider = Security.getProvider(providerName);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
throw new RuntimeException("SunJCE provider does not exist.");
|
throw new RuntimeException(providerName + ": provider does not exist.");
|
||||||
}
|
}
|
||||||
// Generate secret key
|
// Generate secret key
|
||||||
PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray(),
|
PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -122,7 +122,8 @@ public class Encrypt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Provider p = Security.getProvider("SunJCE");
|
Provider p = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
for (String alg : ALGORITHMS) {
|
for (String alg : ALGORITHMS) {
|
||||||
for (int keyStrength : KEY_STRENGTHS) {
|
for (int keyStrength : KEY_STRENGTHS) {
|
||||||
if (keyStrength > Cipher.getMaxAllowedKeyLength(alg)) {
|
if (keyStrength > Cipher.getMaxAllowedKeyLength(alg)) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -102,7 +102,8 @@ public class GCMLargeDataKAT {
|
|||||||
|
|
||||||
byte[] encrypt(int inLen) {
|
byte[] encrypt(int inLen) {
|
||||||
try {
|
try {
|
||||||
cipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
cipher = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, key, spec);
|
cipher.init(Cipher.ENCRYPT_MODE, key, spec);
|
||||||
return cipher.doFinal(plaintext, 0, inLen);
|
return cipher.doFinal(plaintext, 0, inLen);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -125,7 +126,8 @@ public class GCMLargeDataKAT {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
cipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
cipher = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
cipher.init(Cipher.DECRYPT_MODE, key, spec);
|
cipher.init(Cipher.DECRYPT_MODE, key, spec);
|
||||||
result = cipher.doFinal(data);
|
result = cipher.doFinal(data);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -87,7 +87,8 @@ public class GCMParameterSpecTest {
|
|||||||
AAD = Helper.generateBytes(AADLength);
|
AAD = Helper.generateBytes(AADLength);
|
||||||
|
|
||||||
// init a secret key
|
// init a secret key
|
||||||
KeyGenerator kg = KeyGenerator.getInstance("AES", "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance("AES",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(keyLength);
|
kg.init(keyLength);
|
||||||
key = kg.generateKey();
|
key = kg.generateKey();
|
||||||
}
|
}
|
||||||
@ -211,7 +212,8 @@ public class GCMParameterSpecTest {
|
|||||||
|
|
||||||
private Cipher createCipher(int mode, GCMParameterSpec spec)
|
private Cipher createCipher(int mode, GCMParameterSpec spec)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Cipher cipher = Cipher.getInstance(TRANSFORMATION, "SunJCE");
|
Cipher cipher = Cipher.getInstance(TRANSFORMATION,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
cipher.init(mode, key, spec);
|
cipher.init(mode, key, spec);
|
||||||
return cipher;
|
return cipher;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -37,7 +37,7 @@ public class KeyWrapper {
|
|||||||
|
|
||||||
static final String AES = "AES";
|
static final String AES = "AES";
|
||||||
static final String TRANSFORMATION = "AES/GCM/NoPadding";
|
static final String TRANSFORMATION = "AES/GCM/NoPadding";
|
||||||
static final String PROVIDER = "SunJCE";
|
static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE");
|
||||||
static final int KEY_LENGTH = 128;
|
static final int KEY_LENGTH = 128;
|
||||||
|
|
||||||
public static void main(String argv[]) throws Exception {
|
public static void main(String argv[]) throws Exception {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -50,7 +50,7 @@ public class ReadWriteSkip {
|
|||||||
static final int BLOCK = 50;
|
static final int BLOCK = 50;
|
||||||
static final int SAVE = 45;
|
static final int SAVE = 45;
|
||||||
static final int DISCARD = BLOCK - SAVE;
|
static final int DISCARD = BLOCK - SAVE;
|
||||||
static final String PROVIDER = "SunJCE";
|
static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE");
|
||||||
static final String AES = "AES";
|
static final String AES = "AES";
|
||||||
static final String GCM = "GCM";
|
static final String GCM = "GCM";
|
||||||
static final String PADDING = "NoPadding";
|
static final String PADDING = "NoPadding";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,7 +41,7 @@ import jdk.test.lib.Convert;
|
|||||||
*/
|
*/
|
||||||
public class SameBuffer {
|
public class SameBuffer {
|
||||||
|
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final String AES = "AES";
|
private static final String AES = "AES";
|
||||||
private static final String GCM = "GCM";
|
private static final String GCM = "GCM";
|
||||||
private static final String PADDING = "NoPadding";
|
private static final String PADDING = "NoPadding";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -37,7 +37,7 @@ public class SealedObjectTest {
|
|||||||
|
|
||||||
private static final String AES = "AES";
|
private static final String AES = "AES";
|
||||||
private static final String TRANSFORMATION = "AES/GCM/NoPadding";
|
private static final String TRANSFORMATION = "AES/GCM/NoPadding";
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final int KEY_LENGTH = 128;
|
private static final int KEY_LENGTH = 128;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,7 +44,7 @@ import javax.crypto.KeyGenerator;
|
|||||||
*/
|
*/
|
||||||
public class WrongAAD {
|
public class WrongAAD {
|
||||||
|
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final String TRANSFORMATION = "AES/GCM/NoPadding";
|
private static final String TRANSFORMATION = "AES/GCM/NoPadding";
|
||||||
private static final int TEXT_SIZE = 800;
|
private static final int TEXT_SIZE = 800;
|
||||||
private static final int KEY_SIZE = 128;
|
private static final int KEY_SIZE = 128;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -52,7 +52,7 @@ public class CICO {
|
|||||||
"cFB24", "cFB32", "Cfb40", "CFB72", "OfB", "OfB20", "OfB48",
|
"cFB24", "cFB32", "Cfb40", "CFB72", "OfB", "OfB20", "OfB48",
|
||||||
"OfB56", "OFB64", "OFB112", "CFB112", "pCbC" };
|
"OfB56", "OFB64", "OFB112", "CFB112", "pCbC" };
|
||||||
private static final String[] PADDING = { "noPadding", "pkcs5padding" };
|
private static final String[] PADDING = { "noPadding", "pkcs5padding" };
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final int NREADS = 3;
|
private static final int NREADS = 3;
|
||||||
private static final int KEY_LENGTH = 128;
|
private static final int KEY_LENGTH = 128;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -50,7 +50,8 @@ public class CTR {
|
|||||||
|
|
||||||
private static final String ALGORITHM = "AES";
|
private static final String ALGORITHM = "AES";
|
||||||
|
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
|
||||||
private static final String[] MODES = {"CTR","CFB24","OFB32","GCM"};
|
private static final String[] MODES = {"CTR","CFB24","OFB32","GCM"};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,7 +47,8 @@ import javax.crypto.spec.IvParameterSpec;
|
|||||||
public class Padding {
|
public class Padding {
|
||||||
|
|
||||||
private static final String ALGORITHM = "AES";
|
private static final String ALGORITHM = "AES";
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final String[] MODES_PKCS5PAD = {
|
private static final String[] MODES_PKCS5PAD = {
|
||||||
"ECb", "CbC", "PCBC", "OFB",
|
"ECb", "CbC", "PCBC", "OFB",
|
||||||
"OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32",
|
"OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,10 +41,12 @@ public class Test4511676 {
|
|||||||
|
|
||||||
public boolean execute() throws Exception {
|
public boolean execute() throws Exception {
|
||||||
|
|
||||||
Cipher ci = Cipher.getInstance(ALGO, "SunJCE");
|
Cipher ci = Cipher.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
// TEST FIX 4511676
|
// TEST FIX 4511676
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(KEYSIZE*8);
|
kg.init(KEYSIZE*8);
|
||||||
SecretKey key = kg.generateKey();
|
SecretKey key = kg.generateKey();
|
||||||
try {
|
try {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -45,10 +45,12 @@ public class Test4512524 {
|
|||||||
public void execute(String mode) throws Exception {
|
public void execute(String mode) throws Exception {
|
||||||
|
|
||||||
String transformation = ALGO+"/"+mode+"/"+PADDING;
|
String transformation = ALGO+"/"+mode+"/"+PADDING;
|
||||||
Cipher ci = Cipher.getInstance(transformation, "SunJCE");
|
Cipher ci = Cipher.getInstance(transformation,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
// TEST FIX 4512524
|
// TEST FIX 4512524
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(KEYSIZE*8);
|
kg.init(KEYSIZE*8);
|
||||||
SecretKey key = kg.generateKey();
|
SecretKey key = kg.generateKey();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -45,9 +45,11 @@ public class Test4512704 {
|
|||||||
|
|
||||||
AlgorithmParameterSpec aps = null;
|
AlgorithmParameterSpec aps = null;
|
||||||
String transformation = ALGO + "/" + mode + "/"+PADDING;
|
String transformation = ALGO + "/" + mode + "/"+PADDING;
|
||||||
Cipher ci = Cipher.getInstance(transformation, "SunJCE");
|
Cipher ci = Cipher.getInstance(transformation,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(KEYSIZE*8);
|
kg.init(KEYSIZE*8);
|
||||||
SecretKey key = kg.generateKey();
|
SecretKey key = kg.generateKey();
|
||||||
// TEST FIX 4512704
|
// TEST FIX 4512704
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -52,10 +52,12 @@ public class Test4513830 {
|
|||||||
byte[] plainText=new byte[125];
|
byte[] plainText=new byte[125];
|
||||||
rdm.nextBytes(plainText);
|
rdm.nextBytes(plainText);
|
||||||
|
|
||||||
Cipher ci = Cipher.getInstance(ALGO+"/"+MODE+"/"+PADDING, "SunJCE");
|
Cipher ci = Cipher.getInstance(ALGO+"/"+MODE+"/"+PADDING,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
// TEST FIX 4513830
|
// TEST FIX 4513830
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(KEYSIZE*8);
|
kg.init(KEYSIZE*8);
|
||||||
SecretKey key = kg.generateKey();
|
SecretKey key = kg.generateKey();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -48,8 +48,10 @@ public class Test4517355 {
|
|||||||
public void execute(String mode, String padding) throws Exception {
|
public void execute(String mode, String padding) throws Exception {
|
||||||
String transformation = ALGO + "/" + mode + "/" + padding;
|
String transformation = ALGO + "/" + mode + "/" + padding;
|
||||||
|
|
||||||
Cipher ci = Cipher.getInstance(transformation, "SunJCE");
|
Cipher ci = Cipher.getInstance(transformation,
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE");
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
KeyGenerator kg = KeyGenerator.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(KEYSIZE*8);
|
kg.init(KEYSIZE*8);
|
||||||
SecretKey key = kg.generateKey();
|
SecretKey key = kg.generateKey();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -38,8 +38,10 @@ public class Test4626070 {
|
|||||||
|
|
||||||
public void execute(String mode, String padding) throws Exception {
|
public void execute(String mode, String padding) throws Exception {
|
||||||
String transformation = ALGO + "/" + mode + "/" + padding;
|
String transformation = ALGO + "/" + mode + "/" + padding;
|
||||||
Cipher ci = Cipher.getInstance(transformation, "SunJCE");
|
Cipher ci = Cipher.getInstance(transformation,
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE");
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
KeyGenerator kg = KeyGenerator.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(KEYSIZE*8);
|
kg.init(KEYSIZE*8);
|
||||||
SecretKey key = kg.generateKey();
|
SecretKey key = kg.generateKey();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -48,7 +48,7 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
public class TestAESCipher {
|
public class TestAESCipher {
|
||||||
|
|
||||||
private static final String ALGORITHM = "AES";
|
private static final String ALGORITHM = "AES";
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final String[] MODES = { "ECb", "CbC", "CTR", "PCBC", "OFB",
|
private static final String[] MODES = { "ECb", "CbC", "CTR", "PCBC", "OFB",
|
||||||
"OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32",
|
"OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32",
|
||||||
"Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88",
|
"Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88",
|
||||||
|
@ -46,7 +46,7 @@ public class Dynamic {
|
|||||||
static final String[] PADDING = {
|
static final String[] PADDING = {
|
||||||
"NoPadding", "PKCS5Padding", "ISO10126Padding"
|
"NoPadding", "PKCS5Padding", "ISO10126Padding"
|
||||||
};
|
};
|
||||||
static final String SUNJCE = "SunJCE";
|
static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
|
||||||
Cipher ci = null;
|
Cipher ci = null;
|
||||||
byte[] iv = null;
|
byte[] iv = null;
|
||||||
@ -128,8 +128,8 @@ public class Dynamic {
|
|||||||
new Random().nextBytes(plainText);
|
new Random().nextBytes(plainText);
|
||||||
|
|
||||||
String transformation = algo + "/" + mo + "/" + pad;
|
String transformation = algo + "/" + mo + "/" + pad;
|
||||||
ci = Cipher.getInstance(transformation, SUNJCE);
|
ci = Cipher.getInstance(transformation, PROVIDER);
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(algo, SUNJCE);
|
KeyGenerator kg = KeyGenerator.getInstance(algo, PROVIDER);
|
||||||
if (keyStrength > Cipher.getMaxAllowedKeyLength(transformation)) {
|
if (keyStrength > Cipher.getMaxAllowedKeyLength(transformation)) {
|
||||||
// skip if this key length is larger than what's
|
// skip if this key length is larger than what's
|
||||||
// configured in the jce jurisdiction policy files
|
// configured in the jce jurisdiction policy files
|
||||||
|
@ -33,7 +33,7 @@ import java.security.Security;
|
|||||||
|
|
||||||
public class TestAESWithProviderChange extends Dynamic {
|
public class TestAESWithProviderChange extends Dynamic {
|
||||||
public static void main(String argv[]) throws Exception {
|
public static void main(String argv[]) throws Exception {
|
||||||
Security.removeProvider(SUNJCE);
|
Security.removeProvider(PROVIDER);
|
||||||
Security.addProvider(new com.sun.crypto.provider.SunJCE());
|
Security.addProvider(new com.sun.crypto.provider.SunJCE());
|
||||||
new TestAESWithProviderChange().run(argv);
|
new TestAESWithProviderChange().run(argv);
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ import java.security.Provider;
|
|||||||
|
|
||||||
public class TestAESWithRemoveAddProvider extends Dynamic {
|
public class TestAESWithRemoveAddProvider extends Dynamic {
|
||||||
public static void main(String argv[]) throws Exception {
|
public static void main(String argv[]) throws Exception {
|
||||||
Provider pJCE = Security.getProvider(SUNJCE);
|
Provider pJCE = Security.getProvider(PROVIDER);
|
||||||
Security.removeProvider(SUNJCE);
|
Security.removeProvider(PROVIDER);
|
||||||
Security.addProvider(pJCE);
|
Security.addProvider(pJCE);
|
||||||
new TestAESWithRemoveAddProvider().run(argv);
|
new TestAESWithRemoveAddProvider().run(argv);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
grant codeBase "file:${test.classes}/*" {
|
grant codeBase "file:${test.classes}/*" {
|
||||||
permission java.security.SecurityPermission "removeProvider.SunJCE";
|
permission java.security.SecurityPermission "removeProvider.*";
|
||||||
permission java.security.SecurityPermission "insertProvider.SunJCE";
|
permission java.security.SecurityPermission "insertProvider.*";
|
||||||
permission java.lang.RuntimePermission
|
permission java.lang.RuntimePermission
|
||||||
"accessClassInPackage.com.sun.crypto.provider";
|
"accessClassInPackage.com.sun.crypto.provider";
|
||||||
|
permission java.util.PropertyPermission "test.provider.name", "read";
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,7 +43,8 @@ import java.util.*;
|
|||||||
public class TestCICOWithGCM {
|
public class TestCICOWithGCM {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
//init Secret Key
|
//init Secret Key
|
||||||
KeyGenerator kg = KeyGenerator.getInstance("AES", "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance("AES",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(128);
|
kg.init(128);
|
||||||
SecretKey key = kg.generateKey();
|
SecretKey key = kg.generateKey();
|
||||||
|
|
||||||
@ -53,9 +54,11 @@ public class TestCICOWithGCM {
|
|||||||
rdm.nextBytes(plainText);
|
rdm.nextBytes(plainText);
|
||||||
|
|
||||||
//init ciphers
|
//init ciphers
|
||||||
Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
encCipher.init(Cipher.ENCRYPT_MODE, key);
|
encCipher.init(Cipher.ENCRYPT_MODE, key);
|
||||||
Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
decCipher.init(Cipher.DECRYPT_MODE, key, encCipher.getParameters());
|
decCipher.init(Cipher.DECRYPT_MODE, key, encCipher.getParameters());
|
||||||
|
|
||||||
//init cipher streams
|
//init cipher streams
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,7 +39,8 @@ import javax.crypto.*;
|
|||||||
public class TestCICOWithGCMAndAAD {
|
public class TestCICOWithGCMAndAAD {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
//init Secret Key
|
//init Secret Key
|
||||||
KeyGenerator kg = KeyGenerator.getInstance("AES", "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance("AES",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(128);
|
kg.init(128);
|
||||||
SecretKey key = kg.generateKey();
|
SecretKey key = kg.generateKey();
|
||||||
|
|
||||||
@ -53,10 +54,12 @@ public class TestCICOWithGCMAndAAD {
|
|||||||
byte[] aad2 = aad.clone();
|
byte[] aad2 = aad.clone();
|
||||||
aad2[50]++;
|
aad2[50]++;
|
||||||
|
|
||||||
Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
encCipher.init(Cipher.ENCRYPT_MODE, key);
|
encCipher.init(Cipher.ENCRYPT_MODE, key);
|
||||||
encCipher.updateAAD(aad);
|
encCipher.updateAAD(aad);
|
||||||
Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
decCipher.init(Cipher.DECRYPT_MODE, key, encCipher.getParameters());
|
decCipher.init(Cipher.DECRYPT_MODE, key, encCipher.getParameters());
|
||||||
decCipher.updateAAD(aad);
|
decCipher.updateAAD(aad);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -57,7 +57,8 @@ public class TestCopySafe {
|
|||||||
|
|
||||||
public static void main(String[] argv) throws Exception {
|
public static void main(String[] argv) throws Exception {
|
||||||
|
|
||||||
Provider p = Security.getProvider("SunJCE");
|
Provider p = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
AlgorithmParameterSpec params = null;
|
AlgorithmParameterSpec params = null;
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -68,7 +68,8 @@ public class TestGCMKeyAndIvCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
Cipher c = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
Cipher c = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
SecretKey key = new SecretKeySpec(new byte[16], "AES");
|
SecretKey key = new SecretKeySpec(new byte[16], "AES");
|
||||||
// First try parameter-less init.
|
// First try parameter-less init.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -45,7 +45,8 @@ public class TestISO10126Padding {
|
|||||||
|
|
||||||
private TestISO10126Padding() throws Exception {
|
private TestISO10126Padding() throws Exception {
|
||||||
// setup
|
// setup
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(KEYSIZE*8);
|
kg.init(KEYSIZE*8);
|
||||||
key = kg.generateKey();
|
key = kg.generateKey();
|
||||||
}
|
}
|
||||||
@ -59,7 +60,8 @@ public class TestISO10126Padding {
|
|||||||
// TEST#1 --
|
// TEST#1 --
|
||||||
// generate the cipher text using manually-supplied
|
// generate the cipher text using manually-supplied
|
||||||
// XML Encryption padding
|
// XML Encryption padding
|
||||||
Cipher ci = Cipher.getInstance(TRANS + "/NoPadding", "SunJCE");
|
Cipher ci = Cipher.getInstance(TRANS + "/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
ci.init(Cipher.ENCRYPT_MODE, key);
|
ci.init(Cipher.ENCRYPT_MODE, key);
|
||||||
byte[] paddedData = new byte[ci.getBlockSize()];
|
byte[] paddedData = new byte[ci.getBlockSize()];
|
||||||
System.arraycopy(data, 0, paddedData, 0, data.length);
|
System.arraycopy(data, 0, paddedData, 0, data.length);
|
||||||
@ -68,7 +70,8 @@ public class TestISO10126Padding {
|
|||||||
byte[] cipherText = ci.doFinal(paddedData);
|
byte[] cipherText = ci.doFinal(paddedData);
|
||||||
|
|
||||||
// decrypt using ISO10126Padding
|
// decrypt using ISO10126Padding
|
||||||
ci = Cipher.getInstance(TRANS + "/ISO10126Padding", "SunJCE");
|
ci = Cipher.getInstance(TRANS + "/ISO10126Padding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
ci.init(Cipher.DECRYPT_MODE, key);
|
ci.init(Cipher.DECRYPT_MODE, key);
|
||||||
byte[] recovered = ci.doFinal(cipherText);
|
byte[] recovered = ci.doFinal(cipherText);
|
||||||
if (!Arrays.equals(data, recovered)) {
|
if (!Arrays.equals(data, recovered)) {
|
||||||
@ -76,7 +79,8 @@ public class TestISO10126Padding {
|
|||||||
}
|
}
|
||||||
// TEST#2 --
|
// TEST#2 --
|
||||||
// generate the cipher text using ISO10126Padding
|
// generate the cipher text using ISO10126Padding
|
||||||
ci = Cipher.getInstance(TRANS + "/ISO10126Padding", "SunJCE");
|
ci = Cipher.getInstance(TRANS + "/ISO10126Padding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
ci.init(Cipher.ENCRYPT_MODE, key);
|
ci.init(Cipher.ENCRYPT_MODE, key);
|
||||||
cipherText = ci.doFinal(data);
|
cipherText = ci.doFinal(data);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -83,7 +83,8 @@ public class TestKATForECB_IV
|
|||||||
|
|
||||||
public boolean execute() throws Exception {
|
public boolean execute() throws Exception {
|
||||||
String transformation = ALGO+"/"+MODE+"/"+PADDING;
|
String transformation = ALGO+"/"+MODE+"/"+PADDING;
|
||||||
Cipher c = Cipher.getInstance(transformation, "SunJCE");
|
Cipher c = Cipher.getInstance(transformation,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
for (int i=0; i<KEYS.length; i++) {
|
for (int i=0; i<KEYS.length; i++) {
|
||||||
SecretKey aesKey = constructAESKey(KEYS[i]);
|
SecretKey aesKey = constructAESKey(KEYS[i]);
|
||||||
if (aesKey.getEncoded().length*8 >
|
if (aesKey.getEncoded().length*8 >
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -707,7 +707,8 @@ public class TestKATForECB_VK
|
|||||||
|
|
||||||
public boolean execute() throws Exception {
|
public boolean execute() throws Exception {
|
||||||
String transformation = ALGO+"/"+MODE+"/"+PADDING;
|
String transformation = ALGO+"/"+MODE+"/"+PADDING;
|
||||||
Cipher c = Cipher.getInstance(transformation, "SunJCE");
|
Cipher c = Cipher.getInstance(transformation,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
for (int i=0; i<KEY_SIZES.length; i++) {
|
for (int i=0; i<KEY_SIZES.length; i++) {
|
||||||
if (KEY_SIZES[i]*8 >
|
if (KEY_SIZES[i]*8 >
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -513,7 +513,8 @@ public class TestKATForECB_VT
|
|||||||
|
|
||||||
public boolean execute() throws Exception {
|
public boolean execute() throws Exception {
|
||||||
String transformation = ALGO+"/"+MODE+"/"+PADDING;
|
String transformation = ALGO+"/"+MODE+"/"+PADDING;
|
||||||
Cipher c = Cipher.getInstance(transformation, "SunJCE");
|
Cipher c = Cipher.getInstance(transformation,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
for (int i=0; i<KEY_SIZES.length; i++) {
|
for (int i=0; i<KEY_SIZES.length; i++) {
|
||||||
if (KEY_SIZES[i]*8 >
|
if (KEY_SIZES[i]*8 >
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -278,7 +278,8 @@ public class TestKATForGCM {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void executeArray(TestVector tv) throws Exception {
|
void executeArray(TestVector tv) throws Exception {
|
||||||
Cipher c = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
Cipher c = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
try {
|
try {
|
||||||
System.out.println("Test #" + tv.id + ": byte[].");
|
System.out.println("Test #" + tv.id + ": byte[].");
|
||||||
|
|
||||||
@ -320,7 +321,8 @@ public class TestKATForGCM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void executeByteBuffer(TestVector tv, boolean direct, int offset) throws Exception {
|
void executeByteBuffer(TestVector tv, boolean direct, int offset) throws Exception {
|
||||||
Cipher c = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE");
|
Cipher c = Cipher.getInstance("AES/GCM/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
ByteBuffer src;
|
ByteBuffer src;
|
||||||
ByteBuffer ctdst;
|
ByteBuffer ctdst;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -42,7 +42,8 @@ public class TestNoPaddingModes {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Provider p = Security.getProvider("SunJCE");
|
Provider p = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
String transformation;
|
String transformation;
|
||||||
for (String mode : MODES) {
|
for (String mode : MODES) {
|
||||||
for (String padding : PADDINGS) {
|
for (String padding : PADDINGS) {
|
||||||
@ -50,7 +51,8 @@ public class TestNoPaddingModes {
|
|||||||
|
|
||||||
System.out.println("Test using " + transformation);
|
System.out.println("Test using " + transformation);
|
||||||
try {
|
try {
|
||||||
Cipher c = Cipher.getInstance(transformation, "SunJCE");
|
Cipher c = Cipher.getInstance(transformation,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
throw new RuntimeException("=> Fail, no exception thrown");
|
throw new RuntimeException("=> Fail, no exception thrown");
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException ex) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException ex) {
|
||||||
System.out.println("=> Expected ex: " + ex);
|
System.out.println("=> Expected ex: " + ex);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -45,7 +45,8 @@ import javax.crypto.spec.GCMParameterSpec;
|
|||||||
public class TestNonexpanding {
|
public class TestNonexpanding {
|
||||||
|
|
||||||
private static final String ALGORITHM = "AES";
|
private static final String ALGORITHM = "AES";
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final String[] MODES = { "ECb", "CbC", "OFB", "OFB150",
|
private static final String[] MODES = { "ECb", "CbC", "OFB", "OFB150",
|
||||||
"cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", "Cfb40", "cfB48",
|
"cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", "Cfb40", "cfB48",
|
||||||
"cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96", "cfb104",
|
"cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96", "cfb104",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,7 +47,8 @@ import javax.crypto.spec.IvParameterSpec;
|
|||||||
public class TestSameBuffer {
|
public class TestSameBuffer {
|
||||||
|
|
||||||
private static final String ALGORITHM = "AES";
|
private static final String ALGORITHM = "AES";
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final String[] MODES = { "ECb", "CbC", "OFB", "CFB150",
|
private static final String[] MODES = { "ECb", "CbC", "OFB", "CFB150",
|
||||||
"cFB", "CFB7", " cFB8", "cFB16", "cFB24", "cFB32", "Cfb40",
|
"cFB", "CFB7", " cFB8", "cFB16", "cFB24", "cFB32", "Cfb40",
|
||||||
"cfB48", " cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96",
|
"cfB48", " cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -71,7 +71,7 @@ public class TestShortBuffer {
|
|||||||
for (int i = 0; i < MODES.length; i++) {
|
for (int i = 0; i < MODES.length; i++) {
|
||||||
System.out.println("===== TESTING MODE " + MODES[i] + " =====");
|
System.out.println("===== TESTING MODE " + MODES[i] + " =====");
|
||||||
Cipher ci = Cipher.getInstance(ALGO+"/"+MODES[i]+"/PKCS5Padding",
|
Cipher ci = Cipher.getInstance(ALGO+"/"+MODES[i]+"/PKCS5Padding",
|
||||||
"SunJCE");
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
TestShortBuffer test = null;
|
TestShortBuffer test = null;
|
||||||
int stored = 0;
|
int stored = 0;
|
||||||
AlgorithmParameters params = null;
|
AlgorithmParameters params = null;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -162,7 +162,8 @@ public class CounterMode {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
System.out.println("Running test " + i + " (" + alg + ")");
|
System.out.println("Running test " + i + " (" + alg + ")");
|
||||||
Cipher cipher = Cipher.getInstance(alg + "/CTR/NoPadding", "SunJCE");
|
Cipher cipher = Cipher.getInstance(alg + "/CTR/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
SecretKeySpec key = new SecretKeySpec(KEYS[i], alg);
|
SecretKeySpec key = new SecretKeySpec(KEYS[i], alg);
|
||||||
IvParameterSpec iv = new IvParameterSpec(IVS[i]);
|
IvParameterSpec iv = new IvParameterSpec(IVS[i]);
|
||||||
byte[] plainText = PLAIN[i];
|
byte[] plainText = PLAIN[i];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -156,7 +156,7 @@ public class CTSMode {
|
|||||||
}
|
}
|
||||||
System.out.println("Running test1_" + i + " (" + algo + ")");
|
System.out.println("Running test1_" + i + " (" + algo + ")");
|
||||||
Cipher cipher = Cipher.getInstance(algo+ "/CTS/NoPadding",
|
Cipher cipher = Cipher.getInstance(algo+ "/CTS/NoPadding",
|
||||||
"SunJCE");
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
byte[] plainText = PLAIN1[i];
|
byte[] plainText = PLAIN1[i];
|
||||||
byte[] cipherText = CIPHER1[i];
|
byte[] cipherText = CIPHER1[i];
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, KEY1, IV1);
|
cipher.init(Cipher.ENCRYPT_MODE, KEY1, IV1);
|
||||||
@ -194,7 +194,8 @@ public class CTSMode {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Cipher cipher =
|
Cipher cipher =
|
||||||
Cipher.getInstance(algo+"/CTS/NoPadding", "SunJCE");
|
Cipher.getInstance(algo+"/CTS/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
int blockSize = cipher.getBlockSize();
|
int blockSize = cipher.getBlockSize();
|
||||||
SecretKeySpec key = new SecretKeySpec(new byte[keySize], algo);
|
SecretKeySpec key = new SecretKeySpec(new byte[keySize], algo);
|
||||||
// Make sure encryption works for inputs with valid length
|
// Make sure encryption works for inputs with valid length
|
||||||
@ -226,7 +227,8 @@ public class CTSMode {
|
|||||||
IvParameterSpec iv2 = new IvParameterSpec(IV2_SRC, 0, blockSize);
|
IvParameterSpec iv2 = new IvParameterSpec(IV2_SRC, 0, blockSize);
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, key, iv2);
|
cipher.init(Cipher.ENCRYPT_MODE, key, iv2);
|
||||||
Cipher cipher2 =
|
Cipher cipher2 =
|
||||||
Cipher.getInstance(algo+"/CBC/NoPadding", "SunJCE");
|
Cipher.getInstance(algo+"/CBC/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
cipher2.init(Cipher.ENCRYPT_MODE, key, iv2);
|
cipher2.init(Cipher.ENCRYPT_MODE, key, iv2);
|
||||||
|
|
||||||
byte[] eout = cipher.doFinal(IV2_SRC, 0, blockSize);
|
byte[] eout = cipher.doFinal(IV2_SRC, 0, blockSize);
|
||||||
@ -294,7 +296,8 @@ public class CTSMode {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Cipher cipher =
|
Cipher cipher =
|
||||||
Cipher.getInstance(algo+ "/CTS/NoPadding", "SunJCE");
|
Cipher.getInstance(algo+ "/CTS/NoPadding",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
byte[] plainText = PLAIN1[i];
|
byte[] plainText = PLAIN1[i];
|
||||||
byte[] cipherText = CIPHER1[i];
|
byte[] cipherText = CIPHER1[i];
|
||||||
byte[] enc = new byte[plainText.length];
|
byte[] enc = new byte[plainText.length];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -33,7 +33,8 @@ import java.security.*;
|
|||||||
public class KeyWrapping {
|
public class KeyWrapping {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Cipher c1 = Cipher.getInstance("DES", "SunJCE");
|
Cipher c1 = Cipher.getInstance("DES",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
Cipher c2 = Cipher.getInstance("DES");
|
Cipher c2 = Cipher.getInstance("DES");
|
||||||
|
|
||||||
KeyGenerator keyGen = KeyGenerator.getInstance("DES");
|
KeyGenerator keyGen = KeyGenerator.getInstance("DES");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -259,9 +259,12 @@ public class NISTWrapKAT {
|
|||||||
System.out.println("=> skip, exceeds max allowed size " + allowed);
|
System.out.println("=> skip, exceeds max allowed size " + allowed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Cipher c1 = Cipher.getInstance(algo, "SunJCE");
|
Cipher c1 = Cipher.getInstance(algo,
|
||||||
Cipher c2 = Cipher.getInstance(algo, "SunJCE");
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
Cipher c3 = Cipher.getInstance(algo, "SunJCE");
|
Cipher c2 = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
Cipher c3 = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
byte[] keyVal = toBytes(key, keyLen << 1);
|
byte[] keyVal = toBytes(key, keyLen << 1);
|
||||||
byte[] dataVal = toBytes(data, dataLen << 1);
|
byte[] dataVal = toBytes(data, dataLen << 1);
|
||||||
@ -318,9 +321,12 @@ public class NISTWrapKAT {
|
|||||||
System.out.println("=> skip, exceeds max allowed size " + allowed);
|
System.out.println("=> skip, exceeds max allowed size " + allowed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Cipher c1 = Cipher.getInstance(algo, "SunJCE");
|
Cipher c1 = Cipher.getInstance(algo,
|
||||||
Cipher c2 = Cipher.getInstance(algo, "SunJCE");
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
Cipher c3 = Cipher.getInstance(algo, "SunJCE");
|
Cipher c2 = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
Cipher c3 = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
byte[] keyVal = toBytes(key, keyLen << 1);
|
byte[] keyVal = toBytes(key, keyLen << 1);
|
||||||
byte[] dataVal = toBytes(data, dataLen << 1);
|
byte[] dataVal = toBytes(data, dataLen << 1);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -58,7 +58,8 @@ import javax.crypto.spec.PBEParameterSpec;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class TestCipherKeyWrapperTest {
|
public class TestCipherKeyWrapperTest {
|
||||||
private static final String SUN_JCE = "SunJCE";
|
private static final String PROVIDER_NAME =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
// Blowfish Variable key length: 32 bits to 448 bits
|
// Blowfish Variable key length: 32 bits to 448 bits
|
||||||
private static final int BLOWFISH_MIN_KEYSIZE = 32;
|
private static final int BLOWFISH_MIN_KEYSIZE = 32;
|
||||||
private static final int BLOWFISH_MAX_KEYSIZE = 448;
|
private static final int BLOWFISH_MAX_KEYSIZE = 448;
|
||||||
@ -157,9 +158,9 @@ public class TestCipherKeyWrapperTest {
|
|||||||
// PBE and public wrapper test.
|
// PBE and public wrapper test.
|
||||||
String[] publicPrivateAlgos = new String[] { "DiffieHellman", "DSA",
|
String[] publicPrivateAlgos = new String[] { "DiffieHellman", "DSA",
|
||||||
"RSA" };
|
"RSA" };
|
||||||
Provider provider = Security.getProvider(SUN_JCE);
|
Provider provider = Security.getProvider(PROVIDER_NAME);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
throw new RuntimeException("SUN_JCE provider not exist");
|
throw new RuntimeException(PROVIDER_NAME + " provider not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
test.wrapperPBEKeyTest(provider);
|
test.wrapperPBEKeyTest(provider);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -220,7 +220,8 @@ public class TestGeneral {
|
|||||||
SecretKey aes256 = new SecretKeySpec(DATA_32, "AES");
|
SecretKey aes256 = new SecretKeySpec(DATA_32, "AES");
|
||||||
SecretKey any256 = new SecretKeySpec(DATA_32, "ANY");
|
SecretKey any256 = new SecretKeySpec(DATA_32, "ANY");
|
||||||
PrivateKey priv = KeyPairGenerator.getInstance
|
PrivateKey priv = KeyPairGenerator.getInstance
|
||||||
("RSA", "SunRsaSign").generateKeyPair().getPrivate();
|
("RSA", System.getProperty("test.provider.name", "SunRsaSign"))
|
||||||
|
.generateKeyPair().getPrivate();
|
||||||
|
|
||||||
String[] algos = {
|
String[] algos = {
|
||||||
"AES/KW/PKCS5Padding", "AES/KW/NoPadding", "AES/KWP/NoPadding"
|
"AES/KW/PKCS5Padding", "AES/KW/NoPadding", "AES/KWP/NoPadding"
|
||||||
@ -228,7 +229,8 @@ public class TestGeneral {
|
|||||||
|
|
||||||
for (String a : algos) {
|
for (String a : algos) {
|
||||||
System.out.println("Testing " + a);
|
System.out.println("Testing " + a);
|
||||||
Cipher c = Cipher.getInstance(a, "SunJCE");
|
Cipher c = Cipher.getInstance(a,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
int blkSize = c.getBlockSize();
|
int blkSize = c.getBlockSize();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -61,7 +61,8 @@ public class TestKeySizeCheck {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
System.out.println("Testing " + algo);
|
System.out.println("Testing " + algo);
|
||||||
Cipher c = Cipher.getInstance(algo, "SunJCE");
|
Cipher c = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
int[] modes = { Cipher.ENCRYPT_MODE, Cipher.WRAP_MODE };
|
int[] modes = { Cipher.ENCRYPT_MODE, Cipher.WRAP_MODE };
|
||||||
for (int ks : invalidKeySizes) {
|
for (int ks : invalidKeySizes) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -111,7 +111,8 @@ public class XMLEncKAT {
|
|||||||
String cKeyAlg, String[] base64Wrapped) throws Exception {
|
String cKeyAlg, String[] base64Wrapped) throws Exception {
|
||||||
System.out.println("Testing " + cAlg + " Cipher with " +
|
System.out.println("Testing " + cAlg + " Cipher with " +
|
||||||
8*cKeyVal.length + "-bit key");
|
8*cKeyVal.length + "-bit key");
|
||||||
Cipher c = Cipher.getInstance(cAlg, "SunJCE");
|
Cipher c = Cipher.getInstance(cAlg,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
SecretKey cKey = new SecretKeySpec(cKeyVal, cKeyAlg);
|
SecretKey cKey = new SecretKeySpec(cKeyVal, cKeyAlg);
|
||||||
c.init(Cipher.UNWRAP_MODE, cKey);
|
c.init(Cipher.UNWRAP_MODE, cKey);
|
||||||
Key[] key = new SecretKey[base64Wrapped.length];
|
Key[] key = new SecretKey[base64Wrapped.length];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -113,7 +113,8 @@ public class DecryptWithoutParameters {
|
|||||||
boolean status = true;
|
boolean status = true;
|
||||||
|
|
||||||
for (String algo : PBES1ALGOS) {
|
for (String algo : PBES1ALGOS) {
|
||||||
Cipher cipher = Cipher.getInstance(algo, "SunJCE");
|
Cipher cipher = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
SecretKey key = new SecretKeySpec(new byte[5], algo);
|
SecretKey key = new SecretKeySpec(new byte[5], algo);
|
||||||
status = status && test(cipher, key, null);
|
status = status && test(cipher, key, null);
|
||||||
}
|
}
|
||||||
@ -122,7 +123,8 @@ public class DecryptWithoutParameters {
|
|||||||
int iterCount = 123456;
|
int iterCount = 123456;
|
||||||
PBEParameterSpec spec = new PBEParameterSpec(salt, iterCount);
|
PBEParameterSpec spec = new PBEParameterSpec(salt, iterCount);
|
||||||
for (String algo : PBES2ALGOS) {
|
for (String algo : PBES2ALGOS) {
|
||||||
Cipher cipher = Cipher.getInstance(algo, "SunJCE");
|
Cipher cipher = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
SecretKey key = new SecretKeySpec(new byte[5], algo);
|
SecretKey key = new SecretKeySpec(new byte[5], algo);
|
||||||
PBEKey key2 = new MyPBEKey(algo,
|
PBEKey key2 = new MyPBEKey(algo,
|
||||||
new PBEKeySpec("phrase".toCharArray(), salt, iterCount));
|
new PBEKeySpec("phrase".toCharArray(), salt, iterCount));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -38,7 +38,9 @@ public class NegativeLength {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
SecretKeyFactory skf = SecretKeyFactory.getInstance(
|
SecretKeyFactory skf = SecretKeyFactory.getInstance(
|
||||||
"PBKDF2WithHmacSHA1", "SunJCE");
|
"PBKDF2WithHmacSHA1",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
|
|
||||||
// Create a valid PBEKeySpec
|
// Create a valid PBEKeySpec
|
||||||
PBEKeySpec pbeks = new PBEKeySpec(
|
PBEKeySpec pbeks = new PBEKeySpec(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -67,7 +67,8 @@ public class PBEInvalidParamsTest {
|
|||||||
System.out.println("=>testing " + algo);
|
System.out.println("=>testing " + algo);
|
||||||
SecretKeyFactory skf = SecretKeyFactory.getInstance(algo);
|
SecretKeyFactory skf = SecretKeyFactory.getInstance(algo);
|
||||||
SecretKey key = skf.generateSecret(ks);
|
SecretKey key = skf.generateSecret(ks);
|
||||||
Cipher c = Cipher.getInstance(algo, "SunJCE");
|
Cipher c = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
try {
|
try {
|
||||||
c.init(Cipher.ENCRYPT_MODE, key, INVALID_PARAMS);
|
c.init(Cipher.ENCRYPT_MODE, key, INVALID_PARAMS);
|
||||||
throw new Exception("Test Failed: expected IAPE is " +
|
throw new Exception("Test Failed: expected IAPE is " +
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -45,7 +45,8 @@ import javax.crypto.spec.PBEKeySpec;
|
|||||||
*/
|
*/
|
||||||
public class PBEKeyCleanupTest {
|
public class PBEKeyCleanupTest {
|
||||||
|
|
||||||
private final static String SunJCEProvider = "SunJCE";
|
private final static String PROVIDER_NAME =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
|
||||||
private static final String PASS_PHRASE = "some hidden string";
|
private static final String PASS_PHRASE = "some hidden string";
|
||||||
private static final int ITERATION_COUNT = 1000;
|
private static final int ITERATION_COUNT = 1000;
|
||||||
@ -60,7 +61,7 @@ public class PBEKeyCleanupTest {
|
|||||||
char[] password = new char[] {'f', 'o', 'o'};
|
char[] password = new char[] {'f', 'o', 'o'};
|
||||||
PBEKeySpec pbeKeySpec = new PBEKeySpec(password);
|
PBEKeySpec pbeKeySpec = new PBEKeySpec(password);
|
||||||
SecretKeyFactory keyFac =
|
SecretKeyFactory keyFac =
|
||||||
SecretKeyFactory.getInstance(algorithm, SunJCEProvider);
|
SecretKeyFactory.getInstance(algorithm, PROVIDER_NAME);
|
||||||
|
|
||||||
testCleanupSecret(algorithm, keyFac.generateSecret(pbeKeySpec));
|
testCleanupSecret(algorithm, keyFac.generateSecret(pbeKeySpec));
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ public class PBEKeyCleanupTest {
|
|||||||
PBEKeySpec pbeKeySpec = new PBEKeySpec(PASS_PHRASE.toCharArray(), salt,
|
PBEKeySpec pbeKeySpec = new PBEKeySpec(PASS_PHRASE.toCharArray(), salt,
|
||||||
ITERATION_COUNT, KEY_SIZE);
|
ITERATION_COUNT, KEY_SIZE);
|
||||||
SecretKeyFactory keyFac =
|
SecretKeyFactory keyFac =
|
||||||
SecretKeyFactory.getInstance(algorithm, SunJCEProvider);
|
SecretKeyFactory.getInstance(algorithm, PROVIDER_NAME);
|
||||||
|
|
||||||
testCleanupSecret(algorithm, keyFac.generateSecret(pbeKeySpec));
|
testCleanupSecret(algorithm, keyFac.generateSecret(pbeKeySpec));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -59,7 +59,8 @@ public class PBEKeysAlgorithmNames {
|
|||||||
|
|
||||||
for (String s : algs) {
|
for (String s : algs) {
|
||||||
System.out.println("Testing " + s);
|
System.out.println("Testing " + s);
|
||||||
SecretKeyFactory skf = SecretKeyFactory.getInstance(s, "SunJCE");
|
SecretKeyFactory skf = SecretKeyFactory.getInstance(s,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
System.out.println(" Checking skf.getAlgorithm()");
|
System.out.println(" Checking skf.getAlgorithm()");
|
||||||
if (!skf.getAlgorithm().equalsIgnoreCase(s)) {
|
if (!skf.getAlgorithm().equalsIgnoreCase(s)) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -61,7 +61,8 @@ public class PBEParametersTest {
|
|||||||
String algo = PBE_ALGOS[i];
|
String algo = PBE_ALGOS[i];
|
||||||
SecretKeyFactory skf = SecretKeyFactory.getInstance(algo);
|
SecretKeyFactory skf = SecretKeyFactory.getInstance(algo);
|
||||||
SecretKey key = skf.generateSecret(ks);
|
SecretKey key = skf.generateSecret(ks);
|
||||||
Cipher c = Cipher.getInstance(algo, "SunJCE");
|
Cipher c = Cipher.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
c.init(Cipher.ENCRYPT_MODE, key);
|
c.init(Cipher.ENCRYPT_MODE, key);
|
||||||
c.doFinal(new byte[10]); // force the generation of parameters
|
c.doFinal(new byte[10]); // force the generation of parameters
|
||||||
AlgorithmParameters params = c.getParameters();
|
AlgorithmParameters params = c.getParameters();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -81,7 +81,7 @@ public class PBESameBuffer {
|
|||||||
public boolean test(String[] args, PrintStream out) {
|
public boolean test(String[] args, PrintStream out) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
|
||||||
Provider p = Security.getProvider("SunJCE");
|
Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
for (int loop : OFFSETS) {
|
for (int loop : OFFSETS) {
|
||||||
OUTPUT_OFFSET = loop;
|
OUTPUT_OFFSET = loop;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -80,9 +80,12 @@ public class PBESealedObject {
|
|||||||
"PBEWithHmacSHA512/256AndAES_256",
|
"PBEWithHmacSHA512/256AndAES_256",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final String PROVIDER_NAME =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
PBESealedObject test = new PBESealedObject();
|
PBESealedObject test = new PBESealedObject();
|
||||||
Provider sunjce = Security.getProvider("SunJCE");
|
Provider sunjce = Security.getProvider(PROVIDER_NAME);
|
||||||
|
|
||||||
if (!test.runAll(sunjce, System.out)) {
|
if (!test.runAll(sunjce, System.out)) {
|
||||||
throw new RuntimeException("One or more tests have failed....");
|
throw new RuntimeException("One or more tests have failed....");
|
||||||
@ -163,7 +166,7 @@ public class PBESealedObject {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsealedKey = (SecretKey) so.getObject(key, "SunJCE");
|
unsealedKey = (SecretKey) so.getObject(key, PROVIDER_NAME);
|
||||||
return Arrays.equals(unsealedKey.getEncoded(), key.getEncoded());
|
return Arrays.equals(unsealedKey.getEncoded(), key.getEncoded());
|
||||||
} catch (InvalidKeyException ex) {
|
} catch (InvalidKeyException ex) {
|
||||||
if (keyAlgo.endsWith("TRIPLEDES") || keyAlgo.endsWith("AES_256")) {
|
if (keyAlgo.endsWith("TRIPLEDES") || keyAlgo.endsWith("AES_256")) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -84,7 +84,8 @@ public class PKCS12Cipher {
|
|||||||
new SecureRandom().nextBytes(input);
|
new SecureRandom().nextBytes(input);
|
||||||
char[] PASSWD = { 'p','a','s','s','w','o','r','d' };
|
char[] PASSWD = { 'p','a','s','s','w','o','r','d' };
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Provider p = Security.getProvider("SunJCE");
|
Provider p = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + p.getName() + "...");
|
System.out.println("Testing provider " + p.getName() + "...");
|
||||||
runTest("PBEWithSHA1AndDESede", input, PASSWD, p);
|
runTest("PBEWithSHA1AndDESede", input, PASSWD, p);
|
||||||
runTest("PBEWithSHA1AndRC2_40", input, PASSWD, p);
|
runTest("PBEWithSHA1AndRC2_40", input, PASSWD, p);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -179,7 +179,8 @@ public class PKCS12CipherKAT {
|
|||||||
|
|
||||||
static void runTests(Test[] tests) throws Exception {
|
static void runTests(Test[] tests) throws Exception {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Provider p = Security.getProvider("SunJCE");
|
Provider p = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + p.getName() + "...");
|
System.out.println("Testing provider " + p.getName() + "...");
|
||||||
Cipher.getInstance("PBEWithSHA1AndRC2_40", p);
|
Cipher.getInstance("PBEWithSHA1AndRC2_40", p);
|
||||||
Cipher.getInstance("PBEWithSHA1AndDESede", p);
|
Cipher.getInstance("PBEWithSHA1AndDESede", p);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -83,7 +83,8 @@ public class TestCipherKeyWrapperPBEKey {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
TestCipherKeyWrapperPBEKey test = new TestCipherKeyWrapperPBEKey();
|
TestCipherKeyWrapperPBEKey test = new TestCipherKeyWrapperPBEKey();
|
||||||
Provider sunjce = Security.getProvider("SunJCE");
|
Provider sunjce = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
if (!test.runAll(sunjce, System.out)) {
|
if (!test.runAll(sunjce, System.out)) {
|
||||||
throw new RuntimeException("One or more tests have failed....");
|
throw new RuntimeException("One or more tests have failed....");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,7 +47,8 @@ public class TestCipherPBECons {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TestCipherPBECons test = new TestCipherPBECons();
|
TestCipherPBECons test = new TestCipherPBECons();
|
||||||
Provider sunjce = Security.getProvider("SunJCE");
|
Provider sunjce = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
if (!test.runAll(sunjce, System.out)) {
|
if (!test.runAll(sunjce, System.out)) {
|
||||||
throw new RuntimeException("One or more tests have failed....");
|
throw new RuntimeException("One or more tests have failed....");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,9 +47,10 @@ public class TestOAEP {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
cp = Security.getProvider("SunJCE");
|
cp = Security.getProvider(System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + cp.getName() + "...");
|
System.out.println("Testing provider " + cp.getName() + "...");
|
||||||
Provider kfp = Security.getProvider("SunRsaSign");
|
Provider kfp = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunRsaSign"));
|
||||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp);
|
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp);
|
||||||
kpg.initialize(768);
|
kpg.initialize(768);
|
||||||
KeyPair kp = kpg.generateKeyPair();
|
KeyPair kp = kpg.generateKeyPair();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -52,9 +52,11 @@ public class TestOAEPPadding {
|
|||||||
static boolean failed = false;
|
static boolean failed = false;
|
||||||
|
|
||||||
public static void main(String args[]) throws Exception {
|
public static void main(String args[]) throws Exception {
|
||||||
cp = Security.getProvider("SunJCE");
|
cp = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + cp.getName() + "...");
|
System.out.println("Testing provider " + cp.getName() + "...");
|
||||||
Provider kfp = Security.getProvider("SunRsaSign");
|
Provider kfp = Security.getProvider(
|
||||||
|
System.getProperty("test.providername", "SunRsaSign"));
|
||||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp);
|
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp);
|
||||||
kpg.initialize(2048);
|
kpg.initialize(2048);
|
||||||
KeyPair kp = kpg.generateKeyPair();
|
KeyPair kp = kpg.generateKeyPair();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,7 +44,8 @@ public class TestOAEPParameterSpec {
|
|||||||
byte[] p) throws Exception {
|
byte[] p) throws Exception {
|
||||||
OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1",
|
OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1",
|
||||||
mgfSpec, new PSource.PSpecified(p));
|
mgfSpec, new PSource.PSpecified(p));
|
||||||
cp = Security.getProvider("SunJCE");
|
cp = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + cp.getName() + "...");
|
System.out.println("Testing provider " + cp.getName() + "...");
|
||||||
AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp);
|
AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -54,9 +54,11 @@ public class TestOAEPWithParams {
|
|||||||
};
|
};
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
cp = Security.getProvider("SunJCE");
|
cp = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + cp.getName() + "...");
|
System.out.println("Testing provider " + cp.getName() + "...");
|
||||||
Provider kfp = Security.getProvider("SunRsaSign");
|
Provider kfp = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunRsaSign"));
|
||||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp);
|
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp);
|
||||||
kpg.initialize(768);
|
kpg.initialize(768);
|
||||||
KeyPair kp = kpg.generateKeyPair();
|
KeyPair kp = kpg.generateKeyPair();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -57,8 +57,10 @@ public class TestOAEP_KAT {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
Provider provider = Security.getProvider(
|
||||||
Provider kfProvider = Security.getProvider("SunRsaSign");
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
Provider kfProvider = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunRsaSign"));
|
||||||
System.out.println("Testing provider " + provider.getName() + "...");
|
System.out.println("Testing provider " + provider.getName() + "...");
|
||||||
Cipher c = Cipher.getInstance("RSA/ECB/OAEPwithSHA1andMGF1Padding", provider);
|
Cipher c = Cipher.getInstance("RSA/ECB/OAEPwithSHA1andMGF1Padding", provider);
|
||||||
KeyFactory kf = KeyFactory.getInstance("RSA", kfProvider);
|
KeyFactory kf = KeyFactory.getInstance("RSA", kfProvider);
|
||||||
|
@ -168,7 +168,8 @@ public class TestRSA {
|
|||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
p = Security.getProvider("SunJCE");
|
p = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + p.getName() + "...");
|
System.out.println("Testing provider " + p.getName() + "...");
|
||||||
|
|
||||||
KeyFactory kf;
|
KeyFactory kf;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,7 +44,7 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
*/
|
*/
|
||||||
public abstract class TestCipher {
|
public abstract class TestCipher {
|
||||||
|
|
||||||
private final String SUNJCE = "SunJCE";
|
private final String PROVIDER_NAME = System.getProperty("test.provider.name", "SunJCE");
|
||||||
private final String ALGORITHM;
|
private final String ALGORITHM;
|
||||||
private final String[] MODES;
|
private final String[] MODES;
|
||||||
private final String[] PADDINGS;
|
private final String[] PADDINGS;
|
||||||
@ -138,8 +138,8 @@ public abstract class TestCipher {
|
|||||||
out.println("Testing: " + TRANSFORMATION);
|
out.println("Testing: " + TRANSFORMATION);
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
Cipher ci = Cipher.getInstance(TRANSFORMATION, SUNJCE);
|
Cipher ci = Cipher.getInstance(TRANSFORMATION, PROVIDER_NAME);
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM, SUNJCE);
|
KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM, PROVIDER_NAME);
|
||||||
if (keySize != 0) {
|
if (keySize != 0) {
|
||||||
kg.init(keySize);
|
kg.init(keySize);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,9 +44,11 @@ public class SameBufferOverwrite {
|
|||||||
SameBufferOverwrite(String algo, String transformation)
|
SameBufferOverwrite(String algo, String transformation)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
skey = kg.generateKey();
|
skey = kg.generateKey();
|
||||||
c = Cipher.getInstance(transformation, "SunJCE");
|
c = Cipher.getInstance(transformation,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -38,7 +38,8 @@ public class StrongOrUnlimited {
|
|||||||
// decide if the installed jurisdiction policy file is the
|
// decide if the installed jurisdiction policy file is the
|
||||||
// unlimited version
|
// unlimited version
|
||||||
boolean isUnlimited = true;
|
boolean isUnlimited = true;
|
||||||
Cipher c = Cipher.getInstance("AES", "SunJCE");
|
Cipher c = Cipher.getInstance("AES",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
c.init(Cipher.ENCRYPT_MODE,
|
c.init(Cipher.ENCRYPT_MODE,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -40,9 +40,10 @@ public class SunJCEGetInstance {
|
|||||||
Cipher jce;
|
Cipher jce;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
String providerName = System.getProperty("test.provider.name", "SunJCE");
|
||||||
// Remove SunJCE from Provider list
|
// Remove SunJCE from Provider list
|
||||||
Provider prov = Security.getProvider("SunJCE");
|
Provider prov = Security.getProvider(providerName);
|
||||||
Security.removeProvider("SunJCE");
|
Security.removeProvider(providerName);
|
||||||
// Create our own instance of SunJCE provider. Purposefully not
|
// Create our own instance of SunJCE provider. Purposefully not
|
||||||
// using SunJCE.getInstance() so we can have our own instance
|
// using SunJCE.getInstance() so we can have our own instance
|
||||||
// for the test.
|
// for the test.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -62,7 +62,8 @@ public class DHKeyFactory {
|
|||||||
dhSkipParamSpec = new DHParameterSpec(skip1024Modulus,
|
dhSkipParamSpec = new DHParameterSpec(skip1024Modulus,
|
||||||
skip1024Base);
|
skip1024Base);
|
||||||
|
|
||||||
KeyPairGenerator kpgen = KeyPairGenerator.getInstance("DH", "SunJCE");
|
KeyPairGenerator kpgen = KeyPairGenerator.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kpgen.initialize(dhSkipParamSpec);
|
kpgen.initialize(dhSkipParamSpec);
|
||||||
KeyPair kp = kpgen.generateKeyPair();
|
KeyPair kp = kpgen.generateKeyPair();
|
||||||
|
|
||||||
@ -72,7 +73,8 @@ public class DHKeyFactory {
|
|||||||
// get the private key encoding
|
// get the private key encoding
|
||||||
byte[] privKeyEnc = kp.getPrivate().getEncoded();
|
byte[] privKeyEnc = kp.getPrivate().getEncoded();
|
||||||
|
|
||||||
KeyFactory kfac = KeyFactory.getInstance("DH", "SunJCE");
|
KeyFactory kfac = KeyFactory.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(pubKeyEnc);
|
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(pubKeyEnc);
|
||||||
PublicKey pubKey = kfac.generatePublic(x509KeySpec);
|
PublicKey pubKey = kfac.generatePublic(x509KeySpec);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -87,7 +87,8 @@ public class DHKeyGenSpeed {
|
|||||||
|
|
||||||
// generate keyPairs using parameters
|
// generate keyPairs using parameters
|
||||||
KeyPairGenerator keyGen =
|
KeyPairGenerator keyGen =
|
||||||
KeyPairGenerator.getInstance("DH", "SunJCE");
|
KeyPairGenerator.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
keyGen.initialize(spec);
|
keyGen.initialize(spec);
|
||||||
KeyPair keys = keyGen.generateKeyPair();
|
KeyPair keys = keyGen.generateKeyPair();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -78,7 +78,8 @@ public class SameDHKeyStressTest {
|
|||||||
Key[] keyArchives = new Key[numParties];
|
Key[] keyArchives = new Key[numParties];
|
||||||
try {
|
try {
|
||||||
// generate AlogirhtmParameterSpec
|
// generate AlogirhtmParameterSpec
|
||||||
AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE");
|
AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64);
|
AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64);
|
||||||
apg.init(aps);
|
apg.init(aps);
|
||||||
DHParameterSpec spec = apg.generateParameters().
|
DHParameterSpec spec = apg.generateParameters().
|
||||||
@ -139,8 +140,10 @@ class KAParticipant {
|
|||||||
public KAParticipant(String pName, String algo) throws NoSuchAlgorithmException, NoSuchProviderException {
|
public KAParticipant(String pName, String algo) throws NoSuchAlgorithmException, NoSuchProviderException {
|
||||||
name = pName;
|
name = pName;
|
||||||
algorithm = algo;
|
algorithm = algo;
|
||||||
keyGen = KeyPairGenerator.getInstance(algo,"SunJCE");
|
keyGen = KeyPairGenerator.getInstance(algo,
|
||||||
ka = KeyAgreement.getInstance(algo,"SunJCE");
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
ka = KeyAgreement.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(AlgorithmParameterSpec spec) throws InvalidAlgorithmParameterException, InvalidKeyException {
|
public void initialize(AlgorithmParameterSpec spec) throws InvalidAlgorithmParameterException, InvalidKeyException {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -55,7 +55,8 @@ public class SupportedDHKeys {
|
|||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
for (SupportedKeySize keySize : SupportedKeySize.values()) {
|
for (SupportedKeySize keySize : SupportedKeySize.values()) {
|
||||||
System.out.println("Checking " + keySize.primeSize + " ...");
|
System.out.println("Checking " + keySize.primeSize + " ...");
|
||||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE");
|
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kpg.initialize(keySize.primeSize);
|
kpg.initialize(keySize.primeSize);
|
||||||
KeyPair kp = kpg.generateKeyPair();
|
KeyPair kp = kpg.generateKeyPair();
|
||||||
checkKeyPair(kp, keySize.primeSize);
|
checkKeyPair(kp, keySize.primeSize);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -49,12 +49,14 @@ public class SupportedDHParamGens {
|
|||||||
|
|
||||||
System.out.println("Checking " + primeSize + " ...");
|
System.out.println("Checking " + primeSize + " ...");
|
||||||
AlgorithmParameterGenerator apg =
|
AlgorithmParameterGenerator apg =
|
||||||
AlgorithmParameterGenerator.getInstance("DH", "SunJCE");
|
AlgorithmParameterGenerator.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
apg.init(primeSize);
|
apg.init(primeSize);
|
||||||
AlgorithmParameters ap = apg.generateParameters();
|
AlgorithmParameters ap = apg.generateParameters();
|
||||||
DHParameterSpec spec = ap.getParameterSpec(DHParameterSpec.class);
|
DHParameterSpec spec = ap.getParameterSpec(DHParameterSpec.class);
|
||||||
|
|
||||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE");
|
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kpg.initialize(spec);
|
kpg.initialize(spec);
|
||||||
KeyPair kp = kpg.generateKeyPair();
|
KeyPair kp = kpg.generateKeyPair();
|
||||||
checkKeyPair(kp, primeSize);
|
checkKeyPair(kp, primeSize);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -81,7 +81,8 @@ public class TestExponentSize {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
KeyPair kp;
|
KeyPair kp;
|
||||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE");
|
KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
// Sun's default uses a default psize of 3072 and
|
// Sun's default uses a default psize of 3072 and
|
||||||
// lsize of (pSize / 2) but at least 384 bits
|
// lsize of (pSize / 2) but at least 384 bits
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -61,7 +61,8 @@ public class UnsupportedDHKeys {
|
|||||||
try {
|
try {
|
||||||
System.out.println("Checking " + keySize.primeSize + " ...");
|
System.out.println("Checking " + keySize.primeSize + " ...");
|
||||||
KeyPairGenerator kpg =
|
KeyPairGenerator kpg =
|
||||||
KeyPairGenerator.getInstance("DH", "SunJCE");
|
KeyPairGenerator.getInstance("DH",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kpg.initialize(keySize.primeSize);
|
kpg.initialize(keySize.primeSize);
|
||||||
|
|
||||||
throw new Exception("Should not support " + keySize.primeSize);
|
throw new Exception("Should not support " + keySize.primeSize);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -69,7 +69,8 @@ public class PBKDF2HmacSHA1FactoryTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static void test() throws Exception {
|
private static void test() throws Exception {
|
||||||
SecretKeyFactory skf = SecretKeyFactory.getInstance(ALGO, "SunJCE");
|
SecretKeyFactory skf = SecretKeyFactory.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
for (int i = 0; i < TEST_VECTORS.length; i++) {
|
for (int i = 0; i < TEST_VECTORS.length; i++) {
|
||||||
System.out.println("=>Testing vector#" + (i+1));
|
System.out.println("=>Testing vector#" + (i+1));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -106,7 +106,8 @@ public class TestProviderLeak {
|
|||||||
public static void main(String [] args) throws Exception {
|
public static void main(String [] args) throws Exception {
|
||||||
// Prepare the test
|
// Prepare the test
|
||||||
final SecretKeyFactory skf =
|
final SecretKeyFactory skf =
|
||||||
SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1", "SunJCE");
|
SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1",
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
final PBEKeySpec pbeKS = new PBEKeySpec(
|
final PBEKeySpec pbeKS = new PBEKeySpec(
|
||||||
"passPhrase".toCharArray(), new byte [] { 0 }, 5, 512);
|
"passPhrase".toCharArray(), new byte [] { 0 }, 5, 512);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,7 +44,8 @@ public class Test4628062 {
|
|||||||
private static final int[] HMACSHA512_256_SIZES = { 32 };
|
private static final int[] HMACSHA512_256_SIZES = { 32 };
|
||||||
|
|
||||||
public boolean execute(String algo, int[] keySizes) throws Exception {
|
public boolean execute(String algo, int[] keySizes) throws Exception {
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
// TEST FIX 4628062
|
// TEST FIX 4628062
|
||||||
Key keyWithDefaultSize = kg.generateKey();
|
Key keyWithDefaultSize = kg.generateKey();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -38,7 +38,8 @@ public class Test6227536 {
|
|||||||
String[] keyGensToTest = new String[]{"HmacSHA1", "HmacMD5"};
|
String[] keyGensToTest = new String[]{"HmacSHA1", "HmacMD5"};
|
||||||
|
|
||||||
public boolean execute(String algo) throws Exception {
|
public boolean execute(String algo) throws Exception {
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
Utils.runAndCheckException(() -> kg.init(0),
|
Utils.runAndCheckException(() -> kg.init(0),
|
||||||
IllegalArgumentException.class);
|
IllegalArgumentException.class);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,7 +41,8 @@ public class TestExplicitKeyLength {
|
|||||||
{ 64, 80 }; // in bits
|
{ 64, 80 }; // in bits
|
||||||
|
|
||||||
public static void runTest(String algo, int keysize) throws Exception {
|
public static void runTest(String algo, int keysize) throws Exception {
|
||||||
KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE");
|
KeyGenerator kg = KeyGenerator.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
kg.init(keysize);
|
kg.init(keysize);
|
||||||
Key generatedKey = kg.generateKey();
|
Key generatedKey = kg.generateKey();
|
||||||
int actualSizeInBits = generatedKey.getEncoded().length*8;
|
int actualSizeInBits = generatedKey.getEncoded().length*8;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -40,7 +40,8 @@ public class DigestCloneabilityTest {
|
|||||||
// make SampleProvider the most preferred, so its digest impl is picked
|
// make SampleProvider the most preferred, so its digest impl is picked
|
||||||
int status = Security.insertProviderAt(p, 1);
|
int status = Security.insertProviderAt(p, 1);
|
||||||
try {
|
try {
|
||||||
Mac mac = Mac.getInstance(ALGO, "SunJCE");
|
Mac mac = Mac.getInstance(ALGO,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
// do a complete mac generation and check if the supplied
|
// do a complete mac generation and check if the supplied
|
||||||
// digest is used
|
// digest is used
|
||||||
mac.init(new SecretKeySpec(new byte[512>>3], ALGO));
|
mac.init(new SecretKeySpec(new byte[512>>3], ALGO));
|
||||||
@ -72,7 +73,8 @@ public class DigestCloneabilityTest {
|
|||||||
|
|
||||||
public CloneableDigest() throws NoSuchAlgorithmException {
|
public CloneableDigest() throws NoSuchAlgorithmException {
|
||||||
try {
|
try {
|
||||||
md = MessageDigest.getInstance("SHA-512", "SUN");
|
md = MessageDigest.getInstance("SHA-512",
|
||||||
|
System.getProperty("test.provider.name", "SUN"));
|
||||||
} catch (NoSuchProviderException nspe) {
|
} catch (NoSuchProviderException nspe) {
|
||||||
// should never happen
|
// should never happen
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -51,7 +51,8 @@ public class EmptyByteBufferTest implements MacTest {
|
|||||||
SecretKey key = Utils.getSecretKeySpec();
|
SecretKey key = Utils.getSecretKeySpec();
|
||||||
|
|
||||||
// instantiate Mac object and init it with a SecretKey
|
// instantiate Mac object and init it with a SecretKey
|
||||||
Mac mac = Mac.getInstance(alg, "SunJCE");
|
Mac mac = Mac.getInstance(alg,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
mac.init(key);
|
mac.init(key);
|
||||||
|
|
||||||
// prepare buffer
|
// prepare buffer
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -49,7 +49,8 @@ public class HmacPBESHA1 {
|
|||||||
};
|
};
|
||||||
private static final int[] MAC_LENGTHS = { 20, 20, 28, 32, 48, 64, 28, 32 };
|
private static final int[] MAC_LENGTHS = { 20, 20, 28, 32, 48, 64, 28, 32 };
|
||||||
private static final String KEY_ALGO = "PBE";
|
private static final String KEY_ALGO = "PBE";
|
||||||
private static final String PROVIDER = "SunJCE";
|
private static final String PROVIDER =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
|
||||||
private static SecretKey key = null;
|
private static SecretKey key = null;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -91,7 +91,8 @@ public class HmacSaltLengths {
|
|||||||
new SecureRandom().nextBytes(input);
|
new SecureRandom().nextBytes(input);
|
||||||
char[] PASSWD = { 'p','a','s','s','w','o','r','d' };
|
char[] PASSWD = { 'p','a','s','s','w','o','r','d' };
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Provider p = Security.getProvider("SunJCE");
|
Provider p = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + p.getName() + "...");
|
System.out.println("Testing provider " + p.getName() + "...");
|
||||||
for (String algo : ALGOS) {
|
for (String algo : ALGOS) {
|
||||||
runTest(algo, input, PASSWD, p);
|
runTest(algo, input, PASSWD, p);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -53,7 +53,8 @@ public class LargeByteBufferTest implements MacTest {
|
|||||||
SecretKey key = Utils.getSecretKeySpec();
|
SecretKey key = Utils.getSecretKeySpec();
|
||||||
|
|
||||||
// instantiate Mac object and init it with a SecretKey
|
// instantiate Mac object and init it with a SecretKey
|
||||||
Mac mac = Mac.getInstance(alg, "SunJCE");
|
Mac mac = Mac.getInstance(alg,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
mac.init(key);
|
mac.init(key);
|
||||||
|
|
||||||
// prepare buffer
|
// prepare buffer
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -64,7 +64,8 @@ public class MacClone {
|
|||||||
//
|
//
|
||||||
// Clone an uninitialized Mac object
|
// Clone an uninitialized Mac object
|
||||||
//
|
//
|
||||||
Mac mac = Mac.getInstance(algo, "SunJCE");
|
Mac mac = Mac.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
Mac macClone = (Mac)mac.clone();
|
Mac macClone = (Mac)mac.clone();
|
||||||
System.out.println(macClone.getProvider().toString());
|
System.out.println(macClone.getProvider().toString());
|
||||||
System.out.println(macClone.getAlgorithm());
|
System.out.println(macClone.getAlgorithm());
|
||||||
@ -81,7 +82,8 @@ public class MacClone {
|
|||||||
//
|
//
|
||||||
// Clone an initialized Mac object
|
// Clone an initialized Mac object
|
||||||
//
|
//
|
||||||
mac = Mac.getInstance(algo, "SunJCE");
|
mac = Mac.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
mac.init(skey, params);
|
mac.init(skey, params);
|
||||||
macClone = (Mac)mac.clone();
|
macClone = (Mac)mac.clone();
|
||||||
System.out.println(macClone.getProvider().toString());
|
System.out.println(macClone.getProvider().toString());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -333,7 +333,8 @@ public class MacKAT {
|
|||||||
|
|
||||||
static void runTests(Test[] tests) throws Exception {
|
static void runTests(Test[] tests) throws Exception {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Provider p = Security.getProvider("SunJCE");
|
Provider p = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
System.out.println("Testing provider " + p.getName() + "...");
|
System.out.println("Testing provider " + p.getName() + "...");
|
||||||
for (int i = 0; i < tests.length; i++) {
|
for (int i = 0; i < tests.length; i++) {
|
||||||
Test test = tests[i];
|
Test test = tests[i];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -63,7 +63,8 @@ public class MacSameTest implements MacTest {
|
|||||||
NoSuchProviderException, InvalidKeyException {
|
NoSuchProviderException, InvalidKeyException {
|
||||||
Mac mac;
|
Mac mac;
|
||||||
try {
|
try {
|
||||||
mac = Mac.getInstance(algo, "SunJCE");
|
mac = Mac.getInstance(algo,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
} catch (NoSuchAlgorithmException nsae) {
|
} catch (NoSuchAlgorithmException nsae) {
|
||||||
// depending on Solaris configuration,
|
// depending on Solaris configuration,
|
||||||
// it can support HMAC or not with Mac
|
// it can support HMAC or not with Mac
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -51,7 +51,8 @@ public class NullByteBufferTest implements MacTest {
|
|||||||
SecretKey key = Utils.getSecretKeySpec();
|
SecretKey key = Utils.getSecretKeySpec();
|
||||||
|
|
||||||
// instantiate Mac object and init it with a SecretKey
|
// instantiate Mac object and init it with a SecretKey
|
||||||
Mac mac = Mac.getInstance(alg, "SunJCE");
|
Mac mac = Mac.getInstance(alg,
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
mac.init(key);
|
mac.init(key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -51,7 +51,8 @@ import javax.crypto.spec.IvParameterSpec;
|
|||||||
*/
|
*/
|
||||||
public class TestAESOids {
|
public class TestAESOids {
|
||||||
|
|
||||||
private static final String PROVIDER_NAME = "SunJCE";
|
private static final String PROVIDER_NAME =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final byte[] INPUT = "1234567890123456".getBytes();
|
private static final byte[] INPUT = "1234567890123456".getBytes();
|
||||||
|
|
||||||
private static final List<DataTuple> DATA = Arrays.asList(
|
private static final List<DataTuple> DATA = Arrays.asList(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -46,7 +46,8 @@ import javax.crypto.SecretKey;
|
|||||||
*/
|
*/
|
||||||
public class TestAESWrapOids {
|
public class TestAESWrapOids {
|
||||||
|
|
||||||
private static final String PROVIDER_NAME = "SunJCE";
|
private static final String PROVIDER_NAME =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
|
|
||||||
private static final List<DataTuple> DATA = Arrays.asList(
|
private static final List<DataTuple> DATA = Arrays.asList(
|
||||||
new DataTuple("2.16.840.1.101.3.4.1.5", "AESWrap_128"),
|
new DataTuple("2.16.840.1.101.3.4.1.5", "AESWrap_128"),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,7 +41,8 @@ import javax.crypto.SecretKey;
|
|||||||
*/
|
*/
|
||||||
public class TestHmacSHAOids {
|
public class TestHmacSHAOids {
|
||||||
|
|
||||||
private static final String PROVIDER_NAME = "SunJCE";
|
private static final String PROVIDER_NAME =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
private static final byte[] INPUT = "1234567890".getBytes();
|
private static final byte[] INPUT = "1234567890".getBytes();
|
||||||
|
|
||||||
private static final List<DataTuple> DATA = Arrays.asList(
|
private static final List<DataTuple> DATA = Arrays.asList(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,7 +47,8 @@ public class TestKeyMaterial extends Utils {
|
|||||||
private static int PREFIX_LENGTH = "km-master: ".length();
|
private static int PREFIX_LENGTH = "km-master: ".length();
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
Provider provider = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
InputStream in = new FileInputStream(new File(BASE, "keymatdata.txt"));
|
InputStream in = new FileInputStream(new File(BASE, "keymatdata.txt"));
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,7 +47,8 @@ import javax.crypto.interfaces.*;
|
|||||||
|
|
||||||
public class TestLeadingZeroes {
|
public class TestLeadingZeroes {
|
||||||
|
|
||||||
private static final String SUNJCE = "SunJCE";
|
private static final String PROVIDER_NAME =
|
||||||
|
System.getProperty("test.provider.name", "SunJCE");
|
||||||
// Hex formatter to upper case with ":" delimiter
|
// Hex formatter to upper case with ":" delimiter
|
||||||
private static final HexFormat HEX_FORMATTER = HexFormat.ofDelimiter(":").withUpperCase();
|
private static final HexFormat HEX_FORMATTER = HexFormat.ofDelimiter(":").withUpperCase();
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ public class TestLeadingZeroes {
|
|||||||
kfac.generatePrivate(new PKCS8EncodedKeySpec(bobPrivKeyEnc));
|
kfac.generatePrivate(new PKCS8EncodedKeySpec(bobPrivKeyEnc));
|
||||||
|
|
||||||
// generate normal shared secret
|
// generate normal shared secret
|
||||||
KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH", SUNJCE);
|
KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH", PROVIDER_NAME);
|
||||||
aliceKeyAgree.init(alicePrivKey);
|
aliceKeyAgree.init(alicePrivKey);
|
||||||
aliceKeyAgree.doPhase(bobPubKey, true);
|
aliceKeyAgree.doPhase(bobPubKey, true);
|
||||||
byte[] sharedSecret = aliceKeyAgree.generateSecret();
|
byte[] sharedSecret = aliceKeyAgree.generateSecret();
|
||||||
|
@ -49,7 +49,8 @@ public class TestMasterSecret extends Utils {
|
|||||||
private static int PREFIX_LENGTH = "m-premaster: ".length();
|
private static int PREFIX_LENGTH = "m-premaster: ".length();
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
Provider provider = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
InputStream in = new FileInputStream(new File(BASE, "masterdata.txt"));
|
InputStream in = new FileInputStream(new File(BASE, "masterdata.txt"));
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,7 +47,8 @@ public class TestPRF extends Utils {
|
|||||||
private static int PREFIX_LENGTH = "prf-output: ".length();
|
private static int PREFIX_LENGTH = "prf-output: ".length();
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Provider provider = Security.getProvider("SunJCE");
|
Provider provider = Security.getProvider(
|
||||||
|
System.getProperty("test.provider.name", "SunJCE"));
|
||||||
|
|
||||||
InputStream in = new FileInputStream(new File(BASE, "prfdata.txt"));
|
InputStream in = new FileInputStream(new File(BASE, "prfdata.txt"));
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user