List of usage examples for javax.crypto.interfaces DHPrivateKey getX
BigInteger getX();
x
. From source file:edu.internet2.middleware.openid.message.encoding.EncodingUtils.java
/** * Encode a DH private key./*from w w w.j ava2 s .com*/ * * @param privateKey DH private key to encode * @return encoded private key */ public static String encodePrivateKey(DHPrivateKey privateKey) { return new String(Base64.encodeBase64(privateKey.getX().toByteArray())); }
From source file:org.cesecore.keys.util.KeyTools.java
/** * Test if a private key is extractable (could be stored). * //from w w w . j ava2 s . c om * @param privK * key to test. * @return true if the key is extractable. */ public static boolean isPrivateKeyExtractable(final PrivateKey privK) { if (privK instanceof RSAPrivateKey) { final RSAPrivateKey rsa = (RSAPrivateKey) privK; final BigInteger result = rsa.getPrivateExponent(); return result != null && result.bitLength() > 0; } if (privK instanceof ECPrivateKey) { final ECPrivateKey ec = (ECPrivateKey) privK; final BigInteger result = ec.getS(); return result != null && result.bitLength() > 0; } if (privK instanceof DHPrivateKey) { final DHPrivateKey dh = (DHPrivateKey) privK; final BigInteger result = dh.getX(); return result != null && result.bitLength() > 0; } if (privK instanceof DSAPrivateKey) { final DSAPrivateKey dsa = (DSAPrivateKey) privK; final BigInteger result = dsa.getX(); return result != null && result.bitLength() > 0; } return false; }