Examples of ASN1BitString


Examples of codec.asn1.ASN1BitString

  clear();

  algorithm_ = new AlgorithmIdentifier();
  add(algorithm_);
  encodedKey_ = new ASN1BitString();
  add(encodedKey_);

  try {
      dec = new DERDecoder(new ByteArrayInputStream(key.getEncoded()));
View Full Code Here

Examples of codec.asn1.ASN1BitString

  try {
      bos = new ByteArrayOutputStream();
      enc = new DEREncoder(bos);
      key.encode(enc);
      encodedKey_ = new ASN1BitString(bos.toByteArray(), 0);
      enc.close();
      set(1, encodedKey_);
  } catch (ASN1Exception e) {
      throw new InconsistentStateException("Internal, encoding error!");
  } catch (IOException e) {
View Full Code Here

Examples of com.subgraph.orchid.crypto.ASN1Parser.ASN1BitString

    assertEquals(new BigInteger("01020304", 16), asn1Integer.getValue());
  }
 
  @Test
  public void testParseASN1BitString() {
    ASN1BitString bitString = parser.parseASN1BitString(createBuffer("0001020304"));
    assertArrayEquals(new byte[] {1, 2, 3, 4}, bitString.getBytes());
  }
View Full Code Here

Examples of com.subgraph.orchid.crypto.ASN1Parser.ASN1BitString

  private byte[] asn1ObjectToBitString(ASN1Object ob) {
    if(!(ob instanceof ASN1BitString)) {
      throw new IllegalArgumentException();
    }
    final ASN1BitString bitstring = (ASN1BitString) ob;
    return bitstring.getBytes();
  }
View Full Code Here

Examples of org.apache.harmony.security.asn1.ASN1BitString

                    new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } } };

    public void testDecode_Encode() throws IOException {

        // decoder/encoder for testing
        ASN1BitString asn1 = ASN1BitString.getInstance();

        // decode from byte array
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) validBitstring[i][1]);

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
                    decoded.bytes));
        }

        // decode from input stream
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validBitstring[i][1]));

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
View Full Code Here

Examples of org.apache.harmony.security.asn1.ASN1BitString

                    new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } } };

    public void testDecode_Encode() throws IOException {

        // decoder/encoder for testing
        ASN1BitString asn1 = ASN1BitString.getInstance();

        // decode from byte array
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) validBitstring[i][1]);

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
                    decoded.bytes));
        }

        // decode from input stream
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validBitstring[i][1]));

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.