Code example for DHPrivateKey

Methods: getX

0
 
    protected byte[] getDigestedZZ(String otherPublicKeyBase64)
    { 
        DHPublicKey  dhPublicKey  = stringToPublicKey(otherPublicKeyBase64);
        DHPrivateKey dhPrivateKey = getPrivateKey();
        BigInteger xa = dhPrivateKey.getX();
        BigInteger yb = dhPublicKey.getY();
        BigInteger p  = _dhParameterSpec.getP();
 
        BigInteger zz = yb.modPow(xa, p);
 
        return _hDigest.digest(zz.toByteArray());
    } 
 
    private static boolean isDhSupported() 
    { 
        try 
        { 
            AlgorithmParameterGenerator.getInstance(ALGORITHM);
            KeyPairGenerator.getInstance(ALGORITHM);
            KeyFactory.getInstance(ALGORITHM);