Asn1Object read() throws IOException { int tag = in.read(); if (tag == -1) { throw new IOException("Invalid DER: stream too short, missing tag"); } int length = getLength(); byte[] value = new byte[length]; if (in.read(value) < length) { throw new IOException("Invalid DER: stream too short, missing value"); } return new Asn1Object(tag, value); }
private static BigInteger next(DerParser parser) throws IOException { return parser.read().getInteger(); }
Asn1Object read() throws IOException { int tag = in.read(); if (tag == -1) { throw new IOException("Invalid DER: stream too short, missing tag"); } int length = getLength(); byte[] value = new byte[length]; if (in.read(value) < length) { throw new IOException("Invalid DER: stream too short, missing value"); } return new Asn1Object(tag, value); }
public static RSAPrivateCrtKeySpec decodePKCS1(byte[] keyBytes) throws IOException { DerParser parser = new DerParser(keyBytes); Asn1Object sequence = parser.read(); sequence.validateSequence(); parser = new DerParser(sequence.getValue()); parser.read(); return new RSAPrivateCrtKeySpec(next(parser), next(parser), next(parser), next(parser), next(parser), next(parser), next(parser), next(parser)); }
private static BigInteger next(DerParser parser) throws IOException { return parser.read().getInteger(); }
public static RSAPrivateCrtKeySpec decodePKCS1(byte[] keyBytes) throws IOException { DerParser parser = new DerParser(keyBytes); Asn1Object sequence = parser.read(); sequence.validateSequence(); parser = new DerParser(sequence.getValue()); parser.read(); return new RSAPrivateCrtKeySpec(next(parser), next(parser), next(parser), next(parser), next(parser), next(parser), next(parser), next(parser)); }