RawRSAPrivateCrtKey(final RSAPrivateCrtKey original) { super(original); publicExponent = original.getPublicExponent(); primeP = original.getPrimeP(); primeQ = original.getPrimeQ(); primeExponentP = original.getPrimeExponentP(); primeExponentQ = original.getPrimeExponentQ(); crtCoefficient = original.getCrtCoefficient(); }
RawRSAPrivateKey(final RSAPrivateKey original) { super(original); privateExponent = original.getPrivateExponent(); modulus = original.getModulus(); }
@Override protected void writePubKeyContentsIntoBuffer(PublicKey pk, Buffer<?> buf) { final RSAPublicKey rsaKey = (RSAPublicKey) pk; buf.putMPInt(rsaKey.getPublicExponent()) // e .putMPInt(rsaKey.getModulus()); // n }
/** * Get the key size for the given {@code Key}. * * @param key the key * @return the key size or -1 if the key size cannot be determined */ public static int getKeySize(final Key key) { if (key instanceof ECKey) { ECParameterSpec params = ((ECKey) key).getParams(); if (params != null) { return params.getOrder().bitLength(); } } else if (key instanceof DSAKey) { DSAParams params = ((DSAKey) key).getParams(); if (params != null) { return params.getP().bitLength(); } } else if (key instanceof RSAKey) { return ((RSAKey) key).getModulus().bitLength(); } return -1; }
String generateDSAPublicKey() { DSAPublicKey pub = (DSAPublicKey) cert.getPublicKey(); StringBuilder builder = new StringBuilder(); append(builder, NLS.str("certificate.serialPubKeyType"), pub.getAlgorithm()); append(builder, NLS.str("certificate.serialPubKeyY"), pub.getY().toString(10)); return builder.toString(); }
@Override public ECPoint getW() { return this.getKey().getW(); }
@Override public String toString() { return "RsaCipher [privateKey=" + new String(privateKey.getEncoded()) + ", publicKey=" + new String(publicKey.getEncoded()) + "]"; }
@Override public BigInteger getS() { return this.getKey().getS(); }
public CombinedCipherInputStream(InputStream in, RSAKey key, String algorithm) throws IOException, GeneralSecurityException { this(in,toCipher(key,Cipher.DECRYPT_MODE),algorithm,key.getModulus().bitLength()); } }
RawRSAMultiPrimePrivateCrtKey(final RSAMultiPrimePrivateCrtKey original) { super(original); publicExponent = original.getPublicExponent(); primeP = original.getPrimeP(); primeQ = original.getPrimeQ(); primeExponentP = original.getPrimeExponentP(); primeExponentQ = original.getPrimeExponentQ(); crtCoefficient = original.getCrtCoefficient(); final RSAOtherPrimeInfo[] otherPrimeInfo = original.getOtherPrimeInfo(); this.otherPrimeInfo = otherPrimeInfo == null ? null : otherPrimeInfo.clone(); }
/** * Gets base64-encoded public key. */ public String getEncodedPublicKey() { return new String(Base64.encodeBase64(getPublicKey().getEncoded())); } }
@Override public ECParameterSpec getParams() { return this.key.getParams(); }
@Override public String getAlgorithm() { return this.getKey().getAlgorithm(); }
@Override public String getAlgorithm() { return this.getKey().getAlgorithm(); }
@Override public String getFormat() { return this.getKey().getFormat(); }
@Override public byte[] getEncoded() { return this.getKey().getEncoded(); }
/** * Construct a new instance. * * @param rsaKey the RSA key from which the modulus should be acquired (must not be {@code null}) */ public RSAParameterSpec(final RSAKey rsaKey) { this(Assert.checkNotNullParam("rsaKey", rsaKey).getModulus()); }