OpenJDK / jdk8u / jdk8u / jdk
changeset 12334:079cd6c5de27
8176760: Better handling of PKCS8 material
Reviewed-by: ascarpino, ahgross
author | igerasim |
---|---|
date | Thu, 30 Mar 2017 22:29:57 -0700 |
parents | 56e0ab47dbec |
children | e5e3c33f5736 |
files | src/share/classes/sun/security/pkcs/PKCS8Key.java |
diffstat | 1 files changed, 4 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/sun/security/pkcs/PKCS8Key.java Tue Mar 28 15:46:05 2017 +0100 +++ b/src/share/classes/sun/security/pkcs/PKCS8Key.java Thu Mar 30 22:29:57 2017 -0700 @@ -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; @@ -420,18 +421,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; }