org.jasn
Class DerUtilities

java.lang.Object
  extended byorg.jasn.DerUtilities

public class DerUtilities
extends Object


Constructor Summary
DerUtilities()
           
 
Method Summary
static byte[] encodeLength(int len)
          Returns an array of bytes containing the DER encoding of the specified length.
static int encodeLength(int len, byte[] buf, int offset)
           
static byte[] encodeTag(int tag, boolean constructed)
          Returns an array of bytes containing the DER encoding of the specified tag.
static int encodeTag(int tag, boolean constructed, byte[] buf, int offset)
          Stores the bytes of the DER encoding of the specified tag into buf starting at the position offset.
static int getEncodedLengthSize(int len)
          Returns the number of bytes needed to store the DER encoding of the specified length.
static int getEncodedTagSize(int tag)
          Returns the number of bytes needed to store the BER/DER encoding of the specified tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DerUtilities

public DerUtilities()
Method Detail

encodeTag

public static byte[] encodeTag(int tag,
                               boolean constructed)
Returns an array of bytes containing the DER encoding of the specified tag. The encoding is constructed if constructed is true; otherwise it is primitive.


encodeTag

public static int encodeTag(int tag,
                            boolean constructed,
                            byte[] buf,
                            int offset)
Stores the bytes of the DER encoding of the specified tag into buf starting at the position offset. The encoding is constructed if constructed is true; otherwise it is primitive.

Parameters:
tag - the ASN.1 tag to be DER encoded.
constructed - true if the encoding should be constructed; false for primitive encoding.
buf - the buffer into which the bytes of DER encoding of the tag are stored.
offset - the index at which the encoded bytes are stored into the buffer.

encodeLength

public static byte[] encodeLength(int len)
Returns an array of bytes containing the DER encoding of the specified length.

Parameters:
len - the length to be encoded.
Returns:
the byte's array containing the DER encoding of the specified length.
Throws:
IllegalArgumentException - if the length is negative.

encodeLength

public static int encodeLength(int len,
                               byte[] buf,
                               int offset)

getEncodedTagSize

public static int getEncodedTagSize(int tag)
Returns the number of bytes needed to store the BER/DER encoding of the specified tag.

Parameters:
tag - the tag for wich the needed byte number is computed.
Throws:
IllegalArgumentException - if the specified length is negative.

getEncodedLengthSize

public static int getEncodedLengthSize(int len)
Returns the number of bytes needed to store the DER encoding of the specified length.

Parameters:
len - the length for wich the needed byte number is computed.
Throws:
IllegalArgumentException - if the specified length is negative.


Copyright © 2004 Nicolas Vraux. All Rights Reserved.