Class IntegerType

  • All Implemented Interfaces:
    DEREncoder

    public class IntegerType
    extends AbstractDERType
    implements DEREncoder
    Converts arbitrary-precision integers to and from their DER encoded format.
    Author:
    Middleware Services
    • Constructor Summary

      Constructors 
      Constructor Description
      IntegerType​(int item)
      Creates a new integer type.
      IntegerType​(java.math.BigInteger item)
      Creates a new integer type.
      IntegerType​(DERTag tag, int item)
      Creates a new integer type.
      IntegerType​(DERTag tag, java.math.BigInteger item)
      Creates a new integer type.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigInteger decode​(DERBuffer encoded)
      Converts bytes in the buffer to an integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.
      static java.math.BigInteger decodeUnsigned​(DERBuffer encoded)
      Converts bytes in the buffer to an unsigned integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.
      static int decodeUnsignedPrimitive​(DERBuffer encoded)
      Converts bytes in the buffer to an unsigned primitive integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.
      byte[] encode()
      Encode this object into it's DER type.
      static byte[] toBytes​(java.math.BigInteger i)
      Converts the supplied big integer to a byte array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IntegerType

        public IntegerType​(java.math.BigInteger item)
        Creates a new integer type.
        Parameters:
        item - to DER encode
      • IntegerType

        public IntegerType​(int item)
        Creates a new integer type.
        Parameters:
        item - to DER encode
      • IntegerType

        public IntegerType​(DERTag tag,
                           java.math.BigInteger item)
        Creates a new integer type.
        Parameters:
        tag - der tag associated with this type
        item - to DER encode
        Throws:
        java.lang.IllegalArgumentException - if the der tag is constructed
      • IntegerType

        public IntegerType​(DERTag tag,
                           int item)
        Creates a new integer type.
        Parameters:
        tag - der tag associated with this type
        item - to DER encode
        Throws:
        java.lang.IllegalArgumentException - if the der tag is constructed
    • Method Detail

      • encode

        public byte[] encode()
        Description copied from interface: DEREncoder
        Encode this object into it's DER type.
        Specified by:
        encode in interface DEREncoder
        Returns:
        DER encoded object
      • decode

        public static java.math.BigInteger decode​(DERBuffer encoded)
        Converts bytes in the buffer to an integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.
        Parameters:
        encoded - buffer containing DER-encoded data where the buffer is positioned at the start of integer bytes and the limit is set beyond the last byte of integer data.
        Returns:
        decoded bytes as an integer of arbitrary size.
      • decodeUnsigned

        public static java.math.BigInteger decodeUnsigned​(DERBuffer encoded)
        Converts bytes in the buffer to an unsigned integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order.
        Parameters:
        encoded - buffer containing DER-encoded data where the buffer is positioned at the start of integer bytes and the limit is set beyond the last byte of integer data.
        Returns:
        decoded bytes as an unsigned integer of arbitrary size.
      • decodeUnsignedPrimitive

        public static int decodeUnsignedPrimitive​(DERBuffer encoded)
        Converts bytes in the buffer to an unsigned primitive integer by reading from the current position to the limit, which assumes the bytes of the integer are in big-endian order. This method reads up to 4 bytes from the buffer.
        Parameters:
        encoded - buffer containing DER-encoded data where the buffer is positioned at the start of integer bytes and the limit is set beyond the last byte of integer data.
        Returns:
        decoded bytes as an unsigned integer.
        Throws:
        java.lang.IllegalArgumentException - if the buffer contains more than 4 bytes
      • toBytes

        public static byte[] toBytes​(java.math.BigInteger i)
        Converts the supplied big integer to a byte array.
        Parameters:
        i - to convert
        Returns:
        byte array