use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding3.
@Test
public void implicitEncoding3() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(0));
int length = testInteger.encode(berBAOStream, false);
assertEquals(2, length);
byte[] expectedBytes = new byte[] { 0x01, 0x00 };
assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method encodeDecodeLargeLongs.
@Test
public void encodeDecodeLargeLongs() throws IOException {
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(50);
BerInteger myInt = new BerInteger(BigInteger.valueOf(20093243433L));
myInt.encode(os, true);
ByteArrayInputStream berInputStream = new ByteArrayInputStream(os.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 implicitEncoding2.
@Test
public void implicitEncoding2() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(256));
int length = testInteger.encode(berBAOStream, false);
assertEquals(3, length);
byte[] expectedBytes = new byte[] { 0x02, 0x01, 0x00 };
assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding6.
@Test
public void implicitEncoding6() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(-128));
int length = testInteger.encode(berBAOStream, false);
assertEquals(2, length);
byte[] expectedBytes = new byte[] { 0x01, (byte) 0x80 };
assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method explicitEncoding.
@Test
public void explicitEncoding() throws IOException {
ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50);
// 51 is the example in X.690
BerInteger testInteger = new BerInteger(BigInteger.valueOf(51));
int length = testInteger.encode(berStream, true);
assertEquals(3, length);
byte[] expectedBytes = new byte[] { 0x02, 0x01, 0x33 };
assertArrayEquals(expectedBytes, berStream.getArray());
}
Aggregations