# HG changeset patch # User valeriep # Date 1490839160 0 # Node ID b9015c99d2dd0485cdc2ba9443bafb0154950bc8 # Parent dcdb2e744a5408d072f81be21fab03db8e9ed469 8176760: Better handling of PKCS8 material Reviewed-by: ascarpino, ahgross diff -r dcdb2e744a54 -r b9015c99d2dd jdk/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java --- a/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java Fri Mar 24 15:41:33 2017 -0400 +++ b/jdk/src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java Thu Mar 30 01:59:20 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, 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 @@ -32,6 +32,7 @@ import java.security.KeyRep; import java.security.PrivateKey; import java.security.KeyFactory; +import java.security.MessageDigest; import java.security.Security; import java.security.Provider; import java.security.InvalidKeyException; @@ -419,18 +420,9 @@ // that encoding byte[] b2 = ((Key)object).getEncoded(); - // do the comparison - int i; - if (b1.length != b2.length) - return false; - for (i = 0; i < b1.length; i++) { - if (b1[i] != b2[i]) { - return false; - } - } - return true; + // time-constant comparison + return MessageDigest.isEqual(b1, b2); } - return false; }