View Javadoc
1    /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.commons.crypto.jna;
20  
21  import java.nio.ByteBuffer;
22  
23  import com.sun.jna.NativeLong;
24  import com.sun.jna.ptr.PointerByReference;
25  
26  /**
27   * This interface defines the API for the native code.
28   * All methods are listed here; individual implementations may not support them all.
29   */
30  interface OpenSslInterfaceNativeJna {
31  
32      PointerByReference _ENGINE_by_id(final String string);
33  
34      /** TODO Appears to be deprecated as of OpenSSL 1.1.0. */
35      int _ENGINE_cleanup();
36  
37      int _ENGINE_finish(final PointerByReference rdrandEngine);
38  
39      int _ENGINE_free(final PointerByReference rdrandEngine);
40  
41      int _ENGINE_init(final PointerByReference rdrandEngine);
42  
43      void _ENGINE_load_rdrand();
44  
45      int _ENGINE_set_default(final PointerByReference rdrandEngine, final int flags);
46  
47      String _ERR_error_string(final NativeLong err, final char[] buff);
48  
49      NativeLong _ERR_peek_error();
50  
51      PointerByReference _EVP_aes_128_cbc();
52  
53      PointerByReference _EVP_aes_128_ctr();
54  
55      PointerByReference _EVP_aes_192_cbc();
56  
57      PointerByReference _EVP_aes_192_ctr();
58  
59      PointerByReference _EVP_aes_256_cbc();
60  
61      PointerByReference _EVP_aes_256_ctr();
62  
63      void _EVP_CIPHER_CTX_cleanup(final PointerByReference context);
64  
65      void _EVP_CIPHER_CTX_free(final PointerByReference context);
66  
67      PointerByReference _EVP_CIPHER_CTX_new();
68  
69      int _EVP_CIPHER_CTX_set_padding(final PointerByReference context, final int padding);
70  
71      int _EVP_CipherFinal_ex(final PointerByReference context, final ByteBuffer outBuffer,
72              final int[] outlen);
73  
74      int _EVP_CipherInit_ex(final PointerByReference context, final PointerByReference algo,
75              final PointerByReference impl, final byte[] encoded, final byte[] iv, final int cipherMode);
76  
77      int _EVP_CipherUpdate(final PointerByReference context, final ByteBuffer outBuffer,
78              final int[] outlen, final ByteBuffer inBuffer, final int remaining);
79  
80      Throwable _INIT_ERROR();
81  
82      boolean _INIT_OK();
83  
84      String _OpenSSL_version(final int i);
85  
86      int _RAND_bytes(final ByteBuffer buf, final int length);
87  
88      PointerByReference _RAND_get_rand_method();
89  
90      PointerByReference _RAND_SSLeay();
91  }