Package org.xipki.pkcs11.wrapper
Class Functions
- java.lang.Object
-
- org.xipki.pkcs11.wrapper.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 Summary
Constructors Constructor Description Functions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]asUnsignedByteArray(BigInteger bn)static byte[]decodeHex(String encoded)static StringdecodeOid(byte[] encoded)static byte[]dsaSigPlainToX962(byte[] sig)static byte[]dsaSigX962ToPlain(byte[] sig, int rOrSLen)static byte[]encodeOid(String oid)static StringgetCurveName(byte[] ecParams)static String[]getCurveNames(byte[] ecParams)static IntegergetCurveOrderBitLength(byte[] ecParams)static byte[]getEcParams(BigInteger order, BigInteger baseX)static byte[]getOctetsFromASN1BitString(byte[] encoded)static byte[]getOctetsFromASN1OctetString(byte[] encoded)static LongparseLong(String text)static intrequireAmong(String name, int argument, int... candidates)static longrequireAmong(String name, long argument, long... candidates)static <T> TrequireNonNull(String paramName, T param)static intrequireRange(String name, int argument, int min, int max)static StringtoFullHex(long value)Converts a long value to a hexadecimal String of length 16.static StringtoHex(byte[] value)Converts a byte array to a hexadecimal String.static StringtoHex(byte[] value, int ofs, int len)static byte[]toOctetOrBitString(byte[] bytes, boolean isBitString)static StringtoString(String prefix, byte[] bytes)static StringtoStringFlags(PKCS11Constants.Category category, String prefix, long flags, long... flagMasks)
-
-
-
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)
-
toStringFlags
public static String toStringFlags(PKCS11Constants.Category category, String prefix, long flags, long... flagMasks)
-
getEcParams
public static byte[] getEcParams(BigInteger order, BigInteger baseX)
-
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)
-
getOctetsFromASN1OctetString
public static byte[] getOctetsFromASN1OctetString(byte[] encoded) throws TokenException- Throws:
TokenException
-
getOctetsFromASN1BitString
public static byte[] getOctetsFromASN1BitString(byte[] encoded) throws TokenException- Throws:
TokenException
-
toOctetOrBitString
public static byte[] toOctetOrBitString(byte[] bytes, boolean isBitString)
-
-