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 2022/12/13 03:01:43 UTC

[commons-crypto] 01/03: Sort members

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit af185807452179ec9e851822004f416dd3fbf704
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Dec 12 21:51:33 2022 -0500

    Sort members
---
 .../commons/crypto/cipher/OpenSslNative.java       | 112 ++++++++++-----------
 1 file changed, 56 insertions(+), 56 deletions(-)

diff --git a/src/main/java/org/apache/commons/crypto/cipher/OpenSslNative.java b/src/main/java/org/apache/commons/crypto/cipher/OpenSslNative.java
index 0b1760f..426222d 100644
--- a/src/main/java/org/apache/commons/crypto/cipher/OpenSslNative.java
+++ b/src/main/java/org/apache/commons/crypto/cipher/OpenSslNative.java
@@ -26,24 +26,53 @@ import java.nio.ByteBuffer;
 final class OpenSslNative {
 
     /**
-     * The private constructor of {@link OpenSslNative}.
+     * Cleans the context at native.
+     *
+     * @param context The cipher context address
      */
-    private OpenSslNative() {
-    }
+    public static native void clean(long context);
 
     /**
-     * Declares a native method to initialize JNI field and method IDs.
+     * allows various cipher specific parameters to be determined and set.
+     *
+     * it will call OpenSSL's API
+     * int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
+     * In OpenSSL, data type of ptr can be char* or long*.  Here, we map java's
+     * byte[] to native void*ptr. Note that the byte order is ByteOrder.nativeOrder.
+     *
+     * @param context The cipher context address
+     * @param type CtrlValues
+     * @param arg argument like a tag length
+     * @param data byte buffer or null
+     * @return return 0 if there is any error, else return 1.
      */
-    public static native void initIDs();
+    public static native int ctrl(long context, int type, int arg, byte[] data);
 
     /**
-     * Declares a native method to initialize the cipher context.
+     * Finishes a multiple-part operation. The data is encrypted or decrypted,
+     * depending on how this cipher was initialized.
      *
-     * @param algorithm The algorithm name of cipher
-     * @param padding The padding name of cipher
-     * @return the context address of cipher
+     * @param context The cipher context address
+     * @param output The byte buffer for the result
+     * @param offset The offset in output where the result is stored
+     * @param maxOutputLength The maximum length for output
+     * @return The number of bytes stored in output
      */
-    public static native long initContext(int algorithm, int padding);
+    public static native int doFinal(long context, ByteBuffer output,
+            int offset, int maxOutputLength);
+
+    /**
+     * Finishes a multiple-part operation. The data is encrypted or decrypted,
+     * depending on how this cipher was initialized.
+     *
+     * @param context The cipher context address
+     * @param output The byte array for the result
+     * @param offset The offset in output where the result is stored
+     * @param maxOutputLength The maximum length for output
+     * @return The number of bytes stored in output
+     */
+    public static native int doFinalByteArray(long context, byte[] output,
+            int offset, int maxOutputLength);
 
     /**
      * Declares a native method to initialize the cipher context.
@@ -59,6 +88,20 @@ final class OpenSslNative {
     public static native long init(long context, int mode, int alg,
                                    int padding, byte[] key, byte[] iv);
 
+    /**
+     * Declares a native method to initialize the cipher context.
+     *
+     * @param algorithm The algorithm name of cipher
+     * @param padding The padding name of cipher
+     * @return the context address of cipher
+     */
+    public static native long initContext(int algorithm, int padding);
+
+    /**
+     * Declares a native method to initialize JNI field and method IDs.
+     */
+    public static native void initIDs();
+
     /**
      * Continues a multiple-part encryption/decryption operation. The data is
      * encrypted or decrypted, depending on how this cipher was initialized.
@@ -110,53 +153,10 @@ final class OpenSslNative {
                                                        int inputOffset, int inputLength,
                                                        ByteBuffer output, int outputOffset, int maxOutputLength);
 
-    /**
-     * Finishes a multiple-part operation. The data is encrypted or decrypted,
-     * depending on how this cipher was initialized.
-     *
-     * @param context The cipher context address
-     * @param output The byte buffer for the result
-     * @param offset The offset in output where the result is stored
-     * @param maxOutputLength The maximum length for output
-     * @return The number of bytes stored in output
-     */
-    public static native int doFinal(long context, ByteBuffer output,
-            int offset, int maxOutputLength);
-
-    /**
-     * Finishes a multiple-part operation. The data is encrypted or decrypted,
-     * depending on how this cipher was initialized.
-     *
-     * @param context The cipher context address
-     * @param output The byte array for the result
-     * @param offset The offset in output where the result is stored
-     * @param maxOutputLength The maximum length for output
-     * @return The number of bytes stored in output
-     */
-    public static native int doFinalByteArray(long context, byte[] output,
-            int offset, int maxOutputLength);
-
-    /**
-     * allows various cipher specific parameters to be determined and set.
-     *
-     * it will call OpenSSL's API
-     * int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
-     * In OpenSSL, data type of ptr can be char* or long*.  Here, we map java's
-     * byte[] to native void*ptr. Note that the byte order is ByteOrder.nativeOrder.
-     *
-     * @param context The cipher context address
-     * @param type CtrlValues
-     * @param arg argument like a tag length
-     * @param data byte buffer or null
-     * @return return 0 if there is any error, else return 1.
-     */
-    public static native int ctrl(long context, int type, int arg, byte[] data);
-
 
     /**
-     * Cleans the context at native.
-     *
-     * @param context The cipher context address
+     * The private constructor of {@link OpenSslNative}.
      */
-    public static native void clean(long context);
+    private OpenSslNative() {
+    }
 }