public static ECDSASignature decodeFromDER(byte[] bytes) { ASN1InputStream decoder = null; try { decoder = new ASN1InputStream(bytes); DLSequence seq = (DLSequence) decoder.readObject(); if (seq == null) throw new RuntimeException("Reached past end of ASN.1 stream."); ASN1Integer r, s; try { r = (ASN1Integer) seq.getObjectAt(0); s = (ASN1Integer) seq.getObjectAt(1); } catch (ClassCastException e) { throw new IllegalArgumentException(e); } // OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be // Thus, we always use the positive versions. See: http://r6.ca/blog/20111119T211504Z.html return new ECDSASignature(r.getPositiveValue(), s.getPositiveValue()); } catch (IOException e) { throw new RuntimeException(e); } finally { if (decoder != null) try { decoder.close(); } catch (IOException x) {} } }
/** * @deprecated use classes in org.spongycastle.cert.ocsp. */ public OCSPResp( byte[] resp) throws IOException { this(new ASN1InputStream(resp)); }
/** * @deprecated use classes in org.spongycastle.cert.ocsp. */ public OCSPResp( InputStream in) throws IOException { this(new ASN1InputStream(in)); }
public OCSPReq( byte[] req) throws IOException { this(new ASN1InputStream(req)); }
public OCSPResp( InputStream resp) throws IOException { this(new ASN1InputStream(resp)); }
public OCSPResp( InputStream resp) throws IOException { this(new ASN1InputStream(resp)); }
public LazyConstructionEnumeration(byte[] encoded) { aIn = new ASN1InputStream(encoded, true); nextObj = readObject(); }
static ContentInfo readContentInfo( InputStream input) throws CMSException { // enforce some limit checking return readContentInfo(new ASN1InputStream(input)); }
ASN1EncodableVector buildDEREncodableVector( DefiniteLengthInputStream dIn) throws IOException { return new ASN1InputStream(dIn).buildEncodableVector(); }
ASN1EncodableVector buildDEREncodableVector( DefiniteLengthInputStream dIn) throws IOException { return new ASN1InputStream(dIn).buildEncodableVector(); }
/** * Constructor from an encoded byte array. */ public X509Principal( byte[] bytes) throws IOException { super(readSequence(new ASN1InputStream(bytes))); }
static ContentInfo readContentInfo( InputStream input) throws CMSException { // enforce some limit checking return readContentInfo(new ASN1InputStream(input)); }
private static ASN1Sequence getReq( byte[] r) throws IOException { ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(r)); return ASN1Sequence.getInstance(aIn.readObject()); }
private static ASN1Sequence getReq( byte[] r) throws IOException { ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(r)); return ASN1Sequence.getInstance(aIn.readObject()); }
public static void main( String args[]) throws Exception { FileInputStream fIn = new FileInputStream(args[0]); ASN1InputStream bIn = new ASN1InputStream(fIn); Object obj = null; while ((obj = bIn.readObject()) != null) { System.out.println(ASN1Dump.dumpAsString(obj)); } } }
private X509CertificatePair readDERCrossCertificatePair( InputStream in) throws IOException, CertificateParsingException { ASN1InputStream dIn = new ASN1InputStream(in); ASN1Sequence seq = (ASN1Sequence)dIn.readObject(); CertificatePair pair = CertificatePair.getInstance(seq); return new X509CertificatePair(pair); }
/** * Create a private key parameter from a PKCS8 PrivateKeyInfo encoding read from a * stream. * * @param inStr the stream to read the PrivateKeyInfo encoding from * @return a suitable private key parameter * @throws IOException on an error decoding the key */ public static AsymmetricKeyParameter createKey(InputStream inStr) throws IOException { return createKey(PrivateKeyInfo.getInstance(new ASN1InputStream(inStr).readObject())); }
/** * Create a public key from a SubjectPublicKeyInfo encoding read from a stream * * @param inStr the stream to read the SubjectPublicKeyInfo encoding from * @return the appropriate key parameter * @throws IOException on an error decoding the key */ public static AsymmetricKeyParameter createKey(InputStream inStr) throws IOException { return createKey(SubjectPublicKeyInfo.getInstance(new ASN1InputStream(inStr).readObject())); }
public X509TrustedCertificateBlock(byte[] encoding) throws IOException { ASN1InputStream aIn = new ASN1InputStream(encoding); this.certificateHolder = new X509CertificateHolder(aIn.readObject().getEncoded()); this.trustBlock = new CertificateTrustBlock(aIn.readObject().getEncoded()); }
public X509TrustedCertificateBlock(byte[] encoding) throws IOException { ASN1InputStream aIn = new ASN1InputStream(encoding); this.certificateHolder = new X509CertificateHolder(aIn.readObject().getEncoded()); this.trustBlock = new CertificateTrustBlock(aIn.readObject().getEncoded()); }