use of java.security.spec.AlgorithmParameterSpec in project cxf by apache.
the class WrappedKeyDecryptionAlgorithm method getDecryptedContentEncryptionKey.
public byte[] getDecryptedContentEncryptionKey(JweDecryptionInput jweDecryptionInput) {
KeyProperties keyProps = new KeyProperties(getKeyEncryptionAlgorithm(jweDecryptionInput));
AlgorithmParameterSpec spec = getAlgorithmParameterSpec(jweDecryptionInput);
if (spec != null) {
keyProps.setAlgoSpec(spec);
}
if (!unwrap) {
keyProps.setBlockSize(getKeyCipherBlockSize());
return CryptoUtils.decryptBytes(getEncryptedContentEncryptionKey(jweDecryptionInput), getCekDecryptionKey(), keyProps);
}
return CryptoUtils.unwrapSecretKey(getEncryptedContentEncryptionKey(jweDecryptionInput), getContentEncryptionAlgorithm(jweDecryptionInput), getCekDecryptionKey(), keyProps).getEncoded();
}
use of java.security.spec.AlgorithmParameterSpec in project xDrip by NightscoutFoundation.
the class SendCalibrations method encrypt.
public static byte[] encrypt(byte[] ivBytes, byte[] keyBytes, byte[] textBytes) {
try {
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
SecretKeySpec newKey = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, newKey, ivSpec);
return cipher.doFinal(textBytes);
} catch (Exception e) {
System.err.println("Error during encryption: " + e.toString());
return errorbyte;
}
}
use of java.security.spec.AlgorithmParameterSpec in project xDrip by NightscoutFoundation.
the class CipherUtils method encrypt.
public static byte[] encrypt(byte[] ivBytes, byte[] keyBytes, byte[] textBytes) {
try {
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
SecretKeySpec newKey = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, newKey, ivSpec);
return cipher.doFinal(textBytes);
} catch (Exception e) {
Log.e(TAG, "Error during encryption: " + e.toString());
return errorbyte;
}
}
use of java.security.spec.AlgorithmParameterSpec in project xDrip-plus by jamorham.
the class SendCalibrations method encrypt.
public static byte[] encrypt(byte[] ivBytes, byte[] keyBytes, byte[] textBytes) {
try {
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
SecretKeySpec newKey = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, newKey, ivSpec);
return cipher.doFinal(textBytes);
} catch (Exception e) {
System.err.println("Error during encryption: " + e.toString());
return errorbyte;
}
}
use of java.security.spec.AlgorithmParameterSpec in project xDrip-plus by jamorham.
the class CipherUtils method decrypt.
public static byte[] decrypt(byte[] ivBytes, byte[] keyBytes, byte[] textBytes) {
try {
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
SecretKeySpec newKey = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, newKey, ivSpec);
return cipher.doFinal(textBytes);
} catch (Exception e) {
return errorbyte;
}
}
Aggregations