1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 /* 3 * Copyright (C) 2012 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.org.conscrypt; 19 20 import java.io.Serializable; 21 import java.security.SecureRandomSpi; 22 23 /** 24 * Implements {@link java.security.SecureRandom} using BoringSSL's RAND interface. 25 * @hide This class is not part of the Android public SDK API 26 */ 27 @libcore.api.IntraCoreApi 28 @Internal 29 public final class OpenSSLRandom extends SecureRandomSpi implements Serializable { 30 private static final long serialVersionUID = 8506210602917522861L; 31 32 @dalvik.annotation.compat.UnsupportedAppUsage 33 @libcore.api.IntraCoreApi 34 public OpenSSLRandom() {} 35 36 @Override 37 protected void engineSetSeed(byte[] seed) { 38 if (seed == null) { 39 throw new NullPointerException("seed == null"); 40 } 41 } 42 43 @Override 44 protected void engineNextBytes(byte[] bytes) { 45 NativeCrypto.RAND_bytes(bytes); 46 } 47 48 @Override 49 protected byte[] engineGenerateSeed(int numBytes) { 50 byte[] output = new byte[numBytes]; 51 NativeCrypto.RAND_bytes(output); 52 return output; 53 } 54 } 55