public final class SubtleUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
androidApiLevel()
Deprecated.
Please reimplement this method in your code instead. From within Tink, use
Util.getAndroidApiLevel directly. |
static BigInteger |
bytes2Integer(byte[] bs)
Converts an unsigned, big-endian encoded byte array to a non-negative integer
(https://tools.ietf.org/html/rfc8017#section-4.1).
|
static byte[] |
integer2Bytes(BigInteger num,
int intendedLength)
Converts a nonnegative integer to a byte array of a specified length
(https://tools.ietf.org/html/rfc8017#section-4.2).
|
static boolean |
isAndroid()
Best-effort checks that this is Android.
|
static byte[] |
mgf1(byte[] mgfSeed,
int maskLen,
Enums.HashType mgfHash)
Computes MGF1 as defined at https://tools.ietf.org/html/rfc8017#appendix-B.2.1.
|
static void |
putAsUnsigedInt(ByteBuffer buffer,
long value)
Inserts
value as unsigned into into buffer. |
static String |
toDigestAlgo(Enums.HashType hash)
Returns the digest algorithm name corresponding to a hash type.
|
static String |
toEcdsaAlgo(Enums.HashType hash)
Returns the Ecdsa algorithm name corresponding to a hash type.
|
static String |
toRsaSsaPkcs1Algo(Enums.HashType hash)
Returns the RSA SSA (Signature with Appendix) PKCS1 algorithm name corresponding to a hash
type.
|
public static String toEcdsaAlgo(Enums.HashType hash) throws GeneralSecurityException
hash - the hash typeGeneralSecurityException - if hash is not supported or is not safe for digital
signature.public static String toRsaSsaPkcs1Algo(Enums.HashType hash) throws GeneralSecurityException
hash - the hash type.GeneralSecurityException - if hash is not supported or is not safe for digital
signature.public static String toDigestAlgo(Enums.HashType hash) throws GeneralSecurityException
hash - the hash type.GeneralSecurityException - if hash is not supported.public static boolean isAndroid()
@Deprecated public static int androidApiLevel()
Util.getAndroidApiLevel directly.public static BigInteger bytes2Integer(byte[] bs)
bs - the byte array to be converted to integer.public static byte[] integer2Bytes(BigInteger num, int intendedLength) throws GeneralSecurityException
num - nonnegative integer to be converted.intendedLength - intended length of the resulting integer.intendedLength.GeneralSecurityExceptionpublic static byte[] mgf1(byte[] mgfSeed,
int maskLen,
Enums.HashType mgfHash)
throws GeneralSecurityException
GeneralSecurityExceptionpublic static void putAsUnsigedInt(ByteBuffer buffer, long value) throws GeneralSecurityException
value as unsigned into into buffer.
@throws GeneralSecurityException if not 0 <= value < 2^32.
GeneralSecurityException