public final class Validators extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
validateAesKeySize(int sizeInBytes) |
static void |
validateCryptoKeyUri(String kmsKeyUri) |
static void |
validateExists(File f) |
static String |
validateKmsKeyUriAndRemovePrefix(String expectedPrefix,
String kmsKeyUri)
Validates that
kmsKeyUri starts with expectedPrefix, and removes the prefix. |
static void |
validateNotExists(File f) |
static void |
validateRsaModulusSize(int modulusSize)
Validates whether
modulusSize is at least 2048-bit. |
static void |
validateSignatureHash(Enums.HashType hash)
Validates whether
hash is safe to use for digital signature. |
static void |
validateTypeUrl(String typeUrl) |
static void |
validateVersion(int candidate,
int maxExpected) |
public static void validateTypeUrl(String typeUrl) throws GeneralSecurityException
GeneralSecurityException - if typeUrl is in invalid format.public static void validateAesKeySize(int sizeInBytes)
throws InvalidAlgorithmParameterException
InvalidAlgorithmParameterException - if sizeInBytes is not supported.public static void validateVersion(int candidate,
int maxExpected)
throws GeneralSecurityException
GeneralSecurityException - if candidate is negative or larger than maxExpected.public static void validateSignatureHash(Enums.HashType hash) throws GeneralSecurityException
hash is safe to use for digital signature.GeneralSecurityException - if hash is invalid or is not safe to use for digital
signature.public static void validateRsaModulusSize(int modulusSize)
throws GeneralSecurityException
modulusSize is at least 2048-bit.
To reach 128-bit security strength, RSA's modulus must be at least 3072-bit while 2048-bit RSA key only has 112-bit security. Nevertheless, a 2048-bit RSA key is considered safe by NIST until 2030 (see https://www.keylength.com/en/4/).
GeneralSecurityException - if modulusSize is less than 2048-bit.public static void validateNotExists(File f) throws IOException
IOExceptionpublic static void validateExists(File f) throws IOException
IOException - if f does not exists.public static String validateKmsKeyUriAndRemovePrefix(String expectedPrefix, String kmsKeyUri)
kmsKeyUri starts with expectedPrefix, and removes the prefix.IllegalArgumentException - if kmsKeyUri is invalid.public static void validateCryptoKeyUri(String kmsKeyUri) throws GeneralSecurityException
GeneralSecurityException - if kmsKeyUri is not a valid URI of a CryptoKey in
Google Cloud KMS.