public final class CryptoUtils extends Object
Modifier and Type | Method and Description |
---|---|
static SecretKey |
createSecretKeySpec(byte[] bytes,
String algo) |
static SecretKey |
createSecretKeySpec(String encodedBytes,
String algo) |
static Certificate |
decodeCertificate(String encodedCert) |
static SecretKey |
decodeSecretKey(String encodedSecretKey) |
static SecretKey |
decodeSecretKey(String encodedSecretKey,
String secretKeyAlgo) |
static byte[] |
decodeSequence(String encodedSequence) |
static byte[] |
decryptBytes(byte[] bytes,
Key secretKey) |
static byte[] |
decryptBytes(byte[] bytes,
Key secretKey,
KeyProperties keyProps) |
static SecretKey |
decryptSecretKey(String encodedEncryptedSecretKey,
PrivateKey privateKey) |
static SecretKey |
decryptSecretKey(String encodedEncryptedSecretKey,
String secretKeyAlgo,
KeyProperties props,
PrivateKey privateKey) |
static SecretKey |
decryptSecretKey(String encodedEncryptedSecretKey,
String secretKeyAlgo,
PrivateKey privateKey) |
static String |
decryptSequence(String encodedData,
Key secretKey) |
static String |
decryptSequence(String encodedData,
Key secretKey,
KeyProperties props) |
static String |
decryptSequence(String encodedToken,
String encodedSecretKey) |
static String |
decryptSequence(String encodedData,
String encodedSecretKey,
KeyProperties props) |
static String |
encodeBytes(byte[] bytes) |
static String |
encodeCertificate(Certificate cert) |
static String |
encodeSecretKey(SecretKey key) |
static byte[] |
encryptBytes(byte[] bytes,
Key secretKey) |
static byte[] |
encryptBytes(byte[] bytes,
Key secretKey,
KeyProperties keyProps) |
static String |
encryptSecretKey(SecretKey secretKey,
PublicKey publicKey) |
static String |
encryptSecretKey(SecretKey secretKey,
PublicKey publicKey,
KeyProperties props) |
static String |
encryptSequence(String sequence,
Key secretKey) |
static String |
encryptSequence(String sequence,
Key secretKey,
KeyProperties keyProps) |
static KeyPair |
generateECKeyPair(String curve) |
static byte[] |
generateSecureRandomBytes(int size) |
static AlgorithmParameterSpec |
getContentEncryptionCipherSpec(int authTagLength,
byte[] iv) |
static ECPrivateKey |
getECPrivateKey(String curve,
byte[] privateKey) |
static ECPrivateKey |
getECPrivateKey(String curve,
String encodedPrivateKey) |
static ECPublicKey |
getECPublicKey(String curve,
byte[] xPoint,
byte[] yPoint) |
static ECPublicKey |
getECPublicKey(String curve,
String encodedXPoint,
String encodedYPoint) |
static AlgorithmParameterSpec |
getGCMParameterSpec(int authTagLength,
byte[] iv) |
static RSAPrivateKey |
getRSAPrivateKey(byte[] modulusBytes,
byte[] privateExponentBytes) |
static RSAPrivateKey |
getRSAPrivateKey(byte[] modulusBytes,
byte[] publicExponentBytes,
byte[] privateExponentBytes,
byte[] primePBytes,
byte[] primeQBytes,
byte[] primeExpPBytes,
byte[] primeExpQBytes,
byte[] crtCoefficientBytes) |
static RSAPrivateKey |
getRSAPrivateKey(String encodedModulus,
String encodedPrivateExponent) |
static RSAPrivateKey |
getRSAPrivateKey(String encodedModulus,
String encodedPublicExponent,
String encodedPrivateExponent,
String encodedPrimeP,
String encodedPrimeQ,
String encodedPrimeExpP,
String encodedPrimeExpQ,
String encodedCrtCoefficient) |
static RSAPublicKey |
getRSAPublicKey(byte[] modulusBytes,
byte[] publicExponentBytes) |
static RSAPublicKey |
getRSAPublicKey(KeyFactory factory,
byte[] modulusBytes,
byte[] publicExponentBytes) |
static RSAPublicKey |
getRSAPublicKey(String encodedModulus,
String encodedPublicExponent) |
static SecretKey |
getSecretKey(KeyProperties props) |
static SecretKey |
getSecretKey(String symEncAlgo) |
static SecretKey |
getSecretKey(String symEncAlgo,
int keySize) |
static Signature |
getSignature(PrivateKey key,
String signAlgo,
SecureRandom random,
AlgorithmParameterSpec params) |
static Cipher |
initCipher(Key secretKey,
KeyProperties keyProps,
int mode) |
static Certificate |
loadCertificate(InputStream storeLocation,
char[] storePassword,
String alias,
String storeType) |
static Certificate |
loadCertificate(KeyStore keyStore,
String alias) |
static KeyStore |
loadKeyStore(InputStream storeLocation,
char[] storePassword,
String type) |
static PrivateKey |
loadPrivateKey(InputStream storeLocation,
char[] storePassword,
char[] keyPassword,
String alias,
String storeType) |
static PrivateKey |
loadPrivateKey(KeyStore keyStore,
char[] keyPassword,
String alias) |
static PublicKey |
loadPublicKey(InputStream storeLocation,
char[] storePassword,
String alias,
String storeType) |
static PublicKey |
loadPublicKey(KeyStore keyStore,
String alias) |
static byte[] |
signData(byte[] data,
PrivateKey key,
String signAlgo) |
static byte[] |
signData(byte[] data,
PrivateKey key,
String signAlgo,
SecureRandom random,
AlgorithmParameterSpec params) |
static Key |
unwrapKey(byte[] wrappedBytes,
String wrappedKeyAlgo,
Key unwrapperKey,
KeyProperties keyProps,
int wrappedKeyType) |
static SecretKey |
unwrapSecretKey(byte[] wrappedBytes,
String wrappedKeyAlgo,
Key unwrapperKey,
KeyProperties keyProps) |
static SecretKey |
unwrapSecretKey(byte[] wrappedBytes,
String wrappedKeyAlgo,
Key unwrapperKey,
String unwrapperKeyAlgo) |
static boolean |
verifySignature(byte[] data,
byte[] signature,
PublicKey key,
String signAlgo) |
static boolean |
verifySignature(byte[] data,
byte[] signature,
PublicKey key,
String signAlgo,
AlgorithmParameterSpec params) |
static byte[] |
wrapSecretKey(byte[] keyBytes,
String keyAlgo,
Key wrapperKey,
KeyProperties wrapperKeyProps) |
static byte[] |
wrapSecretKey(Key secretKey,
Key wrapperKey,
KeyProperties keyProps) |
public static String encodeSecretKey(SecretKey key) throws SecurityException
SecurityException
public static String encryptSecretKey(SecretKey secretKey, PublicKey publicKey) throws SecurityException
SecurityException
public static String encryptSecretKey(SecretKey secretKey, PublicKey publicKey, KeyProperties props) throws SecurityException
SecurityException
public static byte[] generateSecureRandomBytes(int size)
public static RSAPublicKey getRSAPublicKey(String encodedModulus, String encodedPublicExponent)
public static RSAPublicKey getRSAPublicKey(byte[] modulusBytes, byte[] publicExponentBytes)
public static RSAPublicKey getRSAPublicKey(KeyFactory factory, byte[] modulusBytes, byte[] publicExponentBytes)
public static RSAPrivateKey getRSAPrivateKey(String encodedModulus, String encodedPrivateExponent)
public static RSAPrivateKey getRSAPrivateKey(byte[] modulusBytes, byte[] privateExponentBytes)
public static RSAPrivateKey getRSAPrivateKey(String encodedModulus, String encodedPublicExponent, String encodedPrivateExponent, String encodedPrimeP, String encodedPrimeQ, String encodedPrimeExpP, String encodedPrimeExpQ, String encodedCrtCoefficient)
public static RSAPrivateKey getRSAPrivateKey(byte[] modulusBytes, byte[] publicExponentBytes, byte[] privateExponentBytes, byte[] primePBytes, byte[] primeQBytes, byte[] primeExpPBytes, byte[] primeExpQBytes, byte[] crtCoefficientBytes)
public static ECPrivateKey getECPrivateKey(String curve, String encodedPrivateKey)
public static ECPrivateKey getECPrivateKey(String curve, byte[] privateKey)
public static ECPublicKey getECPublicKey(String curve, String encodedXPoint, String encodedYPoint)
public static ECPublicKey getECPublicKey(String curve, byte[] xPoint, byte[] yPoint)
public static AlgorithmParameterSpec getContentEncryptionCipherSpec(int authTagLength, byte[] iv)
public static AlgorithmParameterSpec getGCMParameterSpec(int authTagLength, byte[] iv)
public static byte[] signData(byte[] data, PrivateKey key, String signAlgo)
public static byte[] signData(byte[] data, PrivateKey key, String signAlgo, SecureRandom random, AlgorithmParameterSpec params)
public static Signature getSignature(PrivateKey key, String signAlgo, SecureRandom random, AlgorithmParameterSpec params)
public static boolean verifySignature(byte[] data, byte[] signature, PublicKey key, String signAlgo)
public static boolean verifySignature(byte[] data, byte[] signature, PublicKey key, String signAlgo, AlgorithmParameterSpec params)
public static SecretKey getSecretKey(String symEncAlgo) throws SecurityException
SecurityException
public static SecretKey getSecretKey(String symEncAlgo, int keySize) throws SecurityException
SecurityException
public static SecretKey getSecretKey(KeyProperties props) throws SecurityException
SecurityException
public static String decryptSequence(String encodedToken, String encodedSecretKey) throws SecurityException
SecurityException
public static String decryptSequence(String encodedData, String encodedSecretKey, KeyProperties props) throws SecurityException
SecurityException
public static String decryptSequence(String encodedData, Key secretKey) throws SecurityException
SecurityException
public static String decryptSequence(String encodedData, Key secretKey, KeyProperties props) throws SecurityException
SecurityException
public static String encryptSequence(String sequence, Key secretKey) throws SecurityException
SecurityException
public static String encryptSequence(String sequence, Key secretKey, KeyProperties keyProps) throws SecurityException
SecurityException
public static String encodeBytes(byte[] bytes) throws SecurityException
SecurityException
public static byte[] encryptBytes(byte[] bytes, Key secretKey) throws SecurityException
SecurityException
public static byte[] encryptBytes(byte[] bytes, Key secretKey, KeyProperties keyProps) throws SecurityException
SecurityException
public static byte[] decryptBytes(byte[] bytes, Key secretKey) throws SecurityException
SecurityException
public static byte[] decryptBytes(byte[] bytes, Key secretKey, KeyProperties keyProps) throws SecurityException
SecurityException
public static byte[] wrapSecretKey(byte[] keyBytes, String keyAlgo, Key wrapperKey, KeyProperties wrapperKeyProps) throws SecurityException
SecurityException
public static byte[] wrapSecretKey(Key secretKey, Key wrapperKey, KeyProperties keyProps) throws SecurityException
SecurityException
public static SecretKey unwrapSecretKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, String unwrapperKeyAlgo) throws SecurityException
SecurityException
public static SecretKey unwrapSecretKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, KeyProperties keyProps) throws SecurityException
SecurityException
public static Key unwrapKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, KeyProperties keyProps, int wrappedKeyType) throws SecurityException
SecurityException
public static Cipher initCipher(Key secretKey, KeyProperties keyProps, int mode) throws SecurityException
SecurityException
public static SecretKey decodeSecretKey(String encodedSecretKey) throws SecurityException
SecurityException
public static SecretKey decodeSecretKey(String encodedSecretKey, String secretKeyAlgo) throws SecurityException
SecurityException
public static SecretKey decryptSecretKey(String encodedEncryptedSecretKey, PrivateKey privateKey)
public static SecretKey decryptSecretKey(String encodedEncryptedSecretKey, String secretKeyAlgo, PrivateKey privateKey) throws SecurityException
SecurityException
public static SecretKey decryptSecretKey(String encodedEncryptedSecretKey, String secretKeyAlgo, KeyProperties props, PrivateKey privateKey) throws SecurityException
SecurityException
public static byte[] decodeSequence(String encodedSequence) throws SecurityException
SecurityException
public static Certificate loadCertificate(InputStream storeLocation, char[] storePassword, String alias, String storeType)
public static Certificate loadCertificate(KeyStore keyStore, String alias)
public static String encodeCertificate(Certificate cert)
public static Certificate decodeCertificate(String encodedCert)
public static PublicKey loadPublicKey(InputStream storeLocation, char[] storePassword, String alias, String storeType)
public static KeyStore loadKeyStore(InputStream storeLocation, char[] storePassword, String type)
public static PrivateKey loadPrivateKey(InputStream storeLocation, char[] storePassword, char[] keyPassword, String alias, String storeType)
public static PrivateKey loadPrivateKey(KeyStore keyStore, char[] keyPassword, String alias)
Apache CXF