use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerEmbeddedPdv method encodeAndSave.
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding1.
@Test
public void implicitEncoding1() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
// 51 is the example in X.690
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(51));
int length = testInteger.encode(berBAOStream, false);
assertEquals(2, length);
byte[] expectedBytes = new byte[] { 0x01, 0x33 };
assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding7.
@Test
public void implicitEncoding7() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(-129));
int length = testInteger.encode(berBAOStream, false);
assertEquals(3, length);
byte[] expectedBytes = new byte[] { 0x02, (byte) 0xff, (byte) 0x7f };
assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method encodeDecodeLargeNegativeLongs.
@Test
public void encodeDecodeLargeNegativeLongs() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
BerInteger myInt = new BerInteger(BigInteger.valueOf(-20093243433L));
myInt.encode(berBAOStream, true);
ByteArrayInputStream berInputStream = new ByteArrayInputStream(berBAOStream.getArray());
BerInteger myInt2 = new BerInteger();
myInt2.decode(berInputStream, true);
assertEquals(-20093243433L, myInt2.value.longValue());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding4.
@Test
public void implicitEncoding4() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(127));
int length = testInteger.encode(berBAOStream, false);
assertEquals(2, length);
byte[] expectedBytes = new byte[] { 0x01, 0x7f };
assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
Aggregations