List of usage examples for org.bouncycastle.asn1 DERSequence size
public int size()
From source file:org.jruby.ext.openssl.x509store.BouncyCastleASN1FormatHandler.java
License:LGPL
@Override public PrivateKey readRSAPrivateKey(String input) throws IOException, GeneralSecurityException { KeyFactory fact = KeyFactory.getInstance("RSA"); DERSequence seq = (DERSequence) (new ASN1InputStream(ByteList.plain(input)).readObject()); if (seq.size() == 9) { BigInteger mod = ((DERInteger) seq.getObjectAt(1)).getValue(); BigInteger pubexp = ((DERInteger) seq.getObjectAt(2)).getValue(); BigInteger privexp = ((DERInteger) seq.getObjectAt(3)).getValue(); BigInteger primep = ((DERInteger) seq.getObjectAt(4)).getValue(); BigInteger primeq = ((DERInteger) seq.getObjectAt(5)).getValue(); BigInteger primeep = ((DERInteger) seq.getObjectAt(6)).getValue(); BigInteger primeeq = ((DERInteger) seq.getObjectAt(7)).getValue(); BigInteger crtcoeff = ((DERInteger) seq.getObjectAt(8)).getValue(); return fact.generatePrivate( new RSAPrivateCrtKeySpec(mod, pubexp, privexp, primep, primeq, primeep, primeeq, crtcoeff)); } else {/*from w w w .ja v a2s . c o m*/ return null; } }
From source file:org.jruby.ext.openssl.x509store.BouncyCastleASN1FormatHandler.java
License:LGPL
@Override public PublicKey readRSAPublicKey(String input) throws IOException, GeneralSecurityException { KeyFactory fact = KeyFactory.getInstance("RSA"); DERSequence seq = (DERSequence) (new ASN1InputStream(ByteList.plain(input)).readObject()); if (seq.size() == 2) { BigInteger mod = ((DERInteger) seq.getObjectAt(0)).getValue(); BigInteger pubexp = ((DERInteger) seq.getObjectAt(1)).getValue(); return fact.generatePublic(new RSAPublicKeySpec(mod, pubexp)); } else {/*from ww w. j a va2s .com*/ return null; } }
From source file:org.jruby.ext.openssl.x509store.BouncyCastleASN1FormatHandler.java
License:LGPL
@Override public KeyPair readDSAPrivateKey(String input) throws IOException, GeneralSecurityException { KeyFactory fact = KeyFactory.getInstance("DSA"); DERSequence seq = (DERSequence) (new ASN1InputStream(ByteList.plain(input)).readObject()); if (seq.size() == 6) { BigInteger p = ((DERInteger) seq.getObjectAt(1)).getValue(); BigInteger q = ((DERInteger) seq.getObjectAt(2)).getValue(); BigInteger g = ((DERInteger) seq.getObjectAt(3)).getValue(); BigInteger y = ((DERInteger) seq.getObjectAt(4)).getValue(); BigInteger x = ((DERInteger) seq.getObjectAt(5)).getValue(); PrivateKey priv = fact.generatePrivate(new DSAPrivateKeySpec(x, p, q, g)); PublicKey pub = fact.generatePublic(new DSAPublicKeySpec(y, p, q, g)); return new KeyPair(pub, priv); } else {/*from w w w.j av a 2s . co m*/ return null; } }
From source file:org.jruby.ext.openssl.x509store.BouncyCastleASN1FormatHandler.java
License:LGPL
@Override public PublicKey readDSAPublicKey(String input) throws IOException, GeneralSecurityException { KeyFactory fact = KeyFactory.getInstance("RSA"); DERSequence seq = (DERSequence) (new ASN1InputStream(ByteList.plain(input)).readObject()); if (seq.size() == 4) { BigInteger y = ((DERInteger) seq.getObjectAt(0)).getValue(); BigInteger p = ((DERInteger) seq.getObjectAt(1)).getValue(); BigInteger q = ((DERInteger) seq.getObjectAt(2)).getValue(); BigInteger g = ((DERInteger) seq.getObjectAt(3)).getValue(); return fact.generatePublic(new DSAPublicKeySpec(y, p, q, g)); } else {/* ww w. j a v a 2 s. c om*/ return null; } }
From source file:se.inera.intyg.webcert.web.service.signatur.asn1.ASN1UtilImpl.java
License:Open Source License
private String handleDERSequence(String identifier, DERSequence seq) { String value = null;//ww w . j a v a 2s. co m for (int a = 0; a < seq.size() && value == null; a++) { DERObject obj = seq.getObjectAt(a).getDERObject(); if (obj instanceof ASN1ObjectIdentifier) { ASN1ObjectIdentifier objectIdentifier = (ASN1ObjectIdentifier) obj; if (objectIdentifier.getId().equals(identifier)) { value = seq.getObjectAt(a + 1).toString(); break; } } else { value = findInCertificate(identifier, obj); } } return value; }