You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2016/06/30 18:13:35 UTC

commons-crypto git commit: Fix format nits.

Repository: commons-crypto
Updated Branches:
  refs/heads/master de22a5b1e -> 276b4ba2d


Fix format nits.

Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/276b4ba2
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/276b4ba2
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/276b4ba2

Branch: refs/heads/master
Commit: 276b4ba2d81e4881b604725273629d066e8d982d
Parents: de22a5b
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Jun 30 11:13:32 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Jun 30 11:13:32 2016 -0700

----------------------------------------------------------------------
 .../commons/crypto/jna/OpenSslJnaCipher.java      | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/276b4ba2/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
index 75296b1..9d76817 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJnaCipher.java
@@ -103,19 +103,21 @@ class OpenSslJnaCipher implements CryptoCipher {
         }
         
        if(algMode == AlgorithmMode.AES_CBC) {
-            switch(key.getEncoded().length) {
+            switch (key.getEncoded().length) {
                 case 16: algo = OpenSslNativeJna.EVP_aes_128_cbc(); break;
                 case 24: algo = OpenSslNativeJna.EVP_aes_192_cbc(); break;
                 case 32: algo = OpenSslNativeJna.EVP_aes_256_cbc(); break;
-                default: throw new InvalidKeyException("keysize unsupported ("+key.getEncoded().length+")");
+            default:
+                throw new InvalidKeyException("keysize unsupported (" + key.getEncoded().length + ")");
             }
 
         } else {
-            switch(key.getEncoded().length) {
+            switch (key.getEncoded().length) {
                 case 16: algo = OpenSslNativeJna.EVP_aes_128_ctr(); break;
                 case 24: algo = OpenSslNativeJna.EVP_aes_192_ctr(); break;
                 case 32: algo = OpenSslNativeJna.EVP_aes_256_ctr(); break;
-                default: throw new InvalidKeyException("keysize unsupported ("+key.getEncoded().length+")");
+            default:
+                throw new InvalidKeyException("keysize unsupported (" + key.getEncoded().length + ")");
             }
         }
         
@@ -162,7 +164,7 @@ class OpenSslJnaCipher implements CryptoCipher {
     @Override
     public int update(byte[] input, int inputOffset, int inputLen,
             byte[] output, int outputOffset) throws ShortBufferException {
-        ByteBuffer outputBuf = ByteBuffer.wrap(output, outputOffset, output.length-outputOffset);
+        ByteBuffer outputBuf = ByteBuffer.wrap(output, outputOffset, output.length - outputOffset);
         ByteBuffer inputBuf = ByteBuffer.wrap(input, inputOffset, inputLen);
         return update(inputBuf, outputBuf);
     }
@@ -233,18 +235,18 @@ class OpenSslJnaCipher implements CryptoCipher {
      */
     @Override
     public void close() {
-        if(context != null) {
+        if (context != null) {
             OpenSslNativeJna.EVP_CIPHER_CTX_cleanup(context);
             OpenSslNativeJna.EVP_CIPHER_CTX_free(context);
         }
     }
     
     private void throwOnError(int retVal) {  
-        if(retVal != 1) {
+        if (retVal != 1) {
             NativeLong err = OpenSslNativeJna.ERR_peek_error();
             String errdesc = OpenSslNativeJna.ERR_error_string(err, null);
             
-            if(context != null) {
+            if (context != null) {
                 OpenSslNativeJna.EVP_CIPHER_CTX_cleanup(context);
             }
             throw new RuntimeException("return code "+retVal+" from OpenSSL. Err code is "+err+": "+errdesc);