提交 cead73cf 编写于 作者: I igerasim

8176760: Better handling of PKCS8 material

Reviewed-by: ascarpino, ahgross
上级 08b28be8
/* /*
* 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. * 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
...@@ -32,6 +32,7 @@ import java.security.Key; ...@@ -32,6 +32,7 @@ import java.security.Key;
import java.security.KeyRep; import java.security.KeyRep;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.MessageDigest;
import java.security.Security; import java.security.Security;
import java.security.Provider; import java.security.Provider;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
...@@ -420,18 +421,9 @@ public class PKCS8Key implements PrivateKey { ...@@ -420,18 +421,9 @@ public class PKCS8Key implements PrivateKey {
// that encoding // that encoding
byte[] b2 = ((Key)object).getEncoded(); byte[] b2 = ((Key)object).getEncoded();
// do the comparison // time-constant comparison
int i; return MessageDigest.isEqual(b1, b2);
if (b1.length != b2.length)
return false;
for (i = 0; i < b1.length; i++) {
if (b1[i] != b2[i]) {
return false;
}
}
return true;
} }
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册