BCRSAPublicKey( SubjectPublicKeyInfo info) { try { org.spongycastle.asn1.pkcs.RSAPublicKey pubKey = org.spongycastle.asn1.pkcs.RSAPublicKey.getInstance(info.parsePublicKey()); this.modulus = pubKey.getModulus(); this.publicExponent = pubKey.getPublicExponent(); } catch (IOException e) { throw new IllegalArgumentException("invalid info structure in RSA public key"); } }
JCERSAPublicKey( SubjectPublicKeyInfo info) { try { org.spongycastle.asn1.pkcs.RSAPublicKey pubKey = org.spongycastle.asn1.pkcs.RSAPublicKey.getInstance(info.parsePublicKey()); this.modulus = pubKey.getModulus(); this.publicExponent = pubKey.getPublicExponent(); } catch (IOException e) { throw new IllegalArgumentException("invalid info structure in RSA public key"); } }
private AsymmetricBlockCipher getAsymmetricCipher( SecurityAlgorithm algorithm, RSAPublicKey publicKey) throws ServiceResultException { CipherParameters params = new RSAKeyParameters(false, publicKey.getModulus(), publicKey.getPublicExponent()); // logger.info("Cipher: \nmodulus={}, \npublicExponent={}\n", // publicKey.getModulus(), publicKey.getPublicExponent()); return getAsymmetricCipher(true, algorithm, params); }
private Signer getAsymmetricSigner(boolean forSigning, SecurityAlgorithm algorithm, RSAPublicKey publicKey) throws ServiceResultException { CipherParameters params = new RSAKeyParameters(false, publicKey.getModulus(), publicKey.getPublicExponent()); return getAsymmetricSigner(forSigning, algorithm, params); }
private void populateFromPublicKeyInfo(SubjectPublicKeyInfo info) { try { org.spongycastle.asn1.pkcs.RSAPublicKey pubKey = org.spongycastle.asn1.pkcs.RSAPublicKey.getInstance(info.parsePublicKey()); this.algorithmIdentifier = info.getAlgorithm(); this.modulus = pubKey.getModulus(); this.publicExponent = pubKey.getPublicExponent(); } catch (IOException e) { throw new IllegalArgumentException("invalid info structure in RSA public key"); } }
/** * This outputs the key in PKCS1v2 format. * <pre> * RSAPublicKey ::= SEQUENCE { * modulus INTEGER, -- n * publicExponent INTEGER, -- e * } * </pre> * <p> */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new ASN1Integer(getModulus())); v.add(new ASN1Integer(getPublicExponent())); return new DERSequence(v); } }
/** * This outputs the key in PKCS1v2 format. * <pre> * RSAPublicKey ::= SEQUENCE { * modulus INTEGER, -- n * publicExponent INTEGER, -- e * } * </pre> * <p> */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new ASN1Integer(getModulus())); v.add(new ASN1Integer(getPublicExponent())); return new DERSequence(v); } }
return new RSAKeyParameters(false, pubKey.getModulus(), pubKey.getPublicExponent());
return new RSAKeyParameters(false, pubKey.getModulus(), pubKey.getPublicExponent());