diff --git a/checkstyle.xml b/checkstyle.xml index d5c065f83..4e84392cd 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -27,9 +27,11 @@ + + diff --git a/src/main/java/com/ibm/crypto/plus/provider/AESCCMCipher.java b/src/main/java/com/ibm/crypto/plus/provider/AESCCMCipher.java index f8e0a9292..8ce92323f 100644 --- a/src/main/java/com/ibm/crypto/plus/provider/AESCCMCipher.java +++ b/src/main/java/com/ibm/crypto/plus/provider/AESCCMCipher.java @@ -233,8 +233,7 @@ protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] throw new ShortBufferException( "The output buffer is too small to hold the encryption result."); } - } else // decrypting - { + } else { // decrypting if ((output.length - outputOffset) < (input.length - tagLenInBytes)) { throw new ShortBufferException( "The output buffer is too small to hold the decryption result."); @@ -276,8 +275,7 @@ protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] } else { // else decrypting - if ((input == null) || (input.length == 0)) // If this doFinal( ) carries no data to be encrypted - { + if ((input == null) || (input.length == 0)) { // If this doFinal( ) carries no data to be encrypted return 0; } @@ -715,8 +713,7 @@ protected void engineUpdateAAD(ByteBuffer src) { if (this.authData == null) { this.authData = new byte[src.remaining()]; src.get(this.authData, 0, this.authData.length); - } else // else this.authData != null - { + } else { // else this.authData != null byte[] tempAuthData = new byte[this.authData.length + src.remaining()]; System.arraycopy(this.authData, 0, tempAuthData, 0, this.authData.length); src.get(tempAuthData, this.authData.length, src.remaining()); diff --git a/src/main/java/com/ibm/crypto/plus/provider/AESGCMCipher.java b/src/main/java/com/ibm/crypto/plus/provider/AESGCMCipher.java index 4b3047540..4508cbb66 100644 --- a/src/main/java/com/ibm/crypto/plus/provider/AESGCMCipher.java +++ b/src/main/java/com/ibm/crypto/plus/provider/AESGCMCipher.java @@ -1051,8 +1051,7 @@ protected int doUpdate(byte[] input, int inputOffset, int inputLen, byte[] outpu // GCMCipher.do_GCM_UpdForUpdateDecrypt=" + outLen); // outLen = cipher.decrypt(buffer, 0, len, output, outputOffset); - } // decrypting - else { + } else { // decrypting // OCKDebug.Msg(debPrefix, methodName, "Encrypting"); // OCKDebug.Msg(debPrefix, methodName, "FirstUpdate generateIV"); @@ -1093,8 +1092,7 @@ protected int doUpdate(byte[] input, int inputOffset, int inputLen, byte[] outpu tagLenInBytes, buffer, 0, buffered, output, outputOffset, authData, provider); // outLen = cipher.decrypt(buffer, 0, buffered, output, outputOffset); - } // decrypting - else { + } else { // decrypting outLen = GCMCipher.do_GCM_UpdForUpdateEncrypt(ockContext, Key.getValue(), IV, tagLenInBytes, buffer, 0, buffered, output, outputOffset, authData, provider); diff --git a/src/main/java/com/ibm/crypto/plus/provider/CCMParameters.java b/src/main/java/com/ibm/crypto/plus/provider/CCMParameters.java index 333efe299..a92ab0f88 100644 --- a/src/main/java/com/ibm/crypto/plus/provider/CCMParameters.java +++ b/src/main/java/com/ibm/crypto/plus/provider/CCMParameters.java @@ -111,8 +111,7 @@ protected void engineInit(byte[] encoded) throws IOException { if (value.getData().available() != 0) { throw new IOException("CCM parameter parsing error: Extra data is present."); } - } else // else no tag length present - { + } else { // else no tag length present throw new InvalidParameterException( "CCM parameters parsing error: No tag length is present."); } diff --git a/src/main/java/com/ibm/crypto/plus/provider/DESedeCipher.java b/src/main/java/com/ibm/crypto/plus/provider/DESedeCipher.java index d90af30e3..865e53c73 100644 --- a/src/main/java/com/ibm/crypto/plus/provider/DESedeCipher.java +++ b/src/main/java/com/ibm/crypto/plus/provider/DESedeCipher.java @@ -265,9 +265,7 @@ protected void engineSetMode(String mode) throws NoSuchAlgorithmException { * modeUpperCase.equals("CFB") */) { this.mode = modeUpperCase; - } /* - * else if (modeUpperCase.equals("CFB64")) { this.mode = "CFB"; } - */ else { + } else { throw new NoSuchAlgorithmException("Cipher mode: " + mode + " not found"); } } diff --git a/src/main/java/com/ibm/crypto/plus/provider/PBEKey.java b/src/main/java/com/ibm/crypto/plus/provider/PBEKey.java index ee6c820aa..70c36c5e4 100644 --- a/src/main/java/com/ibm/crypto/plus/provider/PBEKey.java +++ b/src/main/java/com/ibm/crypto/plus/provider/PBEKey.java @@ -140,8 +140,7 @@ public boolean isDestroyed() { */ @java.io.Serial private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException - { + throws IOException, ClassNotFoundException { s.defaultReadObject(); if (key == null) { throw new InvalidObjectException( diff --git a/src/main/java/com/ibm/crypto/plus/provider/PBEKeyFactory.java b/src/main/java/com/ibm/crypto/plus/provider/PBEKeyFactory.java index 5200fe4bc..e3f02f06a 100644 --- a/src/main/java/com/ibm/crypto/plus/provider/PBEKeyFactory.java +++ b/src/main/java/com/ibm/crypto/plus/provider/PBEKeyFactory.java @@ -105,8 +105,7 @@ public PBEWithHmacSHA512AndAES_256(OpenJCEPlusProvider provider) { * is inappropriate for this key factory to produce a public key. */ protected SecretKey engineGenerateSecret(KeySpec keySpec) - throws InvalidKeySpecException - { + throws InvalidKeySpecException { if (!(keySpec instanceof PBEKeySpec)) { throw new InvalidKeySpecException("Invalid key spec"); } @@ -166,8 +165,7 @@ protected KeySpec engineGetKeySpec(SecretKey key, Class keySpecCl) * this key factory. */ protected SecretKey engineTranslateKey(SecretKey key) - throws InvalidKeyException - { + throws InvalidKeyException { try { if ((key != null) && (key.getFormat() != null) && (key.getFormat().equalsIgnoreCase("RAW"))) { diff --git a/src/main/java/com/ibm/crypto/plus/provider/PBES2Parameters.java b/src/main/java/com/ibm/crypto/plus/provider/PBES2Parameters.java index 2d8db8336..9c1eacc40 100644 --- a/src/main/java/com/ibm/crypto/plus/provider/PBES2Parameters.java +++ b/src/main/java/com/ibm/crypto/plus/provider/PBES2Parameters.java @@ -179,8 +179,7 @@ abstract class PBES2Parameters extends AlgorithmParametersSpi { } protected void engineInit(AlgorithmParameterSpec paramSpec) - throws InvalidParameterSpecException - { + throws InvalidParameterSpecException { if (!(paramSpec instanceof PBEParameterSpec)) { throw new InvalidParameterSpecException ("Inappropriate parameter specification"); } @@ -190,8 +189,7 @@ protected void engineInit(AlgorithmParameterSpec paramSpec) } protected void engineInit(byte[] encoded) - throws IOException - { + throws IOException { DerValue pBES2_params = new DerValue(encoded); if (pBES2_params.tag != DerValue.tag_Sequence) { throw new IOException("PBE parameter parsing error: " @@ -318,15 +316,13 @@ private String parseES(DerValue encryptionScheme) throws IOException { } protected void engineInit(byte[] encoded, String decodingMethod) - throws IOException - { + throws IOException { engineInit(encoded); } protected T engineGetParameterSpec(Class paramSpec) - throws InvalidParameterSpecException - { + throws InvalidParameterSpecException { if (paramSpec.isAssignableFrom(PBEParameterSpec.class)) { return paramSpec.cast( new PBEParameterSpec(this.salt, this.iCount, this.cipherParam)); @@ -379,8 +375,7 @@ protected byte[] engineGetEncoded() throws IOException { } protected byte[] engineGetEncoded(String encodingMethod) - throws IOException - { + throws IOException { return engineGetEncoded(); } diff --git a/src/main/java/com/ibm/crypto/plus/provider/RSAPSSSignature.java b/src/main/java/com/ibm/crypto/plus/provider/RSAPSSSignature.java index 4fb93b74a..71bab5543 100644 --- a/src/main/java/com/ibm/crypto/plus/provider/RSAPSSSignature.java +++ b/src/main/java/com/ibm/crypto/plus/provider/RSAPSSSignature.java @@ -381,17 +381,13 @@ protected void engineSetParameter(AlgorithmParameterSpec params) || mgfMessageDigest.equalsIgnoreCase("SHA")) { throwException = false; } - } - - else if (messageDigest.equalsIgnoreCase("SHA224") + } else if (messageDigest.equalsIgnoreCase("SHA224") || messageDigest.equalsIgnoreCase("SHA-224")) { if (mgfMessageDigest.equalsIgnoreCase("SHA224") || mgfMessageDigest.equalsIgnoreCase("SHA-224")) { throwException = false; } - } - - else if (messageDigest.equalsIgnoreCase("SHA256") + } else if (messageDigest.equalsIgnoreCase("SHA256") || messageDigest.equalsIgnoreCase("SHA-256") || messageDigest.equalsIgnoreCase("SHA2")) { if (mgfMessageDigest.equalsIgnoreCase("SHA256") @@ -399,9 +395,7 @@ else if (messageDigest.equalsIgnoreCase("SHA256") || mgfMessageDigest.equalsIgnoreCase("SHA2")) { throwException = false; } - } - - else if (messageDigest.equalsIgnoreCase("SHA384") + } else if (messageDigest.equalsIgnoreCase("SHA384") || messageDigest.equalsIgnoreCase("SHA-384") || messageDigest.equalsIgnoreCase("SHA3")) { if (mgfMessageDigest.equalsIgnoreCase("SHA384") @@ -409,9 +403,7 @@ else if (messageDigest.equalsIgnoreCase("SHA384") || mgfMessageDigest.equalsIgnoreCase("SHA3")) { throwException = false; } - } - - else if (messageDigest.equalsIgnoreCase("SHA512") + } else if (messageDigest.equalsIgnoreCase("SHA512") || messageDigest.equalsIgnoreCase("SHA-512") || messageDigest.equalsIgnoreCase("SHA5")) { if (mgfMessageDigest.equalsIgnoreCase("SHA512") @@ -419,9 +411,7 @@ else if (messageDigest.equalsIgnoreCase("SHA512") || mgfMessageDigest.equalsIgnoreCase("SHA5")) { throwException = false; } - } - - else if (messageDigest.equalsIgnoreCase("SHA512/224") + } else if (messageDigest.equalsIgnoreCase("SHA512/224") || messageDigest.equalsIgnoreCase("SHA-512/224")) { if (mgfMessageDigest.equalsIgnoreCase("SHA512/224") || mgfMessageDigest.equalsIgnoreCase("SHA-512/224")) { diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestAES.java b/src/test/java/ibm/jceplus/junit/base/BaseTestAES.java index 18191204c..0794b12ef 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestAES.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestAES.java @@ -781,9 +781,7 @@ protected void encryptDecrypt(String algorithm, boolean requireLengthMultipleBlo // Run encrypt/decrypt test using just doFinal calls // protected void encryptDecryptDoFinal(String algorithm, boolean requireLengthMultipleBlockSize, - AlgorithmParameters algParams, byte[] message, Cipher cp) throws Exception - - { + AlgorithmParameters algParams, byte[] message, Cipher cp) throws Exception { if (algParams == null) { cp.init(Cipher.ENCRYPT_MODE, key); } else { @@ -914,9 +912,7 @@ protected void encryptDecryptPartialUpdate(String algorithm, // protected void encryptDecryptReuseObject(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message, Cipher cp) - throws Exception - - { + throws Exception { if (algParams == null) { cp.init(Cipher.ENCRYPT_MODE, key); } else { @@ -960,9 +956,7 @@ protected void encryptDecryptReuseObject(String algorithm, // protected void encryptDecryptDoFinalCopySafe(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message, Cipher cp) - throws Exception - - { + throws Exception { if (algParams == null) { cp.init(Cipher.ENCRYPT_MODE, key); } else { @@ -1007,9 +1001,7 @@ protected void encryptDecryptDoFinalCopySafe(String algorithm, // protected void encryptDecryptUpdateCopySafe(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message, Cipher cp) - throws Exception - - { + throws Exception { if (algParams == null) { cp.init(Cipher.ENCRYPT_MODE, key); } else { diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCM.java b/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCM.java index 801f0953f..03ac84835 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCM.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCM.java @@ -201,12 +201,12 @@ public void testAESCCM() throws Exception { if (printJunitTrace) System.out.println(toHexString(cipherText)); } - } else // else cipherText == null - { - if (printJunitTrace) + } else { // else cipherText == null + if (printJunitTrace) { System.out.println( "BaseTestAESCCM.java: testAESCCM(): ERROR: The encrypted text is NULL. Iteration counter = " + iterationCounter); + } RuntimeException rtex = new RuntimeException(); rtex.printStackTrace(System.out); Assertions.fail(); @@ -370,9 +370,7 @@ private byte[] encrypt(byte[] plaintext, SecretKey key, byte[] IV, int ccmTagLen // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 1) { + } else if (whichMethod == 1) { if (printJunitTrace) System.out.println("BaseTestAESCCM.java: encrypt(): METHOD CHOSEN = 1"); @@ -393,9 +391,7 @@ else if (whichMethod == 1) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 2) { + } else if (whichMethod == 2) { if (printJunitTrace) System.out.println("BaseTestAESCCM.java: encrypt(): METHOD CHOSEN = 2"); int outputSizeNeeded = cipher.getOutputSize(plaintext.length); @@ -434,9 +430,7 @@ else if (whichMethod == 2) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 3) { + } else if (whichMethod == 3) { if (printJunitTrace) System.out.println("BaseTestAESCCM.java: encrypt(): METHOD CHOSEN = 3"); int outputSizeNeeded = cipher.getOutputSize(plaintext.length); @@ -476,9 +470,7 @@ else if (whichMethod == 3) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 4) { + } else if (whichMethod == 4) { if (printJunitTrace) System.out.println("BaseTestAESCCM.java: encrypt(): METHOD CHOSEN = 4"); @@ -629,9 +621,7 @@ private String decrypt(byte[] cipherText, SecretKey key, byte[] IV, int ccmTagLe // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 1) { + } else if (whichMethod == 1) { if (printJunitTrace) System.out.println("BaseTestAESCCM.java: decrypt(): METHOD CHOSEN = 1"); @@ -654,9 +644,7 @@ else if (whichMethod == 1) { decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 2) { + } else if (whichMethod == 2) { if (printJunitTrace) System.out.println("BaseTestAESCCM.java: decrypt(): METHOD CHOSEN = 2"); int outputSizeNeeded = cipher.getOutputSize(cipherText.length); @@ -695,9 +683,7 @@ else if (whichMethod == 2) { // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 3) { + } else if (whichMethod == 3) { if (printJunitTrace) System.out.println("BaseTestAESCCM.java: decrypt(): METHOD CHOSEN = 3"); int outputSizeNeeded = cipher.getOutputSize(cipherText.length); @@ -736,9 +722,7 @@ else if (whichMethod == 3) { // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 4) { + } else if (whichMethod == 4) { if (printJunitTrace) System.out.println("BaseTestAESCCM.java: decrypt(): METHOD CHOSEN = 4"); int outputSizeNeeded = cipher.getOutputSize(cipherText.length); @@ -780,7 +764,6 @@ else if (whichMethod == 4) { decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); } - } catch (AEADBadTagException abte) { if (printJunitTrace) System.out.println( diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCM2.java b/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCM2.java index 9a866f715..416b2ae94 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCM2.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCM2.java @@ -202,8 +202,7 @@ public void testAESCCM() throws Exception { if (printJunitTrace) System.out.println(toHexString(cipherText)); } - } else // else cipherText == null - { + } else { // else cipherText == null if (printJunitTrace) System.out.println( "BaseTestAESCCM2.java: testAESCCM(): ERROR: The encrypted text is NULL. Iteration counter = " @@ -387,9 +386,7 @@ private byte[] encrypt(byte[] plaintext, SecretKey key, byte[] IV, int ccmTagLen // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 1) { + } else if (whichMethod == 1) { if (printJunitTrace) System.out.println("BaseTestAESCCM2.java: encrypt(): METHOD CHOSEN = 1"); @@ -410,9 +407,7 @@ else if (whichMethod == 1) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 2) { + } else if (whichMethod == 2) { if (printJunitTrace) System.out.println("BaseTestAESCCM2.java: encrypt(): METHOD CHOSEN = 2"); int outputSizeNeeded = cipher.getOutputSize(plaintext.length); @@ -451,9 +446,7 @@ else if (whichMethod == 2) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 3) { + } else if (whichMethod == 3) { if (printJunitTrace) System.out.println("BaseTestAESCCM2.java: encrypt(): METHOD CHOSEN = 3"); int outputSizeNeeded = cipher.getOutputSize(plaintext.length); @@ -493,9 +486,7 @@ else if (whichMethod == 3) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 4) { + } else if (whichMethod == 4) { if (printJunitTrace) System.out.println("BaseTestAESCCM2.java: encrypt(): METHOD CHOSEN = 4"); @@ -661,9 +652,7 @@ private String decrypt(byte[] cipherText, SecretKey key, byte[] IV, int ccmTagLe // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 1) { + } else if (whichMethod == 1) { if (printJunitTrace) System.out.println("BaseTestAESCCM2.java: decrypt(): METHOD CHOSEN = 1"); @@ -686,9 +675,7 @@ else if (whichMethod == 1) { decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 2) { + } else if (whichMethod == 2) { if (printJunitTrace) System.out.println("BaseTestAESCCM2.java: decrypt(): METHOD CHOSEN = 2"); int outputSizeNeeded = cipher.getOutputSize(cipherText.length); @@ -727,9 +714,7 @@ else if (whichMethod == 2) { // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 3) { + } else if (whichMethod == 3) { if (printJunitTrace) System.out.println("BaseTestAESCCM2.java: decrypt(): METHOD CHOSEN = 3"); int outputSizeNeeded = cipher.getOutputSize(cipherText.length); @@ -768,9 +753,7 @@ else if (whichMethod == 3) { // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 4) { + } else if (whichMethod == 4) { if (printJunitTrace) System.out.println("BaseTestAESCCM2.java: decrypt(): METHOD CHOSEN = 4"); int outputSizeNeeded = cipher.getOutputSize(cipherText.length); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCMInteropBC.java b/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCMInteropBC.java index 9126fc7c9..dd38712bb 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCMInteropBC.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestAESCCMInteropBC.java @@ -77,20 +77,19 @@ public void testAESCCM() throws Exception { if (whichEncryptionProvider == 0) { encryptionProvider = getProviderName(); decryptionProvider = getInteropProviderName(); - } else // else whichEncryptionProvider == 1 - { + } else { // else whichEncryptionProvider == 1 encryptionProvider = getInteropProviderName(); decryptionProvider = getProviderName(); } - if (printJunitTrace) + if (printJunitTrace) { System.out.println( "BaseTestInteropBC.java: testAESCCM(): The encryption provider is: " + encryptionProvider); - if (printJunitTrace) System.out.println( "BaseTestInteropBC.java: testAESCCM(): The decryption provider is: " + decryptionProvider); + } // Select which plainText string to encrypt/decrypt. @@ -226,8 +225,7 @@ public void testAESCCM() throws Exception { if (printJunitTrace) System.out.println(toHexString(cipherText)); } - } else // else cipherText == null - { + } else { // else cipherText == null if (printJunitTrace) System.out.println( "BaseTestInteropBC.java: testAESCCM(): ERROR: The encrypted text is NULL. Iteration counter = " @@ -386,9 +384,7 @@ private static byte[] encrypt(byte[] plaintext, byte[] aesKeyBytes, byte[] IV, i // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 1) { + } else if (whichMethod == 1) { if (printJunitTrace) System.out .println("BaseTestInteropBC.java: encrypt(): METHOD CHOSEN = 1"); @@ -398,9 +394,7 @@ else if (whichMethod == 1) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 2) { + } else if (whichMethod == 2) { if (printJunitTrace) System.out .println("BaseTestInteropBC.java: encrypt(): METHOD CHOSEN = 2"); @@ -427,9 +421,7 @@ else if (whichMethod == 2) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 3) { + } else if (whichMethod == 3) { if (printJunitTrace) System.out .println("BaseTestInteropBC.java: encrypt(): METHOD CHOSEN = 3"); @@ -456,9 +448,7 @@ else if (whichMethod == 3) { // All the encryption was performed on Cipher.doFinal( ) cipherText = new byte[cipherText2.length]; System.arraycopy(cipherText2, 0, cipherText, 0, cipherText2.length); - } - - else if (whichMethod == 4) { + } else if (whichMethod == 4) { if (printJunitTrace) System.out .println("BaseTestInteropBC.java: encrypt(): METHOD CHOSEN = 4"); @@ -516,15 +506,14 @@ else if (whichMethod == 4) { return cipherText; - } else // else if the encryption provider is "BC". - { + } else { // else if the encryption provider is "BC". // AES/CCM for BouncyCastle is a proprietary cipher implementation that // is dissimilar to cipher implementations developed by Oracle or IBM. - if (printJunitTrace) + if (printJunitTrace) { System.out.println("\nThe plain text to be encoded is:"); - if (printJunitTrace) System.out.println(toHexString(plaintext)); + } org.bouncycastle.crypto.MultiBlockCipher engine = org.bouncycastle.crypto.engines.AESEngine.newInstance(); org.bouncycastle.crypto.params.AEADParameters params = new org.bouncycastle.crypto.params.AEADParameters( @@ -640,9 +629,7 @@ private static String decrypt(byte[] cipherText, byte[] aesKeyBytes, byte[] IV, // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 1) { + } else if (whichMethod == 1) { if (printJunitTrace) System.out .println("BaseTestInteropBC.java: decrypt(): METHOD CHOSEN = 1"); @@ -654,9 +641,7 @@ else if (whichMethod == 1) { // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 2) { + } else if (whichMethod == 2) { if (printJunitTrace) System.out .println("BaseTestInteropBC.java: decrypt(): METHOD CHOSEN = 2"); @@ -683,12 +668,10 @@ else if (whichMethod == 2) { // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 3) { - if (printJunitTrace) - System.out - .println("BaseTestInteropBC.java: decrypt(): METHOD CHOSEN = 3"); + } else if (whichMethod == 3) { + if (printJunitTrace) { + System.out.println("BaseTestInteropBC.java: decrypt(): METHOD CHOSEN = 3"); + } int outputSizeNeeded = cipher.getOutputSize(cipherText.length); if (printJunitTrace) System.out.println( @@ -712,9 +695,7 @@ else if (whichMethod == 3) { // All the decryption was performed on Cipher.doFinal( ) decryptedText = new byte[decryptedText2.length]; System.arraycopy(decryptedText2, 0, decryptedText, 0, decryptedText2.length); - } - - else if (whichMethod == 4) { + } else if (whichMethod == 4) { if (printJunitTrace) System.out .println("BaseTestInteropBC.java: decrypt(): METHOD CHOSEN = 4"); @@ -774,8 +755,7 @@ else if (whichMethod == 4) { return new String(decryptedText); - } else // else if the decryption provider is "BC". - { + } else { // else if the decryption provider is "BC". // AES/CCM for BouncyCastle is a proprietary cipher implementation that // is dissimilar to cipher implementations developed by Oracle or IBM. diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestAESCipherInputStreamExceptions.java b/src/test/java/ibm/jceplus/junit/base/BaseTestAESCipherInputStreamExceptions.java index 7762f7960..e63a4cc44 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestAESCipherInputStreamExceptions.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestAESCipherInputStreamExceptions.java @@ -249,7 +249,7 @@ public void do_cbc_readAllIllegalBlockSize() throws Exception { fail("IOException expected."); } catch (IOException e) { // We expect a IOException. - }; + } } /** diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestAESGCM.java b/src/test/java/ibm/jceplus/junit/base/BaseTestAESGCM.java index 447489f3a..be8c69593 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestAESGCM.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestAESGCM.java @@ -865,9 +865,7 @@ protected void encryptDecrypt(String algorithm, boolean requireLengthMultipleBlo // Run encrypt/decrypt test using just doFinal calls // protected void encryptDecryptDoFinal(String algorithm, boolean requireLengthMultipleBlockSize, - AlgorithmParameters algParams, byte[] message) throws Exception - - { + AlgorithmParameters algParams, byte[] message) throws Exception { Cipher cp = Cipher.getInstance(algorithm, getProviderName()); if (algParams == null) { cp.init(Cipher.ENCRYPT_MODE, key); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestAESGCMUpdate.java b/src/test/java/ibm/jceplus/junit/base/BaseTestAESGCMUpdate.java index 1f934bd6f..6a7a7760d 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestAESGCMUpdate.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestAESGCMUpdate.java @@ -271,9 +271,7 @@ public void testCaseShortBufferError4() throws Exception { //System.out.println ("decryptedText = " + decryptedText); assertTrue(Arrays.equals(decryptedText, plainTextBytes)); - } - - catch (ShortBufferException sxe) { + } catch (ShortBufferException sxe) { assertTrue(true); } catch (Exception ex) { ex.printStackTrace(); @@ -409,12 +407,9 @@ public void testCaseCallUpdateAfterFinal() throws Exception { } catch (IllegalStateException ex) { //ex.printStackTrace(); assertTrue(true); - } - - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); assertTrue(false); - } try { diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestAESInterop.java b/src/test/java/ibm/jceplus/junit/base/BaseTestAESInterop.java index 5da905e0c..fc3161a99 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestAESInterop.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestAESInterop.java @@ -618,9 +618,7 @@ protected void encryptDecrypt(String algorithm, boolean requireLengthMultipleBlo // protected void encryptDecryptDoFinal(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message, Cipher cpA, Cipher cpB) - throws Exception - - { + throws Exception { if (algParams == null) { cpA.init(Cipher.ENCRYPT_MODE, key); } else { @@ -774,9 +772,7 @@ protected void encryptDecryptPartialUpdate(String algorithm, // protected void encryptDecryptReuseObject(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message, - Cipher cpA, Cipher cpB) throws Exception - - { + Cipher cpA, Cipher cpB) throws Exception { if (algParams == null) { cpA.init(Cipher.ENCRYPT_MODE, key); @@ -821,9 +817,7 @@ protected void encryptDecryptReuseObject(String algorithm, // protected void encryptDecryptDoFinalCopySafe(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message, - Cipher cpA, Cipher cpB) throws Exception - - { + Cipher cpA, Cipher cpB) throws Exception { if (algParams == null) { cpA.init(Cipher.ENCRYPT_MODE, key); } else { @@ -867,9 +861,7 @@ protected void encryptDecryptDoFinalCopySafe(String algorithm, // protected void encryptDecryptUpdateCopySafe(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message, - Cipher cpA, Cipher cpB) throws Exception - - { + Cipher cpA, Cipher cpB) throws Exception { if (algParams == null) { cpA.init(Cipher.ENCRYPT_MODE, key); } else { diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestDESede.java b/src/test/java/ibm/jceplus/junit/base/BaseTestDESede.java index fc891ca6a..87a53a71f 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestDESede.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestDESede.java @@ -1088,9 +1088,7 @@ protected void encryptDecrypt(String algorithm, boolean requireLengthMultipleBlo } protected void encryptDecryptDoFinal(String algorithm, boolean requireLengthMultipleBlockSize, - AlgorithmParameters algParams, byte[] message) throws Exception - - { + AlgorithmParameters algParams, byte[] message) throws Exception { if (isTransformationValidButUnsupported(algorithm)) { return; } @@ -1244,9 +1242,7 @@ protected void encryptDecryptPartialUpdate(String algorithm, // protected void encryptDecryptReuseObject(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message) - throws Exception - - { + throws Exception { if (isTransformationValidButUnsupported(algorithm)) { return; } @@ -1300,9 +1296,7 @@ protected void encryptDecryptReuseObject(String algorithm, // protected void encryptDecryptDoFinalCopySafe(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message) - throws Exception - - { + throws Exception { if (isTransformationValidButUnsupported(algorithm)) { return; } @@ -1355,9 +1349,7 @@ protected void encryptDecryptDoFinalCopySafe(String algorithm, // protected void encryptDecryptUpdateCopySafe(String algorithm, boolean requireLengthMultipleBlockSize, AlgorithmParameters algParams, byte[] message) - throws Exception - - { + throws Exception { if (isTransformationValidButUnsupported(algorithm)) { return; } diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestDH.java b/src/test/java/ibm/jceplus/junit/base/BaseTestDH.java index 55ede8821..9dac1b76b 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestDH.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestDH.java @@ -268,9 +268,7 @@ void compute_dh_key(String idString, AlgorithmParameterSpec algParameterSpec) throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestDHInterop.java b/src/test/java/ibm/jceplus/junit/base/BaseTestDHInterop.java index 720d2915d..135198ece 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestDHInterop.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestDHInterop.java @@ -114,9 +114,7 @@ void compute_dh_key(String idString, AlgorithmParameterSpec algParameterSpec, St throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestECDH.java b/src/test/java/ibm/jceplus/junit/base/BaseTestECDH.java index ae26350d3..3a5ce01fb 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestECDH.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestECDH.java @@ -227,9 +227,7 @@ void compute_ecdh_key(String idString, AlgorithmParameterSpec algParameterSpec) throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestECDHInterop.java b/src/test/java/ibm/jceplus/junit/base/BaseTestECDHInterop.java index f2ff6aad7..5f1043e05 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestECDHInterop.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestECDHInterop.java @@ -196,9 +196,7 @@ void compute_ecdh_key(String idString, AlgorithmParameterSpec algParameterSpec, throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestHKDF.java b/src/test/java/ibm/jceplus/junit/base/BaseTestHKDF.java index b682eaf8a..b5c87f41a 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestHKDF.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestHKDF.java @@ -643,9 +643,7 @@ byte[] compute_ecdh_key(String idString, AlgorithmParameterSpec algParameterSpec throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestHKDFInterop.java b/src/test/java/ibm/jceplus/junit/base/BaseTestHKDFInterop.java index 806d7b494..55fd30964 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestHKDFInterop.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestHKDFInterop.java @@ -498,9 +498,7 @@ byte[] compute_ecdh_key(String idString, AlgorithmParameterSpec algParameterSpec throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestMiniRSAPSS2.java b/src/test/java/ibm/jceplus/junit/base/BaseTestMiniRSAPSS2.java index 495d7e4ec..e709f7482 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestMiniRSAPSS2.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestMiniRSAPSS2.java @@ -138,9 +138,7 @@ public void testRSAPSS() throws Exception { "================ BEGINNING OF testRSAPSS() ================================"); int ii = 0; - for (; ii < 1; ii++) // For each RSA key size - { - + for (; ii < 1; ii++) { // For each RSA key size if (signingProviderName.equalsIgnoreCase("OpenJCEPlus")) { if (ii == 0) { rsaKeyPair = rsaKeyPair_OpenJCEPlus[0]; // RSA keylength 3072 @@ -163,17 +161,14 @@ public void testRSAPSS() throws Exception { - for (int jj = 0; jj < 3; jj++) // For each dataToBeSigned string (differing lengths) - { - + for (int jj = 0; jj < 3; jj++) { // For each dataToBeSigned string (differing lengths) if (jj == 0) { dataToBeSigned = dataToBeSignedShort; } else if (jj == 1) { dataToBeSigned = dataToBeSignedMedium; } else if (jj == 2) { dataToBeSigned = dataToBeSignedLong; - } else // added to make the compiler happy - { + } else { // added to make the compiler happy dataToBeSigned = dataToBeSignedLong; } @@ -2203,8 +2198,7 @@ private boolean doSignature(byte[] dataToBeSigned, KeyPair rsaKeyPair, "BaseTestRSAPSS2.java: doSignature(): NOT PERFORMING KEY TRANSLATION. signingProviderName = verifyingProviderName"); // then no key translation is necessary translatedPublicKey = (RSAPublicKey) (rsaKeyPair.getPublic()); - } else // else translate the RSA public key for the verifying provider - { + } else { // else translate the RSA public key for the verifying provider System.out.println( "BaseTestRSAPSS2.java: doSignature(): PERFORMING KEY TRANSLATION. signingProviderName != verifyingProviderName"); KeyFactory myKeyFactory = KeyFactory.getInstance("RSA", verifyingProviderName); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestPQCSignatureWithAliases.java b/src/test/java/ibm/jceplus/junit/base/BaseTestPQCSignatureWithAliases.java index 2974bec94..8dee4eaca 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestPQCSignatureWithAliases.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestPQCSignatureWithAliases.java @@ -40,22 +40,15 @@ public void testPQCKeys(String pqcKeyType) { byte[] longMessageToBeSigned = "Long msg 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".getBytes(); - for (int i=0; i<10; i++) // Execute 10 times - { - + for (int i=0; i<10; i++) { // Execute 10 times // THIS TEST CASE WILL EXECUTE 3 TIMES. ONCE FOR EACH MESSAGE SIZE. for (int whichMessageToSign=0; whichMessageToSign<=2; whichMessageToSign++) { - if ( whichMessageToSign == 0 ) - { + if ( whichMessageToSign == 0 ) { messageToBeSigned = shortMessageToBeSigned; - } - else if ( whichMessageToSign == 1 ) - { + } else if ( whichMessageToSign == 1 ) { messageToBeSigned = mediumMessageToBeSigned; - } - else if ( whichMessageToSign == 2 ) - { + } else if ( whichMessageToSign == 2 ) { messageToBeSigned = longMessageToBeSigned; } @@ -112,8 +105,7 @@ public void testPQCSignature(String Algorithm, byte[] dataToBeSigned) throws Exc //System.out.println("testPQCSignature( ): Calling generateKeyPair( " + Algorithm + " ) "); KeyPair keyPair = generateKeyPair(Algorithm); //System.out.println("testPQCSignature( ): Returned from generateKeyPair( " + Algorithm + " ) "); - if (keyPair == null) - { + if (keyPair == null) { System.out.println("generateKeyPair( ): The provider name is: " + getProviderName( ) ); System.out.println("testPQCSignature( ): Returned from generateKeyPair( " + Algorithm + " ) "); System.out.println("testPQCSignature( ): The returned keyPair is NULL"); @@ -124,8 +116,7 @@ public void testPQCSignature(String Algorithm, byte[] dataToBeSigned) throws Exc //System.out.println("\ntestPQCSignature(): The publicKey is: " + publicKey.toString() ); //System.out.println("\ntestPQCSignature(): The privateKey is: " + privateKey.toString() ); // This probably won't work. - if (!(Algorithm.contains("KEM")|| Algorithm.contains("2.16.840.1.101.3.4.4"))) - { + if (!(Algorithm.contains("KEM")|| Algorithm.contains("2.16.840.1.101.3.4.4"))) { //System.out.println("testPQCSignature( ): Calling doSignVerify( )"); doSignVerify(Algorithm, dataToBeSigned, privateKey, publicKey); // Do Sign/Verify //System.out.println("testPQCSignature( ): Returned from doSignVerify( )"); @@ -150,8 +141,7 @@ protected void doSignVerify(String sigAlgo, byte[] message, PrivateKey privateKe // Verify signature signature.initVerify(publicKey); signature.update(message); - if ( signature.verify(signedBytes) == false ) - { + if ( signature.verify(signedBytes) == false ) { System.out.println("doSignVerify(): Signature verification FAILURE = "+sigAlgo); } else { // System.out.println("doSignVerify(): Signature verification SUCCESSFUL"); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAKeyInterop.java b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAKeyInterop.java index 5d7926d4d..f6197c4b4 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAKeyInterop.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAKeyInterop.java @@ -446,9 +446,7 @@ public void testSignPlusAndVerifyJCE() { verifyingJCE.initVerify(rsaPubJCE); verifyingJCE.update(origMsg); assertTrue(verifyingJCE.verify(signedBytesPlus), "Signature verification"); - } - - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); assertTrue(false, "SignAndVerify failed"); } diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAKeyInteropBC.java b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAKeyInteropBC.java index 74a2f4218..a46e73ebb 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAKeyInteropBC.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAKeyInteropBC.java @@ -466,9 +466,7 @@ public void testSignPlusAndVerifyBC() { verifyingBC.initVerify(rsaPubBC); verifyingBC.update(origMsg); assertTrue(verifyingBC.verify(signedBytesPlus), "Signature verification"); - } - - catch (Exception ex) { + } catch (Exception ex) { ex.printStackTrace(); assertTrue(false, "SignAndVerify failed"); } diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSS2.java b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSS2.java index 7961423ca..9827eeeb3 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSS2.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSS2.java @@ -225,8 +225,7 @@ public void testRSAPSS() throws Exception { //OpenJCEPlusFIPS and SunRsaSign does not support 512 - for (int ii = 0; ii <= 5; ii++) // For each RSA key size - { + for (int ii = 0; ii <= 5; ii++) { // For each RSA key size if (signingProviderName.equalsIgnoreCase("OpenJCEPlus")) { if (ii == 0) { @@ -326,8 +325,7 @@ public void testRSAPSS() throws Exception { - for (int jj = 0; jj < 3; jj++) // For each dataToBeSigned string (differing lengths) - { + for (int jj = 0; jj < 3; jj++) { // For each dataToBeSigned string (differing lengths) if (jj == 0) { dataToBeSigned = dataToBeSignedShort; @@ -335,8 +333,7 @@ public void testRSAPSS() throws Exception { dataToBeSigned = dataToBeSignedMedium; } else if (jj == 2) { dataToBeSigned = dataToBeSignedLong; - } else // added to make the compiler happy - { + } else { // added to make the compiler happy dataToBeSigned = dataToBeSignedLong; } @@ -825,15 +822,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -847,8 +842,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -974,15 +968,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -996,12 +988,12 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { - if (printJunitTrace) + } else { // else key size > 512 + if (printJunitTrace) { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " + ex.getMessage()); + } Assertions.fail(); } } @@ -2586,15 +2578,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2608,8 +2598,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2735,15 +2724,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2757,8 +2744,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2884,15 +2870,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 1) //If key size <= 1024 - { + if (ii <= 1) { //If key size <= 1024 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 1) //If key size <= 1024 - { + if (ii <= 1) { //If key size <= 1024 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2906,8 +2890,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 1024 - { + } else { // else key size > 1024 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -3032,15 +3015,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 2) //If key size <= 2048 - { + if (ii <= 2) { //If key size <= 2048 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 2) //If key size <= 2048 - { + if (ii <= 2) { //If key size <= 2048 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -3054,8 +3035,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 2048 - { + } else { // else key size > 2048 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -3860,8 +3840,7 @@ private static boolean doSignature(byte[] dataToBeSigned, KeyPair rsaKeyPair, "BaseTestRSAPSS2.java: doSignature(): NOT PERFORMING KEY TRANSLATION. signingProviderName = verifyingProviderName"); // then no key translation is necessary translatedPublicKey = (RSAPublicKey) (rsaKeyPair.getPublic()); - } else // else translate the RSA public key for the verifying provider - { + } else { // else translate the RSA public key for the verifying provider if (printJunitTrace) System.out.println( "BaseTestRSAPSS2.java: doSignature(): PERFORMING KEY TRANSLATION. signingProviderName != verifyingProviderName"); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSSInterop2.java b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSSInterop2.java index 8b07c5e61..d3559e289 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSSInterop2.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSSInterop2.java @@ -227,9 +227,7 @@ public void testRSAPSS() throws Exception { // testRSAPSS(ibm.jceplus.junit.openjceplus.TestRSAPSSInterop2)java.security.InvalidKeyException: java.security.SignatureException: Key is too short, need min 70 //OpenJCEPlusFIPS and SunRsaSign does not support 512 - for (int ii = 1; ii <= 5; ii++) // For each RSA key size - { - + for (int ii = 1; ii <= 5; ii++) { // For each RSA key size if (signingProviderName.equalsIgnoreCase("OpenJCEPlus")) { if (ii == 0) { rsaKeyPair = rsaKeyPair_OpenJCEPlus[0]; // RSA keylength 512 @@ -332,17 +330,14 @@ public void testRSAPSS() throws Exception { - for (int jj = 0; jj < 3; jj++) // For each dataToBeSigned string (differing lengths) - { - + for (int jj = 0; jj < 3; jj++) { // For each dataToBeSigned string (differing lengths) if (jj == 0) { dataToBeSigned = dataToBeSignedShort; } else if (jj == 1) { dataToBeSigned = dataToBeSignedMedium; } else if (jj == 2) { dataToBeSigned = dataToBeSignedLong; - } else // added to make the compiler happy - { + } else { // added to make the compiler happy dataToBeSigned = dataToBeSignedLong; } @@ -784,15 +779,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -806,8 +799,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -919,15 +911,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -941,8 +931,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2376,15 +2365,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2398,8 +2385,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2511,15 +2497,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2533,8 +2517,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2646,15 +2629,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 1) //if key size <= 1024 - { + if (ii <= 1) { //if key size <= 1024 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 1) //if key size <= 1024 - { + if (ii <= 1) { //if key size <= 1024 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2668,12 +2649,12 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 1024 - { - if (printJunitTrace) + } else { // else key size > 1024 + if (printJunitTrace) { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " + ex.getMessage()); + } Assertions.fail(); } } @@ -2780,15 +2761,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 2) //if key size <= 2048 - { + if (ii <= 2) { //if key size <= 2048 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 2) //if key size <= 2048 - { + if (ii <= 2) { //if key size <= 2048 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2802,12 +2781,12 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 2048 - { - if (printJunitTrace) + } else { // else key size > 2048 + if (printJunitTrace) { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " + ex.getMessage()); + } Assertions.fail(); } } @@ -3255,15 +3234,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -3277,12 +3254,12 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { - if (printJunitTrace) + } else { // else key size > 512 + if (printJunitTrace) { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " + ex.getMessage()); + } Assertions.fail(); } } @@ -3391,15 +3368,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //if key size <= 512 - { + if (ii <= 0) { //if key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -3413,8 +3388,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -3485,13 +3459,13 @@ private static boolean doSignature(byte[] dataToBeSigned, KeyPair rsaKeyPair, // If signingProviderName == verifyingProviderName, then do not perform key translation. if (signingProviderName.equalsIgnoreCase(verifyingProviderName)) { - if (printJunitTrace) + if (printJunitTrace) { System.out.println( "BaseTestRSAPSSInterop2.java: doSignature(): NOT PERFORMING KEY TRANSLATION. signingProviderName = verifyingProviderName"); + } // then no key translation is necessary translatedPublicKey = (RSAPublicKey) (rsaKeyPair.getPublic()); - } else // else translate the RSA public key for the verifying provider - { + } else { // else translate the RSA public key for the verifying provider if (printJunitTrace) System.out.println( "BaseTestRSAPSSInterop2.java: doSignature(): PERFORMING KEY TRANSLATION. signingProviderName != verifyingProviderName"); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSSInterop3.java b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSSInterop3.java index b81be180f..bcb76682b 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSSInterop3.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestRSAPSSInterop3.java @@ -212,9 +212,7 @@ public void testRSAPSS() throws Exception { System.out.println( "================ BEGINNING OF testRSAPSS() ================================"); - for (int ii = 0; ii <= 5; ii++) // For each RSA key size - { - + for (int ii = 0; ii <= 5; ii++) { // For each RSA key size if (signingProviderName.equalsIgnoreCase("OpenJCEPlus")) { if (ii == 0) { rsaKeyPair = rsaKeyPair_OpenJCEPlus[0]; // RSA keylength 512 @@ -317,17 +315,14 @@ public void testRSAPSS() throws Exception { - for (int jj = 0; jj < 3; jj++) // For each dataToBeSigned string (differing lengths) - { - + for (int jj = 0; jj < 3; jj++) { // For each dataToBeSigned string (differing lengths) if (jj == 0) { dataToBeSigned = dataToBeSignedShort; } else if (jj == 1) { dataToBeSigned = dataToBeSignedMedium; } else if (jj == 2) { dataToBeSigned = dataToBeSignedLong; - } else // added to make the compiler happy - { + } else { // added to make the compiler happy dataToBeSigned = dataToBeSignedLong; } @@ -769,15 +764,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -791,8 +784,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -904,15 +896,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -926,8 +916,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2359,15 +2348,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2381,8 +2368,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2494,15 +2480,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2516,8 +2500,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2629,15 +2612,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 1) //If key size <= 1024 - { + if (ii <= 1) { //If key size <= 1024 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 1) //If key size <= 1024 - { + if (ii <= 1) { //If key size <= 1024 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2651,8 +2632,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 1024 - { + } else { // else key size > 1024 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -2763,15 +2743,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 2) //If key size <= 2048 - { + if (ii <= 2) { //If key size <= 2048 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 2) //If key size <= 2048 - { + if (ii <= 2) { //If key size <= 2048 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -2785,8 +2763,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 2048 - { + } else { // else key size > 2048 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -3238,15 +3215,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -3260,8 +3235,7 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { + } else { // else key size > 512 if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " @@ -3374,15 +3348,13 @@ public void testRSAPSS() throws Exception { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " = " + result); // For all key sizes and data lengths - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 fail(" testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => Instead, this test should have produced an InvalidKeyException"); } } catch (InvalidKeyException ex) { - if (ii <= 0) //If key size <= 512 - { + if (ii <= 0) { //If key size <= 512 if (ex.getMessage().indexOf("Key is too short") != -1) { if (printJunitTrace) System.out.println("testRSAPSS(): TEST RESULT #" @@ -3396,12 +3368,12 @@ public void testRSAPSS() throws Exception { + ex.getMessage()); Assertions.fail(); } - } else // else key size > 512 - { - if (printJunitTrace) + } else { // else key size > 512 + if (printJunitTrace) { System.out.println("testRSAPSS(): TEST RESULT #" + (testCaseNumber - 1) + " => An unexpected exception was thrown with message = " + ex.getMessage()); + } Assertions.fail(); } } @@ -3473,11 +3445,11 @@ private boolean doSignature(byte[] dataToBeSigned, KeyPair rsaKeyPair, "BaseTestRSAPSSInterop3.java: doSignature(): NOT PERFORMING KEY TRANSLATION. signingProviderName = verifyingProviderName"); // then no key translation is necessary translatedPublicKey = (RSAPublicKey) (rsaKeyPair.getPublic()); - } else // else translate the RSA public key for the verifying provider - { - if (printJunitTrace) + } else { // else translate the RSA public key for the verifying provider + if (printJunitTrace) { System.out.println( "BaseTestRSAPSSInterop3.java: doSignature(): PERFORMING KEY TRANSLATION. signingProviderName != verifyingProviderName"); + } KeyFactory myKeyFactory = KeyFactory.getInstance("RSA", verifyingProviderName); translatedPublicKey = (RSAPublicKey) (myKeyFactory .translateKey(rsaKeyPair.getPublic())); diff --git a/src/test/java/ibm/jceplus/junit/base/BaseTestXDH.java b/src/test/java/ibm/jceplus/junit/base/BaseTestXDH.java index 13d2506a6..11dab8471 100644 --- a/src/test/java/ibm/jceplus/junit/base/BaseTestXDH.java +++ b/src/test/java/ibm/jceplus/junit/base/BaseTestXDH.java @@ -172,9 +172,7 @@ void compute_xdh_key(String idString, NamedParameterSpec algParameterSpec) throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); diff --git a/src/test/java/ibm/jceplus/junit/base/certificateutils/CertAndKeyGen.java b/src/test/java/ibm/jceplus/junit/base/certificateutils/CertAndKeyGen.java index 334bd0666..3fa9eb697 100644 --- a/src/test/java/ibm/jceplus/junit/base/certificateutils/CertAndKeyGen.java +++ b/src/test/java/ibm/jceplus/junit/base/certificateutils/CertAndKeyGen.java @@ -795,9 +795,7 @@ public X509Certificate getSelfCertificate(X500Name myname, Date firstDate, long public X509Certificate dogetSelfCertificate(X500Name myname, Date firstDate, long validity, CertificateExtensions ext) throws CertificateException, InvalidKeyException, SignatureException, - NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException - - { + NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { X509CertImpl cert; Date lastDate; diff --git a/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressAESGCM.java b/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressAESGCM.java index 723fce4d4..d1a725986 100644 --- a/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressAESGCM.java +++ b/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressAESGCM.java @@ -119,9 +119,7 @@ protected void encryptDecrypt(String algorithm, boolean requireLengthMultipleBlo // Run encrypt/decrypt test using just doFinal calls // protected void encryptDecryptDoFinal(String algorithm, boolean requireLengthMultipleBlockSize, - AlgorithmParameters algParams, byte[] message) throws Exception - - { + AlgorithmParameters algParams, byte[] message) throws Exception { cp = Cipher.getInstance(algorithm, getProviderName()); if (algParams == null) { cp.init(Cipher.ENCRYPT_MODE, key); diff --git a/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressDH.java b/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressDH.java index 341248a09..2e1faa3ca 100644 --- a/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressDH.java +++ b/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressDH.java @@ -134,9 +134,7 @@ void compute_dh_key(AlgorithmParameterSpec algParameterSpec) throws NoSuchAlgori throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); diff --git a/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressXDH.java b/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressXDH.java index 9d9b42215..b205a2870 100644 --- a/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressXDH.java +++ b/src/test/java/ibm/jceplus/junit/base/memstress/BaseTestMemStressXDH.java @@ -127,9 +127,7 @@ void compute_xdh_key(String idString, NamedParameterSpec algParameterSpec) throw e; } - try - - { + try { kpgB.initialize(algParameterSpec); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace();