mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8172366: Support SHA-3 based signatures
Enhance default JDK providers including SUN, SunRsaSign, and SunEC, with signatures using SHA-3 family of digests. Reviewed-by: xuelei
This commit is contained in:
parent
46598c8644
commit
40206822f4
20 changed files with 673 additions and 95 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -108,6 +108,34 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec {
|
|||
public static final MGF1ParameterSpec SHA512_256 =
|
||||
new MGF1ParameterSpec("SHA-512/256");
|
||||
|
||||
/**
|
||||
* The MGF1ParameterSpec which uses SHA3-224 message digest
|
||||
* @since 16
|
||||
*/
|
||||
public static final MGF1ParameterSpec SHA3_224 =
|
||||
new MGF1ParameterSpec("SHA3-224");
|
||||
|
||||
/**
|
||||
* The MGF1ParameterSpec which uses SHA3-256 message digest
|
||||
* @since 16
|
||||
*/
|
||||
public static final MGF1ParameterSpec SHA3_256 =
|
||||
new MGF1ParameterSpec("SHA3-256");
|
||||
|
||||
/**
|
||||
* The MGF1ParameterSpec which uses SHA3-384 message digest
|
||||
* @since 16
|
||||
*/
|
||||
public static final MGF1ParameterSpec SHA3_384 =
|
||||
new MGF1ParameterSpec("SHA3-384");
|
||||
|
||||
/**
|
||||
* The MGF1ParameterSpec which uses SHA3-512 message digest
|
||||
* @since 16
|
||||
*/
|
||||
public static final MGF1ParameterSpec SHA3_512 =
|
||||
new MGF1ParameterSpec("SHA3-512");
|
||||
|
||||
private String mdName;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -47,11 +47,16 @@ import sun.security.jca.JCAUtil;
|
|||
* Standards and Technology (NIST), using SHA digest algorithms
|
||||
* from FIPS180-3.
|
||||
*
|
||||
* This file contains both the signature implementation for the
|
||||
* commonly used SHA1withDSA (DSS), SHA224withDSA, SHA256withDSA,
|
||||
* as well as RawDSA, used by TLS among others. RawDSA expects
|
||||
* the 20 byte SHA-1 digest as input via update rather than the
|
||||
* original data like other signature implementations.
|
||||
* This file contains the signature implementation for the
|
||||
* SHA1withDSA (DSS), SHA224withDSA, SHA256withDSA, SHA384withDSA,
|
||||
* SHA512withDSA, SHA3-224withDSA, SHA3-256withDSA, SHA3-384withDSA,
|
||||
* SHA3-512withDSA, as well as RawDSA, used by TLS among others.
|
||||
* RawDSA expects the 20 byte SHA-1 digest as input via update rather
|
||||
* than the original data like other signature implementations.
|
||||
*
|
||||
* In addition, IEEE P1363 signature format is supported. The
|
||||
* corresponding implementation is registered under <sig>inP1363Format,
|
||||
* e.g. SHA256withDSAinP1363Format.
|
||||
*
|
||||
* @author Benjamin Renaud
|
||||
*
|
||||
|
@ -504,6 +509,78 @@ abstract class DSA extends SignatureSpi {
|
|||
return printable;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA3-224withDSA implementation.
|
||||
*/
|
||||
public static final class SHA3_224withDSA extends DSA {
|
||||
public SHA3_224withDSA() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA3-224"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA3-224withDSA implementation that uses the IEEE P1363 format.
|
||||
*/
|
||||
public static final class SHA3_224withDSAinP1363Format extends DSA {
|
||||
public SHA3_224withDSAinP1363Format() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA3-224"), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA3-256withDSA implementation.
|
||||
*/
|
||||
public static final class SHA3_256withDSA extends DSA {
|
||||
public SHA3_256withDSA() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA3-256"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA3-256withDSA implementation that uses the IEEE P1363 format.
|
||||
*/
|
||||
public static final class SHA3_256withDSAinP1363Format extends DSA {
|
||||
public SHA3_256withDSAinP1363Format() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA3-256"), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA3-384withDSA implementation.
|
||||
*/
|
||||
public static final class SHA3_384withDSA extends DSA {
|
||||
public SHA3_384withDSA() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA3-384"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA3-384withDSA implementation that uses the IEEE P1363 format.
|
||||
*/
|
||||
public static final class SHA3_384withDSAinP1363Format extends DSA {
|
||||
public SHA3_384withDSAinP1363Format() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA3-384"), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA3-512withDSA implementation.
|
||||
*/
|
||||
public static final class SHA3_512withDSA extends DSA {
|
||||
public SHA3_512withDSA() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA3-512"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA3-512withDSA implementation that uses the IEEE P1363 format.
|
||||
*/
|
||||
public static final class SHA3_512withDSAinP1363Format extends DSA {
|
||||
public SHA3_512withDSAinP1363Format() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA3-512"), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA224withDSA implementation as defined in FIPS186-3.
|
||||
*/
|
||||
|
@ -540,6 +617,42 @@ abstract class DSA extends SignatureSpi {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA384withDSA implementation as defined in FIPS186-3.
|
||||
*/
|
||||
public static final class SHA384withDSA extends DSA {
|
||||
public SHA384withDSA() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA-384"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA384withDSA implementation that uses the IEEE P1363 format.
|
||||
*/
|
||||
public static final class SHA384withDSAinP1363Format extends DSA {
|
||||
public SHA384withDSAinP1363Format() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA-384"), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA512withDSA implementation as defined in FIPS186-3.
|
||||
*/
|
||||
public static final class SHA512withDSA extends DSA {
|
||||
public SHA512withDSA() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA-512"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA512withDSA implementation that uses the IEEE P1363 format.
|
||||
*/
|
||||
public static final class SHA512withDSAinP1363Format extends DSA {
|
||||
public SHA512withDSAinP1363Format() throws NoSuchAlgorithmException {
|
||||
super(MessageDigest.getInstance("SHA-512"), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard SHA1withDSA implementation.
|
||||
*/
|
||||
|
|
|
@ -54,9 +54,13 @@ import static sun.security.util.SecurityProviderConstants.getAliases;
|
|||
* SHA-2 family of hash functions includes SHA-224, SHA-256, SHA-384,
|
||||
* and SHA-512.
|
||||
*
|
||||
* - SHA-224withDSA/SHA-256withDSA are the signature schemes
|
||||
* - [SHA-224|SHA-256|SHA-384|SHA-512]withDSA are the signature schemes
|
||||
* described in FIPS 186-3. The associated object identifiers are
|
||||
* "OID.2.16.840.1.101.3.4.3.1", and "OID.2.16.840.1.101.3.4.3.2".
|
||||
* "OID.2.16.840.1.101.3.4.3.[1|2|3|4]" respectively.
|
||||
*
|
||||
* - [SHA3-224|SHA3-256|SHA3-384|SHA3-512]withDSA are the signature schemes
|
||||
* using SHA-3 family of digests with DSA. The associated object identifiers
|
||||
* are "OID.2.16.840.1.101.3.4.3.[5|6|7|8]" respectively.
|
||||
*
|
||||
* - DSA is the key generation scheme as described in FIPS 186.
|
||||
* Aliases for DSA include the OID strings "OID.1.3.14.3.2.12"
|
||||
|
@ -127,13 +131,30 @@ public final class SunEntries {
|
|||
addWithAlias(p, "Signature", "NONEwithDSA",
|
||||
"sun.security.provider.DSA$RawDSA", attrs);
|
||||
|
||||
attrs.put("KeySize", "2048"); // for SHA224 and SHA256 DSA signatures
|
||||
// for DSA signatures with 224/256-bit digests
|
||||
attrs.put("KeySize", "2048");
|
||||
|
||||
addWithAlias(p, "Signature", "SHA224withDSA",
|
||||
"sun.security.provider.DSA$SHA224withDSA", attrs);
|
||||
addWithAlias(p, "Signature", "SHA256withDSA",
|
||||
"sun.security.provider.DSA$SHA256withDSA", attrs);
|
||||
|
||||
addWithAlias(p, "Signature", "SHA3-224withDSA",
|
||||
"sun.security.provider.DSA$SHA3_224withDSA", attrs);
|
||||
addWithAlias(p, "Signature", "SHA3-256withDSA",
|
||||
"sun.security.provider.DSA$SHA3_256withDSA", attrs);
|
||||
|
||||
attrs.put("KeySize", "3072"); // for DSA sig using 384/512-bit digests
|
||||
|
||||
addWithAlias(p, "Signature", "SHA384withDSA",
|
||||
"sun.security.provider.DSA$SHA384withDSA", attrs);
|
||||
addWithAlias(p, "Signature", "SHA512withDSA",
|
||||
"sun.security.provider.DSA$SHA512withDSA", attrs);
|
||||
addWithAlias(p, "Signature", "SHA3-384withDSA",
|
||||
"sun.security.provider.DSA$SHA3_384withDSA", attrs);
|
||||
addWithAlias(p, "Signature", "SHA3-512withDSA",
|
||||
"sun.security.provider.DSA$SHA3_512withDSA", attrs);
|
||||
|
||||
attrs.remove("KeySize");
|
||||
|
||||
add(p, "Signature", "SHA1withDSAinP1363Format",
|
||||
|
@ -144,7 +165,18 @@ public final class SunEntries {
|
|||
"sun.security.provider.DSA$SHA224withDSAinP1363Format");
|
||||
add(p, "Signature", "SHA256withDSAinP1363Format",
|
||||
"sun.security.provider.DSA$SHA256withDSAinP1363Format");
|
||||
|
||||
add(p, "Signature", "SHA384withDSAinP1363Format",
|
||||
"sun.security.provider.DSA$SHA384withDSAinP1363Format");
|
||||
add(p, "Signature", "SHA512withDSAinP1363Format",
|
||||
"sun.security.provider.DSA$SHA512withDSAinP1363Format");
|
||||
add(p, "Signature", "SHA3-224withDSAinP1363Format",
|
||||
"sun.security.provider.DSA$SHA3_224withDSAinP1363Format");
|
||||
add(p, "Signature", "SHA3-256withDSAinP1363Format",
|
||||
"sun.security.provider.DSA$SHA3_256withDSAinP1363Format");
|
||||
add(p, "Signature", "SHA3-384withDSAinP1363Format",
|
||||
"sun.security.provider.DSA$SHA3_384withDSAinP1363Format");
|
||||
add(p, "Signature", "SHA3-512withDSAinP1363Format",
|
||||
"sun.security.provider.DSA$SHA3_512withDSAinP1363Format");
|
||||
/*
|
||||
* Key Pair Generator engines
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -103,7 +103,7 @@ public final class PSSParameters extends AlgorithmParametersSpi {
|
|||
throw new IOException("Only MGF1 mgf is supported");
|
||||
}
|
||||
AlgorithmId params = AlgorithmId.parse(
|
||||
new DerValue(val.getEncodedParams()));
|
||||
new DerValue(val.getEncodedParams()));
|
||||
String mgfDigestName = params.getName();
|
||||
switch (mgfDigestName) {
|
||||
case "SHA-1":
|
||||
|
@ -127,6 +127,18 @@ public final class PSSParameters extends AlgorithmParametersSpi {
|
|||
case "SHA-512/256":
|
||||
mgfSpec = MGF1ParameterSpec.SHA512_256;
|
||||
break;
|
||||
case "SHA3-224":
|
||||
mgfSpec = MGF1ParameterSpec.SHA3_224;
|
||||
break;
|
||||
case "SHA3-256":
|
||||
mgfSpec = MGF1ParameterSpec.SHA3_256;
|
||||
break;
|
||||
case "SHA3-384":
|
||||
mgfSpec = MGF1ParameterSpec.SHA3_384;
|
||||
break;
|
||||
case "SHA3-512":
|
||||
mgfSpec = MGF1ParameterSpec.SHA3_512;
|
||||
break;
|
||||
default:
|
||||
throw new IOException
|
||||
("Unrecognized message digest algorithm " +
|
||||
|
|
|
@ -45,8 +45,8 @@ import sun.security.jca.JCAUtil;
|
|||
* PKCS#1 v2.2 RSASSA-PSS signatures with various message digest algorithms.
|
||||
* RSASSA-PSS implementation takes the message digest algorithm, MGF algorithm,
|
||||
* and salt length values through the required signature PSS parameters.
|
||||
* We support SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and
|
||||
* SHA-512/256 message digest algorithms and MGF1 mask generation function.
|
||||
* We support SHA-1, SHA-2 family and SHA3 family of message digest algorithms,
|
||||
* and MGF1 mask generation function.
|
||||
*
|
||||
* @since 11
|
||||
*/
|
||||
|
@ -81,24 +81,20 @@ public class RSAPSSSignature extends SignatureSpi {
|
|||
|
||||
private static final byte[] EIGHT_BYTES_OF_ZEROS = new byte[8];
|
||||
|
||||
private static final Hashtable<String, Integer> DIGEST_LENGTHS =
|
||||
new Hashtable<String, Integer>();
|
||||
private static final Hashtable<KnownOIDs, Integer> DIGEST_LENGTHS =
|
||||
new Hashtable<KnownOIDs, Integer>();
|
||||
static {
|
||||
DIGEST_LENGTHS.put("SHA-1", 20);
|
||||
DIGEST_LENGTHS.put("SHA", 20);
|
||||
DIGEST_LENGTHS.put("SHA1", 20);
|
||||
DIGEST_LENGTHS.put("SHA-224", 28);
|
||||
DIGEST_LENGTHS.put("SHA224", 28);
|
||||
DIGEST_LENGTHS.put("SHA-256", 32);
|
||||
DIGEST_LENGTHS.put("SHA256", 32);
|
||||
DIGEST_LENGTHS.put("SHA-384", 48);
|
||||
DIGEST_LENGTHS.put("SHA384", 48);
|
||||
DIGEST_LENGTHS.put("SHA-512", 64);
|
||||
DIGEST_LENGTHS.put("SHA512", 64);
|
||||
DIGEST_LENGTHS.put("SHA-512/224", 28);
|
||||
DIGEST_LENGTHS.put("SHA512/224", 28);
|
||||
DIGEST_LENGTHS.put("SHA-512/256", 32);
|
||||
DIGEST_LENGTHS.put("SHA512/256", 32);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA_1, 20);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA_224, 28);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA_256, 32);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA_384, 48);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA_512, 64);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA_512$224, 28);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA_512$256, 32);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA3_224, 28);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA3_256, 32);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA3_384, 48);
|
||||
DIGEST_LENGTHS.put(KnownOIDs.SHA3_512, 64);
|
||||
}
|
||||
|
||||
// message digest implementation we use for hashing the data
|
||||
|
@ -210,27 +206,33 @@ public class RSAPSSSignature extends SignatureSpi {
|
|||
* internal signature parameters.
|
||||
*/
|
||||
private RSAKey isValid(RSAKey rsaKey) throws InvalidKeyException {
|
||||
try {
|
||||
AlgorithmParameterSpec keyParams = rsaKey.getParams();
|
||||
// validate key parameters
|
||||
if (!isCompatible(rsaKey.getParams(), this.sigParams)) {
|
||||
throw new InvalidKeyException
|
||||
("Key contains incompatible PSS parameter values");
|
||||
}
|
||||
// validate key length
|
||||
if (this.sigParams != null) {
|
||||
Integer hLen =
|
||||
DIGEST_LENGTHS.get(this.sigParams.getDigestAlgorithm());
|
||||
if (hLen == null) {
|
||||
throw new ProviderException("Unsupported digest algo: " +
|
||||
this.sigParams.getDigestAlgorithm());
|
||||
}
|
||||
checkKeyLength(rsaKey, hLen, this.sigParams.getSaltLength());
|
||||
}
|
||||
return rsaKey;
|
||||
} catch (SignatureException e) {
|
||||
throw new InvalidKeyException(e);
|
||||
AlgorithmParameterSpec keyParams = rsaKey.getParams();
|
||||
// validate key parameters
|
||||
if (!isCompatible(rsaKey.getParams(), this.sigParams)) {
|
||||
throw new InvalidKeyException
|
||||
("Key contains incompatible PSS parameter values");
|
||||
}
|
||||
// validate key length
|
||||
if (this.sigParams != null) {
|
||||
String digestAlgo = this.sigParams.getDigestAlgorithm();
|
||||
KnownOIDs ko = KnownOIDs.findMatch(digestAlgo);
|
||||
if (ko != null) {
|
||||
Integer hLen = DIGEST_LENGTHS.get(ko);
|
||||
if (hLen != null) {
|
||||
checkKeyLength(rsaKey, hLen,
|
||||
this.sigParams.getSaltLength());
|
||||
} else {
|
||||
// should never happen; checked in validateSigParams()
|
||||
throw new ProviderException
|
||||
("Unsupported digest algo: " + digestAlgo);
|
||||
}
|
||||
} else {
|
||||
// should never happen; checked in validateSigParams()
|
||||
throw new ProviderException
|
||||
("Unrecognized digest algo: " + digestAlgo);
|
||||
}
|
||||
}
|
||||
return rsaKey;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,14 +270,26 @@ public class RSAPSSSignature extends SignatureSpi {
|
|||
("Only supports TrailerFieldBC(1)");
|
||||
|
||||
}
|
||||
String digestAlgo = params.getDigestAlgorithm();
|
||||
|
||||
// check key length again
|
||||
if (key != null) {
|
||||
try {
|
||||
int hLen = DIGEST_LENGTHS.get(digestAlgo);
|
||||
checkKeyLength(key, hLen, params.getSaltLength());
|
||||
} catch (SignatureException e) {
|
||||
throw new InvalidAlgorithmParameterException(e);
|
||||
String digestAlgo = params.getDigestAlgorithm();
|
||||
KnownOIDs ko = KnownOIDs.findMatch(digestAlgo);
|
||||
if (ko != null) {
|
||||
Integer hLen = DIGEST_LENGTHS.get(ko);
|
||||
if (hLen != null) {
|
||||
try {
|
||||
checkKeyLength(key, hLen, params.getSaltLength());
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new InvalidAlgorithmParameterException(e);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("Unsupported digest algo: " + digestAlgo);
|
||||
}
|
||||
} else {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("Unrecognized digest algo: " + digestAlgo);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
|
@ -302,12 +316,12 @@ public class RSAPSSSignature extends SignatureSpi {
|
|||
* salt length
|
||||
*/
|
||||
private static void checkKeyLength(RSAKey key, int digestLen,
|
||||
int saltLen) throws SignatureException {
|
||||
int saltLen) throws InvalidKeyException {
|
||||
if (key != null) {
|
||||
int keyLength = (getKeyLengthInBits(key) + 7) >> 3;
|
||||
int minLength = Math.addExact(Math.addExact(digestLen, saltLen), 2);
|
||||
if (keyLength < minLength) {
|
||||
throw new SignatureException
|
||||
throw new InvalidKeyException
|
||||
("Key is too short, need min " + minLength + " bytes");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -40,8 +40,9 @@ import sun.security.x509.AlgorithmId;
|
|||
* PKCS#1 v1.5 RSA signatures with the various message digest algorithms.
|
||||
* This file contains an abstract base class with all the logic plus
|
||||
* a nested static class for each of the message digest algorithms
|
||||
* (see end of the file). We support MD2, MD5, SHA-1, SHA-224, SHA-256,
|
||||
* SHA-384, SHA-512, SHA-512/224, and SHA-512/256.
|
||||
* (see end of the file). We support MD2, MD5, SHA-1, SHA2 family (
|
||||
* SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256),
|
||||
* and SHA3 family (SHA3-224, SHA3-256, SHA3-384, SHA3-512) of digests.
|
||||
*
|
||||
* @since 1.5
|
||||
* @author Andreas Sterbenz
|
||||
|
@ -360,4 +361,32 @@ public abstract class RSASignature extends SignatureSpi {
|
|||
super("SHA-512/256", AlgorithmId.SHA512_256_oid, 11);
|
||||
}
|
||||
}
|
||||
|
||||
// Nested class for SHA3-224withRSA signatures
|
||||
public static final class SHA3_224withRSA extends RSASignature {
|
||||
public SHA3_224withRSA() {
|
||||
super("SHA3-224", AlgorithmId.SHA3_224_oid, 11);
|
||||
}
|
||||
}
|
||||
|
||||
// Nested class for SHA3-256withRSA signatures
|
||||
public static final class SHA3_256withRSA extends RSASignature {
|
||||
public SHA3_256withRSA() {
|
||||
super("SHA3-256", AlgorithmId.SHA3_256_oid, 11);
|
||||
}
|
||||
}
|
||||
|
||||
// Nested class for SHA3-384withRSA signatures
|
||||
public static final class SHA3_384withRSA extends RSASignature {
|
||||
public SHA3_384withRSA() {
|
||||
super("SHA3-384", AlgorithmId.SHA3_384_oid, 11);
|
||||
}
|
||||
}
|
||||
|
||||
// Nested class for SHA3-512withRSA signatures
|
||||
public static final class SHA3_512withRSA extends RSASignature {
|
||||
public SHA3_512withRSA() {
|
||||
super("SHA3-512", AlgorithmId.SHA3_512_oid, 11);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,14 @@ public final class SunRsaSignEntries {
|
|||
"sun.security.rsa.RSASignature$SHA512_224withRSA", attrs);
|
||||
addA(p, "Signature", "SHA512/256withRSA",
|
||||
"sun.security.rsa.RSASignature$SHA512_256withRSA", attrs);
|
||||
addA(p, "Signature", "SHA3-224withRSA",
|
||||
"sun.security.rsa.RSASignature$SHA3_224withRSA", attrs);
|
||||
addA(p, "Signature", "SHA3-256withRSA",
|
||||
"sun.security.rsa.RSASignature$SHA3_256withRSA", attrs);
|
||||
addA(p, "Signature", "SHA3-384withRSA",
|
||||
"sun.security.rsa.RSASignature$SHA3_384withRSA", attrs);
|
||||
addA(p, "Signature", "SHA3-512withRSA",
|
||||
"sun.security.rsa.RSASignature$SHA3_512withRSA", attrs);
|
||||
|
||||
addA(p, "KeyFactory", "RSASSA-PSS",
|
||||
"sun.security.rsa.RSAKeyFactory$PSS", attrs);
|
||||
|
@ -92,7 +100,7 @@ public final class SunRsaSignEntries {
|
|||
addA(p, "Signature", "RSASSA-PSS",
|
||||
"sun.security.rsa.RSAPSSSignature", attrs);
|
||||
addA(p, "AlgorithmParameters", "RSASSA-PSS",
|
||||
"sun.security.rsa.PSSParameters", attrs);
|
||||
"sun.security.rsa.PSSParameters", null);
|
||||
}
|
||||
|
||||
public Iterator<Provider.Service> iterator() {
|
||||
|
|
|
@ -154,6 +154,14 @@ public enum KnownOIDs {
|
|||
SHA256withDSA("2.16.840.1.101.3.4.3.2"),
|
||||
SHA384withDSA("2.16.840.1.101.3.4.3.3"),
|
||||
SHA512withDSA("2.16.840.1.101.3.4.3.4"),
|
||||
SHA3_224withDSA("2.16.840.1.101.3.4.3.5", "SHA3-224withDSA"),
|
||||
SHA3_256withDSA("2.16.840.1.101.3.4.3.6", "SHA3-256withDSA"),
|
||||
SHA3_384withDSA("2.16.840.1.101.3.4.3.7", "SHA3-384withDSA"),
|
||||
SHA3_512withDSA("2.16.840.1.101.3.4.3.8", "SHA3-512withDSA"),
|
||||
SHA3_224withECDSA("2.16.840.1.101.3.4.3.9", "SHA3-224withECDSA"),
|
||||
SHA3_256withECDSA("2.16.840.1.101.3.4.3.10", "SHA3-256withECDSA"),
|
||||
SHA3_384withECDSA("2.16.840.1.101.3.4.3.11", "SHA3-384withECDSA"),
|
||||
SHA3_512withECDSA("2.16.840.1.101.3.4.3.12", "SHA3-512withECDSA"),
|
||||
SHA3_224withRSA("2.16.840.1.101.3.4.3.13", "SHA3-224withRSA"),
|
||||
SHA3_256withRSA("2.16.840.1.101.3.4.3.14", "SHA3-256withRSA"),
|
||||
SHA3_384withRSA("2.16.840.1.101.3.4.3.15", "SHA3-384withRSA"),
|
||||
|
@ -429,9 +437,9 @@ public enum KnownOIDs {
|
|||
if (debug != null) {
|
||||
debug.println("Setting up name2enum:");
|
||||
}
|
||||
List.of(KnownOIDs.values()).forEach(o -> {
|
||||
for (KnownOIDs o : KnownOIDs.values()) {
|
||||
register(o);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
private static void register(KnownOIDs o) {
|
||||
|
|
|
@ -196,6 +196,10 @@ public class AlgorithmId implements Serializable, DerEncoder {
|
|||
algid.equals((Object)SHA512_oid) ||
|
||||
algid.equals((Object)SHA512_224_oid) ||
|
||||
algid.equals((Object)SHA512_256_oid) ||
|
||||
algid.equals((Object)SHA3_224_oid) ||
|
||||
algid.equals((Object)SHA3_256_oid) ||
|
||||
algid.equals((Object)SHA3_384_oid) ||
|
||||
algid.equals((Object)SHA3_512_oid) ||
|
||||
algid.equals((Object)DSA_oid) ||
|
||||
algid.equals((Object)sha1WithDSA_oid)) {
|
||||
; // no parameter part encoded
|
||||
|
@ -608,6 +612,18 @@ public class AlgorithmId implements Serializable, DerEncoder {
|
|||
public static final ObjectIdentifier SHA512_256_oid =
|
||||
ObjectIdentifier.of(KnownOIDs.SHA_512$256);
|
||||
|
||||
public static final ObjectIdentifier SHA3_224_oid =
|
||||
ObjectIdentifier.of(KnownOIDs.SHA3_224);
|
||||
|
||||
public static final ObjectIdentifier SHA3_256_oid =
|
||||
ObjectIdentifier.of(KnownOIDs.SHA3_256);
|
||||
|
||||
public static final ObjectIdentifier SHA3_384_oid =
|
||||
ObjectIdentifier.of(KnownOIDs.SHA3_384);
|
||||
|
||||
public static final ObjectIdentifier SHA3_512_oid =
|
||||
ObjectIdentifier.of(KnownOIDs.SHA3_512);
|
||||
|
||||
public static final ObjectIdentifier DSA_oid =
|
||||
ObjectIdentifier.of(KnownOIDs.DSA);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue