Skip to content

Commit 2a4ec8a

Browse files
committed
added use of local helper.
1 parent 502fddd commit 2a4ec8a

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

pg/src/main/java/org/bouncycastle/openpgp/operator/jcajce/JcePBEKeyEncryptionMethodGenerator.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -206,27 +206,20 @@ else if (encAlgorithm == SymmetricKeyAlgorithmTags.CAMELLIA_128
206206
throw new PGPException("AEAD only supported for AES and Camellia based algorithms");
207207
}
208208

209-
private static Cipher createAEADCipher(String algorithm, int aeadAlgorithm)
209+
private Cipher createAEADCipher(String algorithm, int aeadAlgorithm)
210210
throws PGPException
211211
{
212212
// Block Cipher must work on 16 byte blocks
213-
try
214-
{
215-
switch (aeadAlgorithm)
216-
{
217-
case AEADAlgorithmTags.EAX:
218-
return Cipher.getInstance(algorithm + "/EAX/NoPadding", "BC");
219-
case AEADAlgorithmTags.OCB:
220-
return Cipher.getInstance(algorithm + "/OCB/NoPadding", "BC");
221-
case AEADAlgorithmTags.GCM:
222-
return Cipher.getInstance(algorithm + "/GCM/NoPadding", "BC");
223-
default:
224-
throw new PGPException("unrecognised AEAD algorithm: " + aeadAlgorithm);
225-
}
226-
}
227-
catch (GeneralSecurityException e)
213+
switch (aeadAlgorithm)
228214
{
229-
throw new PGPException("unrecognised AEAD algorithm: " + e.getMessage(), e);
215+
case AEADAlgorithmTags.EAX:
216+
return helper.createCipher(algorithm + "/EAX/NoPadding");
217+
case AEADAlgorithmTags.OCB:
218+
return helper.createCipher(algorithm + "/OCB/NoPadding");
219+
case AEADAlgorithmTags.GCM:
220+
return helper.createCipher(algorithm + "/GCM/NoPadding");
221+
default:
222+
throw new PGPException("unrecognised AEAD algorithm: " + aeadAlgorithm);
230223
}
231224
}
232225
}

0 commit comments

Comments
 (0)