Class JWKUtil

java.lang.Object
org.keycloak.jose.jwk.JWKUtil

public class JWKUtil extends Object
  • Constructor Details

    • JWKUtil

      public JWKUtil()
  • Method Details

    • toIntegerBytes

      public static byte[] toIntegerBytes(BigInteger bigInt)
      Converts 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)
      Converts 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