mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8254717: isAssignableFrom checks in KeyFactorySpi.engineGetKeySpec appear to be backwards
Reviewed-by: jnimeh
This commit is contained in:
parent
d2c4ed08a2
commit
a777e82cd8
17 changed files with 136 additions and 63 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
|
@ -106,7 +106,7 @@ public final class DESKeyFactory extends SecretKeyFactorySpi {
|
|||
|
||||
// Check if requested key spec is amongst the valid ones
|
||||
if ((keySpec != null) &&
|
||||
DESKeySpec.class.isAssignableFrom(keySpec)) {
|
||||
keySpec.isAssignableFrom(DESKeySpec.class)) {
|
||||
return new DESKeySpec(key.getEncoded());
|
||||
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
|
@ -102,7 +102,7 @@ public final class DESedeKeyFactory extends SecretKeyFactorySpi {
|
|||
&& (key.getFormat().equalsIgnoreCase("RAW"))) {
|
||||
|
||||
// Check if requested key spec is amongst the valid ones
|
||||
if (DESedeKeySpec.class.isAssignableFrom(keySpec)) {
|
||||
if (keySpec.isAssignableFrom(DESedeKeySpec.class)) {
|
||||
return new DESedeKeySpec(key.getEncoded());
|
||||
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
|
@ -145,7 +145,7 @@ public final class DHKeyFactory extends KeyFactorySpi {
|
|||
|
||||
if (key instanceof javax.crypto.interfaces.DHPublicKey) {
|
||||
|
||||
if (DHPublicKeySpec.class.isAssignableFrom(keySpec)) {
|
||||
if (keySpec.isAssignableFrom(DHPublicKeySpec.class)) {
|
||||
javax.crypto.interfaces.DHPublicKey dhPubKey
|
||||
= (javax.crypto.interfaces.DHPublicKey) key;
|
||||
params = dhPubKey.getParams();
|
||||
|
@ -153,7 +153,7 @@ public final class DHKeyFactory extends KeyFactorySpi {
|
|||
params.getP(),
|
||||
params.getG()));
|
||||
|
||||
} else if (X509EncodedKeySpec.class.isAssignableFrom(keySpec)) {
|
||||
} else if (keySpec.isAssignableFrom(X509EncodedKeySpec.class)) {
|
||||
return keySpec.cast(new X509EncodedKeySpec(key.getEncoded()));
|
||||
|
||||
} else {
|
||||
|
@ -163,7 +163,7 @@ public final class DHKeyFactory extends KeyFactorySpi {
|
|||
|
||||
} else if (key instanceof javax.crypto.interfaces.DHPrivateKey) {
|
||||
|
||||
if (DHPrivateKeySpec.class.isAssignableFrom(keySpec)) {
|
||||
if (keySpec.isAssignableFrom(DHPrivateKeySpec.class)) {
|
||||
javax.crypto.interfaces.DHPrivateKey dhPrivKey
|
||||
= (javax.crypto.interfaces.DHPrivateKey)key;
|
||||
params = dhPrivKey.getParams();
|
||||
|
@ -171,7 +171,7 @@ public final class DHKeyFactory extends KeyFactorySpi {
|
|||
params.getP(),
|
||||
params.getG()));
|
||||
|
||||
} else if (PKCS8EncodedKeySpec.class.isAssignableFrom(keySpec)) {
|
||||
} else if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class)) {
|
||||
return keySpec.cast(new PKCS8EncodedKeySpec(key.getEncoded()));
|
||||
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue