Example usage for org.bouncycastle.bcpg RSAPublicBCPGKey RSAPublicBCPGKey

List of usage examples for org.bouncycastle.bcpg RSAPublicBCPGKey RSAPublicBCPGKey

Introduction

In this page you can find the example usage for org.bouncycastle.bcpg RSAPublicBCPGKey RSAPublicBCPGKey.

Prototype

public RSAPublicBCPGKey(BigInteger n, BigInteger e) 

Source Link

Usage

From source file:genkeys.java

License:Open Source License

private static PublicKeyPacket publicKeyPacket(PublicKey key, int algorithm, Date time) throws PGPException {
    BCPGKey bcpgKey;/*from   ww w  .  ja va 2s .co m*/
    if (key instanceof RSAPublicKey) {
        RSAPublicKey rK = (RSAPublicKey) key;
        bcpgKey = new RSAPublicBCPGKey(rK.getModulus(), rK.getPublicExponent());
    } else if (key instanceof DSAPublicKey) {
        DSAPublicKey dK = (DSAPublicKey) key;
        DSAParams dP = dK.getParams();
        bcpgKey = new DSAPublicBCPGKey(dP.getP(), dP.getQ(), dP.getG(), dK.getY());
    } else if (key instanceof ElGamalPublicKey) {
        ElGamalPublicKey eK = (ElGamalPublicKey) key;
        ElGamalParameterSpec eS = eK.getParameters();
        bcpgKey = new ElGamalPublicBCPGKey(eS.getP(), eS.getG(), eK.getY());
    } else {
        throw new PGPException("unknown key class");
    }

    return new PublicKeyPacket(algorithm, time, bcpgKey);
}

From source file:org.sufficientlysecure.keychain.support.KeyringBuilder.java

License:Open Source License

private static PublicKeyPacket createPgpPublicKey(BigInteger modulus) {
    return new PublicKeyPacket(PublicKeyAlgorithmTags.RSA_GENERAL, SIGNATURE_DATE,
            new RSAPublicBCPGKey(modulus, EXPONENT));
}

From source file:org.sufficientlysecure.keychain.support.KeyringBuilder.java

License:Open Source License

private static PublicKeyPacket createPgpPublicSubKey(BigInteger modulus) {
    return new PublicSubkeyPacket(PublicKeyAlgorithmTags.RSA_GENERAL, SIGNATURE_DATE,
            new RSAPublicBCPGKey(modulus, EXPONENT));
}