Пример #1
0
 @Test
 public void concatenate() {
   byte[] a = TestUtils.hexToByteArray("0011");
   byte[] b = TestUtils.hexToByteArray("2233");
   byte[] r = TestUtils.hexToByteArray("00112233");
   assertArrayEquals(r, ByteBufferUtils.concat(a, b));
 }
Пример #2
0
 @Test
 public void test() {
   int ecListLen = (TLS_EC_LIST.length() >> 1);
   String ecList = String.format("%04x%s", ecListLen, TLS_EC_LIST);
   EllipticCurveList list =
       EllipticCurveList.read(ByteBuffer.wrap(TestUtils.hexToByteArray(ecList)));
   assertEquals(TLS_EC_LIST.length() / 4, list.size());
   Iterator<NamedCurve> i = list.iterator();
   assertEquals(NamedCurve.sect163k1, i.next());
   assertEquals(NamedCurve.sect163r1, i.next());
   assertEquals(NamedCurve.sect163r2, i.next());
 }
Пример #3
0
 @Test
 public void testSlice() {
   ByteBuffer b = ByteBuffer.wrap(TestUtils.hexToByteArray("00010203040506070809"));
   int start = 3;
   b.position(start);
   b.mark();
   b.position(5);
   b.limit(8);
   ByteBuffer s = ByteBufferUtils.sliceMarkToLength(b, 3);
   assertEquals(start++, s.get());
   assertEquals(start++, s.get());
   assertEquals(start++, s.get());
   try {
     s.get();
     fail("expected underflow exception");
   } catch (BufferUnderflowException e) {
   }
 }