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  package org.apache.commons.crypto.random;
19  
20  /**
21   * JNI interface of {@link CryptoRandom} implementation for OpenSSL.
22   * The native method in this class is defined in
23   * OpenSslCryptoRandomNative.h (generated at build time by javah)
24   * and implemented in the file
25   * src/main/native/org/apache/commons/crypto/random/OpenSslCryptoRandomNative.c
26   */
27  final class OpenSslCryptoRandomNative {
28  
29      /**
30       * Declares a native method to initialize SR.
31       */
32      public static native void initSR();
33  
34      /**
35       * Judges whether use {@link OpenSslCryptoRandomNative} to generate the
36       * user-specified number of random bits.
37       *
38       * @param bytes the array to be filled in with random bytes.
39       * @return true if use {@link OpenSslCryptoRandomNative} to generate the
40       *         user-specified number of random bits.
41       */
42      public static native boolean nextRandBytes(byte[] bytes);
43  
44      /**
45       * The private constructor of {@link OpenSslCryptoRandomNative}.
46       */
47      private OpenSslCryptoRandomNative() {
48      }
49  }