Class CryptoUtils
java.lang.Object
org.apache.cxf.rt.security.crypto.CryptoUtils
Encryption helpers
-
Method Summary
Modifier and TypeMethodDescriptionstatic SecretKeycreateSecretKeySpec(byte[] bytes, String algo) static SecretKeycreateSecretKeySpec(String encodedBytes, String algo) static CertificatedecodeCertificate(String encodedCert) static SecretKeydecodeSecretKey(String encodedSecretKey) static SecretKeydecodeSecretKey(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 SecretKeydecryptSecretKey(String encodedEncryptedSecretKey, String secretKeyAlgo, PrivateKey privateKey) static SecretKeydecryptSecretKey(String encodedEncryptedSecretKey, String secretKeyAlgo, KeyProperties props, PrivateKey privateKey) static SecretKeydecryptSecretKey(String encodedEncryptedSecretKey, PrivateKey privateKey) static StringdecryptSequence(String encodedToken, String encodedSecretKey) static StringdecryptSequence(String encodedData, String encodedSecretKey, KeyProperties props) static StringdecryptSequence(String encodedData, Key secretKey) static StringdecryptSequence(String encodedData, Key secretKey, KeyProperties props) static StringencodeBytes(byte[] bytes) static StringencodeCertificate(Certificate cert) static StringencodeSecretKey(SecretKey key) static byte[]encryptBytes(byte[] bytes, Key secretKey) static byte[]encryptBytes(byte[] bytes, Key secretKey, KeyProperties keyProps) static StringencryptSecretKey(SecretKey secretKey, PublicKey publicKey) static StringencryptSecretKey(SecretKey secretKey, PublicKey publicKey, KeyProperties props) static StringencryptSequence(String sequence, Key secretKey) static StringencryptSequence(String sequence, Key secretKey, KeyProperties keyProps) static KeyPairgenerateECKeyPair(String curve) static byte[]generateSecureRandomBytes(int size) static AlgorithmParameterSpecgetContentEncryptionCipherSpec(int authTagLength, byte[] iv) static ECPrivateKeygetECPrivateKey(String curve, byte[] privateKey) static ECPrivateKeygetECPrivateKey(String curve, String encodedPrivateKey) static ECPublicKeygetECPublicKey(String curve, byte[] xPoint, byte[] yPoint) static ECPublicKeygetECPublicKey(String curve, String encodedXPoint, String encodedYPoint) static AlgorithmParameterSpecgetGCMParameterSpec(int authTagLength, byte[] iv) static RSAPrivateKeygetRSAPrivateKey(byte[] modulusBytes, byte[] privateExponentBytes) static RSAPrivateKeygetRSAPrivateKey(byte[] modulusBytes, byte[] publicExponentBytes, byte[] privateExponentBytes, byte[] primePBytes, byte[] primeQBytes, byte[] primeExpPBytes, byte[] primeExpQBytes, byte[] crtCoefficientBytes) static RSAPrivateKeygetRSAPrivateKey(String encodedModulus, String encodedPrivateExponent) static RSAPrivateKeygetRSAPrivateKey(String encodedModulus, String encodedPublicExponent, String encodedPrivateExponent, String encodedPrimeP, String encodedPrimeQ, String encodedPrimeExpP, String encodedPrimeExpQ, String encodedCrtCoefficient) static RSAPublicKeygetRSAPublicKey(byte[] modulusBytes, byte[] publicExponentBytes) static RSAPublicKeygetRSAPublicKey(String encodedModulus, String encodedPublicExponent) static RSAPublicKeygetRSAPublicKey(BigInteger modulusBytes, BigInteger publicExponentBytes) static RSAPublicKeygetRSAPublicKey(KeyFactory factory, byte[] modulusBytes, byte[] publicExponentBytes) static RSAPublicKeygetRSAPublicKey(KeyFactory factory, BigInteger modulus, BigInteger publicExponent) static SecretKeygetSecretKey(String symEncAlgo) static SecretKeygetSecretKey(String symEncAlgo, int keySize) static SecretKeygetSecretKey(KeyProperties props) static SignaturegetSignature(PrivateKey key, String signAlgo, SecureRandom random, AlgorithmParameterSpec params) static SignaturegetVerificationSignature(PublicKey key, String signAlgo, AlgorithmParameterSpec params) static CipherinitCipher(Key secretKey, KeyProperties keyProps, int mode) static voidstatic CertificateloadCertificate(InputStream storeLocation, char[] storePassword, String alias, String storeType) static CertificateloadCertificate(KeyStore keyStore, String alias) static KeyStoreloadKeyStore(InputStream storeLocation, char[] storePassword, String type) static PrivateKeyloadPrivateKey(InputStream storeLocation, char[] storePassword, char[] keyPassword, String alias, String storeType) static PrivateKeyloadPrivateKey(KeyStore keyStore, char[] keyPassword, String alias) static PublicKeyloadPublicKey(InputStream storeLocation, char[] storePassword, String alias, String storeType) static PublicKeyloadPublicKey(KeyStore keyStore, String alias) static voidstatic byte[]signData(byte[] data, PrivateKey key, String signAlgo) static byte[]signData(byte[] data, PrivateKey key, String signAlgo, SecureRandom random, AlgorithmParameterSpec params) static KeyunwrapKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, KeyProperties keyProps, int wrappedKeyType) static SecretKeyunwrapSecretKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, String unwrapperKeyAlgo) static SecretKeyunwrapSecretKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, KeyProperties keyProps) static booleanverifySignature(byte[] data, byte[] signature, PublicKey key, String signAlgo) static booleanverifySignature(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)
-
Method Details
-
installBouncyCastleProvider
- Throws:
Exception
-
removeBouncyCastleProvider
public static void removeBouncyCastleProvider() -
encodeSecretKey
- Throws:
SecurityException
-
encryptSecretKey
public static String encryptSecretKey(SecretKey secretKey, PublicKey publicKey) throws SecurityException - Throws:
SecurityException
-
encryptSecretKey
public static String encryptSecretKey(SecretKey secretKey, PublicKey publicKey, KeyProperties props) throws SecurityException - Throws:
SecurityException
-
generateSecureRandomBytes
public static byte[] generateSecureRandomBytes(int size) -
getRSAPublicKey
-
getRSAPublicKey
-
getRSAPublicKey
public static RSAPublicKey getRSAPublicKey(KeyFactory factory, byte[] modulusBytes, byte[] publicExponentBytes) -
getRSAPublicKey
-
getRSAPublicKey
public static RSAPublicKey getRSAPublicKey(KeyFactory factory, BigInteger modulus, BigInteger publicExponent) -
getRSAPrivateKey
-
getRSAPrivateKey
-
getRSAPrivateKey
-
getRSAPrivateKey
public static RSAPrivateKey getRSAPrivateKey(byte[] modulusBytes, byte[] publicExponentBytes, byte[] privateExponentBytes, byte[] primePBytes, byte[] primeQBytes, byte[] primeExpPBytes, byte[] primeExpQBytes, byte[] crtCoefficientBytes) -
getECPrivateKey
-
getECPrivateKey
-
generateECKeyPair
-
getECPublicKey
-
getECPublicKey
-
getContentEncryptionCipherSpec
-
getGCMParameterSpec
-
signData
-
signData
public static byte[] signData(byte[] data, PrivateKey key, String signAlgo, SecureRandom random, AlgorithmParameterSpec params) -
getSignature
public static Signature getSignature(PrivateKey key, String signAlgo, SecureRandom random, AlgorithmParameterSpec params) -
getVerificationSignature
public static Signature getVerificationSignature(PublicKey key, String signAlgo, AlgorithmParameterSpec params) -
verifySignature
-
verifySignature
public static boolean verifySignature(byte[] data, byte[] signature, PublicKey key, String signAlgo, AlgorithmParameterSpec params) -
getSecretKey
- Throws:
SecurityException
-
getSecretKey
- Throws:
SecurityException
-
getSecretKey
- Throws:
SecurityException
-
decryptSequence
public static String decryptSequence(String encodedToken, String encodedSecretKey) throws SecurityException - Throws:
SecurityException
-
decryptSequence
public static String decryptSequence(String encodedData, String encodedSecretKey, KeyProperties props) throws SecurityException - Throws:
SecurityException
-
decryptSequence
- Throws:
SecurityException
-
decryptSequence
public static String decryptSequence(String encodedData, Key secretKey, KeyProperties props) throws SecurityException - Throws:
SecurityException
-
encryptSequence
- Throws:
SecurityException
-
encryptSequence
public static String encryptSequence(String sequence, Key secretKey, KeyProperties keyProps) throws SecurityException - Throws:
SecurityException
-
encodeBytes
- Throws:
SecurityException
-
encryptBytes
- Throws:
SecurityException
-
encryptBytes
public static byte[] encryptBytes(byte[] bytes, Key secretKey, KeyProperties keyProps) throws SecurityException - Throws:
SecurityException
-
decryptBytes
- Throws:
SecurityException
-
decryptBytes
public static byte[] decryptBytes(byte[] bytes, Key secretKey, KeyProperties keyProps) throws SecurityException - Throws:
SecurityException
-
wrapSecretKey
public static byte[] wrapSecretKey(byte[] keyBytes, String keyAlgo, Key wrapperKey, KeyProperties wrapperKeyProps) throws SecurityException - Throws:
SecurityException
-
wrapSecretKey
public static byte[] wrapSecretKey(Key secretKey, Key wrapperKey, KeyProperties keyProps) throws SecurityException - Throws:
SecurityException
-
unwrapSecretKey
public static SecretKey unwrapSecretKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, String unwrapperKeyAlgo) throws SecurityException - Throws:
SecurityException
-
unwrapSecretKey
public static SecretKey unwrapSecretKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, KeyProperties keyProps) throws SecurityException - Throws:
SecurityException
-
unwrapKey
public static Key unwrapKey(byte[] wrappedBytes, String wrappedKeyAlgo, Key unwrapperKey, KeyProperties keyProps, int wrappedKeyType) throws SecurityException - Throws:
SecurityException
-
initCipher
public static Cipher initCipher(Key secretKey, KeyProperties keyProps, int mode) throws SecurityException - Throws:
SecurityException
-
decodeSecretKey
- Throws:
SecurityException
-
decodeSecretKey
public static SecretKey decodeSecretKey(String encodedSecretKey, String secretKeyAlgo) throws SecurityException - Throws:
SecurityException
-
decryptSecretKey
-
decryptSecretKey
public static SecretKey decryptSecretKey(String encodedEncryptedSecretKey, String secretKeyAlgo, PrivateKey privateKey) throws SecurityException - Throws:
SecurityException
-
decryptSecretKey
public static SecretKey decryptSecretKey(String encodedEncryptedSecretKey, String secretKeyAlgo, KeyProperties props, PrivateKey privateKey) throws SecurityException - Throws:
SecurityException
-
createSecretKeySpec
-
createSecretKeySpec
-
decodeSequence
- Throws:
SecurityException
-
loadCertificate
public static Certificate loadCertificate(InputStream storeLocation, char[] storePassword, String alias, String storeType) -
loadCertificate
-
encodeCertificate
-
decodeCertificate
-
loadPublicKey
public static PublicKey loadPublicKey(InputStream storeLocation, char[] storePassword, String alias, String storeType) -
loadPublicKey
-
loadKeyStore
-
loadPrivateKey
public static PrivateKey loadPrivateKey(InputStream storeLocation, char[] storePassword, char[] keyPassword, String alias, String storeType) -
loadPrivateKey
-