Class JWKUtil


  • public class JWKUtil
    extends Object
    • Constructor Detail

      • JWKUtil

        public JWKUtil()
    • Method Detail

      • toIntegerBytes

        public static byte[] toIntegerBytes​(BigInteger bigInt)
        Coverts BigInteger to 64-byte array removing the sign byte if necessary.
        Parameters:
        bigInt - BigInteger to be converted
        Returns:
        Byte array representation of the BigInteger parameter
      • toIntegerBytes

        public static byte[] toIntegerBytes​(BigInteger bigInt,
                                            int bitlen)
        Coverts BigInteger to 64-byte array but maintaining the length to bitlen as specified in rfc7518 for certain fields (X and Y parameter for EC keys).
        Parameters:
        bigInt - BigInteger to be converted
        bitlen - The bit length size of the integer (for example 521 for EC P-521)
        Returns:
        Byte array representation of the BigInteger parameter with length (bitlen + 7) / 8
        Throws:
        IllegalStateException - if the big integer is longer than bitlen