Class Functions


  • public class Functions
    extends Object
    This class contains only static methods. It is the place for all functions that are used by several classes in this package.
    Author:
    Lijun Liao (xipki)
    • Constructor Detail

      • Functions

        public Functions()
    • Method Detail

      • encodeOid

        public static byte[] encodeOid​(String oid)
      • asUnsignedByteArray

        public static byte[] asUnsignedByteArray​(BigInteger bn)
      • toFullHex

        public static String toFullHex​(long value)
        Converts a long value to a hexadecimal String of length 16. Includes leading zeros if necessary.
        Parameters:
        value - The long value to be converted.
        Returns:
        The hexadecimal string representation of the long value.
      • toHex

        public static String toHex​(byte[] value)
        Converts a byte array to a hexadecimal String. Each byte is presented by its two digit hex-code; 0x0A -> "0a", 0x00 -> "00". No leading "0x" is included in the result.
        Parameters:
        value - the byte array to be converted
        Returns:
        the hexadecimal string representation of the byte array
      • toHex

        public static String toHex​(byte[] value,
                                   int ofs,
                                   int len)
      • decodeHex

        public static byte[] decodeHex​(String encoded)
      • requireNonNull

        public static <T> T requireNonNull​(String paramName,
                                           T param)
      • requireRange

        public static int requireRange​(String name,
                                       int argument,
                                       int min,
                                       int max)
      • requireAmong

        public static int requireAmong​(String name,
                                       int argument,
                                       int... candidates)
      • requireAmong

        public static long requireAmong​(String name,
                                        long argument,
                                        long... candidates)
      • getCurveOrderBitLength

        public static Integer getCurveOrderBitLength​(byte[] ecParams)
      • getCurveName

        public static String getCurveName​(byte[] ecParams)
      • getCurveNames

        public static String[] getCurveNames​(byte[] ecParams)
      • decodeOid

        public static String decodeOid​(byte[] encoded)
      • dsaSigPlainToX962

        public static byte[] dsaSigPlainToX962​(byte[] sig)
      • dsaSigX962ToPlain

        public static byte[] dsaSigX962ToPlain​(byte[] sig,
                                               int rOrSLen)
      • toString

        public static String toString​(String prefix,
                                      byte[] bytes)
      • getOctetsFromASN1OctetString

        public static byte[] getOctetsFromASN1OctetString​(byte[] encoded)
                                                   throws TokenException
        Throws:
        TokenException
      • toOctetString

        public static byte[] toOctetString​(byte[] bytes)