Search in sources :

Example 1 with JDKDSAPrivateKey

use of org.bouncycastle.jce.provider.JDKDSAPrivateKey in project keystore-explorer by kaikramer.

the class KeyStoreState method isEntryPrivateKeyEqual.

protected boolean isEntryPrivateKeyEqual(KeyStoreState targetState, String alias, Password password) throws GeneralSecurityException {
    Key currentKey = keyStore.getKey(alias, password.toCharArray());
    Key targetKey = targetState.getKeyStore().getKey(alias, password.toCharArray());
    // JDKDSAPrivateKey has no equals method defined
    if ((currentKey instanceof JDKDSAPrivateKey) || (targetKey instanceof JDKDSAPrivateKey)) {
        DSAPrivateKey currentDsaKey = (DSAPrivateKey) currentKey;
        DSAPrivateKey targetDsaKey = (DSAPrivateKey) targetKey;
        return currentDsaKey.getX().equals(targetDsaKey.getX()) && currentDsaKey.getParams().getG().equals(targetDsaKey.getParams().getG()) && currentDsaKey.getParams().getP().equals(targetDsaKey.getParams().getP()) && currentDsaKey.getParams().getQ().equals(targetDsaKey.getParams().getQ());
    } else {
        return currentKey.equals(targetKey);
    }
}
Also used : JDKDSAPrivateKey(org.bouncycastle.jce.provider.JDKDSAPrivateKey) DSAPrivateKey(java.security.interfaces.DSAPrivateKey) Key(java.security.Key) JDKDSAPrivateKey(org.bouncycastle.jce.provider.JDKDSAPrivateKey) DSAPrivateKey(java.security.interfaces.DSAPrivateKey) JDKDSAPrivateKey(org.bouncycastle.jce.provider.JDKDSAPrivateKey)

Aggregations

Key (java.security.Key)1 DSAPrivateKey (java.security.interfaces.DSAPrivateKey)1 JDKDSAPrivateKey (org.bouncycastle.jce.provider.JDKDSAPrivateKey)1