public class SubtleUtil extends Object
| Constructor and Description |
|---|
SubtleUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
androidApiLevel()
Returns the Android API level or -1 if Tink isn't running on Android
|
static BigInteger |
bytes2Integer(byte[] bs)
Converts an byte array to a nonnegative 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 typeGeneralSecurityExceptionpublic static String toRsaSsaPkcs1Algo(Enums.HashType hash) throws GeneralSecurityException
hash - the hash type.GeneralSecurityExceptionpublic static String toDigestAlgo(Enums.HashType hash) throws GeneralSecurityException
hash - the hash type.GeneralSecurityExceptionpublic static boolean isAndroid()
public static int androidApiLevel()
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