...
Code Block |
---|
|
private static boolean keysEqual(Key key1, Key key2) {
if (key1.equals(key2)) {
return true;
}
if (Arrays.equals(key1.getEncoded(), key2.getEncoded())) {
return true;
}
// More code for different types of keys here
// For example, the following code can check whether
// an RSAPrivateKey and an RSAPrivateCrtKey are equal
if ((key1 instanceof RSAPrivateKey) &&
(key2 instanceof RSAPrivateKey)) {
if ((((RSAKey) key1).getModulus().equals(((RSAKey) key2).getModulus()))
&& (((RSAPrivateKey) key1).getPrivateExponent().equals(
((RSAPrivateKey) key2).getPrivateExponent()))) {
return true;
}
}
return false;
}
|
Automated Detection
...
Tool | Version | Checker | Description |
---|
The Checker Framework | Include Page |
---|
| The Checker Framework_V |
---|
| The Checker Framework_V |
---|
|
| Interning Checker | Errors in equality testing and interning (see Chapter 5) |
Bibliography
...
Image Modified Image Modified Image Modified