org.spongycastle.crypto.params.RSAKeyParameters Java Examples

The following examples show how to use org.spongycastle.crypto.params.RSAKeyParameters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Cryptograph.java    From SightRemote with GNU General Public License v3.0 5 votes vote down vote up
public static KeyPair generateRSAKey() {
    RSAKeyPairGenerator generator = new RSAKeyPairGenerator();
    generator.init(new RSAKeyGenerationParameters(BigInteger.valueOf(65537), new SecureRandom(),2048, 8));
    AsymmetricCipherKeyPair ackp = generator.generateKeyPair();
    KeyPair keyPair = new KeyPair();
    keyPair.privateKey = (RSAPrivateCrtKeyParameters) ackp.getPrivate();
    keyPair.publicKey = (RSAKeyParameters) ackp.getPublic();
    return keyPair;
}
 
Example #2
Source File: Cryptograph.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
public static KeyPair generateRSAKey() {
    RSAKeyPairGenerator generator = new RSAKeyPairGenerator();
    generator.init(new RSAKeyGenerationParameters(BigInteger.valueOf(65537), new SecureRandom(), 2048, 8));
    AsymmetricCipherKeyPair ackp = generator.generateKeyPair();
    KeyPair keyPair = new KeyPair();
    keyPair.privateKey = (RSAPrivateCrtKeyParameters) ackp.getPrivate();
    keyPair.publicKey = (RSAKeyParameters) ackp.getPublic();
    return keyPair;
}
 
Example #3
Source File: PairingEstablisher.java    From SightRemote with GNU General Public License v3.0 4 votes vote down vote up
private static byte[] keyToBytes(RSAKeyParameters publicKey) {
    byte[] modulus = publicKey.getModulus().toByteArray();
    byte[] bytes = new byte[256];
    System.arraycopy(modulus, 1, bytes, 0, 256);
    return bytes;
}
 
Example #4
Source File: KeyPair.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
public RSAKeyParameters getPublicKey() {
    return this.publicKey;
}