public static BigInteger decodeBigInteger(BERInputStream is, MutableByte type) throws IOException { int length; type.setValue((byte)is.read()); if (type.value != 0x02) { throw new IOException("Wrong ASN.1 type. Not an INTEGER: "+type.value+ getPositionMessage(is)); } length = decodeLength(is); if (length < 0) { throw new IOException("Length greater than "+Integer.MAX_VALUE+" are not supported "+ " for integers: "+getPositionMessage(is)); } byte[] bytes = new byte[length]; int actualRead = is.read(bytes); if (actualRead != length) { throw new IOException("Length of INTEGER ("+length+") is greater than number of bytes left in BER stream: "+ actualRead); } return new BigInteger(bytes); }
public static BigInteger decodeBigInteger(BERInputStream is, MutableByte type) throws IOException { int length; type.setValue((byte)is.read()); if (type.value != 0x02) { throw new IOException("Wrong ASN.1 type. Not an INTEGER: "+type.value+ getPositionMessage(is)); } length = decodeLength(is); if (length < 0) { throw new IOException("Length greater than "+Integer.MAX_VALUE+" are not supported "+ " for integers: "+getPositionMessage(is)); } byte[] bytes = new byte[length]; int actualRead = is.read(bytes); if (actualRead != length) { throw new IOException("Length of INTEGER ("+length+") is greater than number of bytes left in BER stream: "+ actualRead); } return new BigInteger(bytes); }
BigInteger value = BigInteger.ZERO; type.setValue((byte)inputStream.read());
getPositionMessage(is)); type.setValue(t); return decodeLength(is, checkLength);
getPositionMessage(is)); type.setValue(t); return decodeLength(is, checkLength);
type.setValue((byte)is.read()); if ((type.value != 0x02) && (type.value != 0x46)) { throw new IOException("Wrong type. Not an integer 64: "+type.value+
type.setValue((byte)is.read()); if ((type.value != BER.OCTETSTRING) && (type.value != 0x24) && (type.value != BER.IPADDRESS) && (type.value != BER.OPAQUE) &&
type.setValue((byte)is.read()); if ((type.value != 0x02) && (type.value != 0x46)) { throw new IOException("Wrong type. Not an integer 64: "+type.value+
BigInteger value = BigInteger.ZERO; type.setValue((byte)inputStream.read());
public static int decodeInteger(BERInputStream is, MutableByte type) throws IOException { int length; int value = 0; type.setValue((byte)is.read()); if ((type.value != 0x02) && (type.value != 0x43) && (type.value != 0x41)) { throw new IOException("Wrong ASN.1 type. Not an integer: "+type.value+ getPositionMessage(is)); } length = decodeLength(is); if (length > 4) { throw new IOException("Length greater than 32bit are not supported "+ " for integers: "+getPositionMessage(is)); } int b = is.read() & 0xFF; if ((b & 0x80) > 0) { value = -1; /* integer is negative */ } while (length-- > 0) { value = (value << 8) | b; if (length > 0) { b = is.read(); } } return value; }
public static final int decodeInteger(BERInputStream is, MutableByte type) throws IOException { int length; int value = 0; type.setValue((byte)is.read()); if ((type.value != 0x02) && (type.value != 0x43) && (type.value != 0x41)) { throw new IOException("Wrong ASN.1 type. Not an integer: "+type.value+ getPositionMessage(is)); } length = decodeLength(is); if (length > 4) { throw new IOException("Length greater than 32bit are not supported "+ " for integers: "+getPositionMessage(is)); } int b = is.read() & 0xFF; if ((b & 0x80) > 0) { value = -1; /* integer is negative */ } while (length-- > 0) { value = (value << 8) | b; if (length > 0) { b = is.read(); } } return value; }
public static int decodeInteger(BERInputStream is, MutableByte type) throws IOException { int length; int value = 0; type.setValue((byte)is.read()); if ((type.value != 0x02) && (type.value != 0x43) && (type.value != 0x41)) { throw new IOException("Wrong ASN.1 type. Not an integer: "+type.value+ getPositionMessage(is)); } length = decodeLength(is); if (length > 4) { throw new IOException("Length greater than 32bit are not supported "+ " for integers: "+getPositionMessage(is)); } int b = is.read() & 0xFF; if ((b & 0x80) > 0) { value = -1; /* integer is negative */ } while (length-- > 0) { value = (value << 8) | b; if (length > 0) { b = is.read(); } } return value; }
public static byte[] decodeString(BERInputStream is, MutableByte type) throws IOException { /* * ASN.1 octet string ::= primstring | cmpdstring * primstring ::= 0x04 asnlength byte {byte}* * cmpdstring ::= 0x24 asnlength string {string}* * ipaddress ::= 0x40 4 byte byte byte byte */ // get the type type.setValue((byte)is.read()); if ((type.value != BER.OCTETSTRING) && (type.value != 0x24) && (type.value != BER.IPADDRESS) && (type.value != BER.OPAQUE) && (type.value != BER.BITSTRING) && (type.value != 0x45)) { throw new IOException("Wrong ASN.1 type. Not a string: "+type.value+getPositionMessage(is)); } int length = decodeLength(is); byte[] value = new byte[length]; if (length > 0) { int read = is.read(value, 0, length); if ((read < 0) || (read < length)) { throw new IOException("Wrong string length " + read + " < " + length); } } return value; }
public static byte[] decodeString(BERInputStream is, MutableByte type) throws IOException { /* * ASN.1 octet string ::= primstring | cmpdstring * primstring ::= 0x04 asnlength byte {byte}* * cmpdstring ::= 0x24 asnlength string {string}* * ipaddress ::= 0x40 4 byte byte byte byte */ // get the type type.setValue((byte)is.read()); if ((type.value != BER.OCTETSTRING) && (type.value != 0x24) && (type.value != BER.IPADDRESS) && (type.value != BER.OPAQUE) && (type.value != BER.BITSTRING) && (type.value != 0x45)) { throw new IOException("Wrong ASN.1 type. Not a string: "+type.value+getPositionMessage(is)); } int length = decodeLength(is); byte[] value = new byte[length]; if (length > 0) { int read = is.read(value, 0, length); if ((read < 0) || (read < length)) { throw new IOException("Wrong string length " + read + " < " + length); } } return value; }
public static void decodeNull(BERInputStream is, MutableByte type) throws IOException { // get the type type.setValue((byte)(is.read() & 0xFF)); if ((type.value != (byte)0x05) && (type.value != (byte)0x80) && (type.value != (byte)0x81) && (type.value != (byte)0x82)) { throw new IOException("Wrong ASN.1 type. Is not null: " + type.value+ getPositionMessage(is)); } int length = decodeLength(is); if (length != 0) { throw new IOException("Invalid Null encoding, length is not zero: "+ length+getPositionMessage(is)); } }
public static void decodeNull(BERInputStream is, MutableByte type) throws IOException { // get the type type.setValue((byte)(is.read() & 0xFF)); if ((type.value != (byte)0x05) && (type.value != (byte)0x80) && (type.value != (byte)0x81) && (type.value != (byte)0x82)) { throw new IOException("Wrong ASN.1 type. Is not null: " + type.value+ getPositionMessage(is)); } int length = decodeLength(is); if (length != 0) { throw new IOException("Invalid Null encoding, length is not zero: "+ length+getPositionMessage(is)); } }
public static final void decodeNull(BERInputStream is, MutableByte type) throws IOException { // get the type type.setValue((byte)(is.read() & 0xFF)); if ((type.value != (byte)0x05) && (type.value != (byte)0x80) && (type.value != (byte)0x81) && (type.value != (byte)0x82)) { throw new IOException("Wrong ASN.1 type. Is not null: " + type.value+ getPositionMessage(is)); } int length = decodeLength(is); if (length != 0) { throw new IOException("Invalid Null encoding, length is not zero: "+ length+getPositionMessage(is)); } }
public MutableByte(byte value) { setValue(value); }
public MutableByte(byte value) { setValue(value); }
public MutableByte(byte value) { setValue(value); }