• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  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 java.security;
19 
20 import java.io.Serializable;
21 
22 /**
23  * {@code SecureRandomSpi} is the <i>Service Provider Interface</i> (<b>SPI</b>) definition
24  * for {@link SecureRandom}.
25  *
26  * @see SecureRandom
27  */
28 public abstract class SecureRandomSpi implements Serializable {
29 
30     private static final long serialVersionUID = -2991854161009191830L;
31 
32     /**
33      * Reseeds this {@code SecureRandomSpi} instance with the specified {@code
34      * seed}. The seed of this {@code SecureRandomSpi} instance is supplemented,
35      * not replaced.
36      *
37      * @param seed
38      *            the new seed.
39      */
engineSetSeed(byte[] seed)40     protected abstract void engineSetSeed(byte[] seed);
41 
42     /**
43      * Generates and stores random bytes in the given {@code byte[]} for each
44      * array element.
45      *
46      * @param bytes
47      *            the {@code byte[]} to be filled with random bytes.
48      */
engineNextBytes(byte[] bytes)49     protected abstract void engineNextBytes(byte[] bytes);
50 
51     /**
52      * Generates and returns the specified number of seed bytes, computed using
53      * the seed generation algorithm used by this {@code SecureRandomSpi}.
54      *
55      * @param numBytes
56      *            the number of seed bytes.
57      * @return the seed bytes
58      */
engineGenerateSeed(int numBytes)59     protected abstract byte[] engineGenerateSeed(int numBytes);
60 }
61