Class Functions


  • public class Functions
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      Functions()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] asUnsignedByteArray​(java.math.BigInteger bn)  
      static byte[] decodeHex​(java.lang.String encoded)  
      static java.lang.String decodeOid​(byte[] encoded)  
      static java.lang.String getCurveName​(byte[] ecParams)  
      static java.lang.String[] getCurveNames​(byte[] ecParams)  
      static java.lang.Integer getCurveOrderBitLength​(byte[] ecParams)  
      static byte[] getEcParams​(java.math.BigInteger order, java.math.BigInteger baseX)  
      static byte[] getOctetsFromASN1OctetString​(byte[] encoded)  
      static byte[] plainToX962DSASignature​(byte[] sig)  
      static int requireAmong​(java.lang.String name, int argument, int... candidates)  
      static long requireAmong​(java.lang.String name, long argument, long... candidates)  
      static <T> T requireNonNull​(java.lang.String paramName, T param)  
      static int requireRange​(java.lang.String name, int argument, int min, int max)  
      static java.lang.String toFullHex​(long value)
      Converts a long value to a hexadecimal String of length 16.
      static java.lang.String toHex​(byte[] value)
      Converts a byte array to a hexadecimal String.
      static java.lang.String toHex​(byte[] value, int ofs, int len)  
      static byte[] toOctetString​(byte[] bytes)  
      static java.lang.String toString​(java.lang.String prefix, byte[] bytes)  
      static java.lang.String toStringFlags​(PKCS11Constants.Category category, java.lang.String prefix, long flags, long... flagMasks)  
      static byte[] x962ToPlainDSASignature​(byte[] sig, int rOrSLen)  
      • Methods inherited from class java.lang.Object

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

      • Functions

        public Functions()
    • Method Detail

      • asUnsignedByteArray

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

        public static java.lang.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 java.lang.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 java.lang.String toHex​(byte[] value,
                                             int ofs,
                                             int len)
      • decodeHex

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

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

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

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

        public static long requireAmong​(java.lang.String name,
                                        long argument,
                                        long... candidates)
      • toStringFlags

        public static java.lang.String toStringFlags​(PKCS11Constants.Category category,
                                                     java.lang.String prefix,
                                                     long flags,
                                                     long... flagMasks)
      • getEcParams

        public static byte[] getEcParams​(java.math.BigInteger order,
                                         java.math.BigInteger baseX)
      • getCurveOrderBitLength

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

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

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

        public static java.lang.String decodeOid​(byte[] encoded)
      • plainToX962DSASignature

        public static byte[] plainToX962DSASignature​(byte[] sig)
      • x962ToPlainDSASignature

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

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

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

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