Class BigIntegerUtils

java.lang.Object
org.forgerock.json.jose.utils.BigIntegerUtils

public final class BigIntegerUtils extends Object
Utils to complement bit operations not covered by the BigInteger functions.
  • Method Details

    • toBytesUnsigned

      public static byte[] toBytesUnsigned(BigInteger x)
      Returns the unsigned big-endian byte array of a big integer. Any leading zero sign byte is removed.
      Parameters:
      x - a big integer
      Returns:
      the unsigned big-endian byte array of x
    • base64UrlDecode

      public static BigInteger base64UrlDecode(String magnitudeBase64UrlEncoded)
      Decode a big-endian base64 url encoding of a magnitude big integer and transform it as a positive big integer.
      Parameters:
      magnitudeBase64UrlEncoded - big-endian base64 url encoding of a big integer magnitude
      Returns:
      a positive big integer with the decoded magnitude.
    • base64UrlEncodeUnsignedBigEndian

      public static String base64UrlEncodeUnsignedBigEndian(BigInteger number)
      Encode a big integer into a base 64 url encoded unsigned big endian.
      Parameters:
      number - a big integer
      Returns:
      big-endian base64 url encoding of a big integer magnitude