01 /*
02 * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package java.security;
27
28 /**
29 * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
30 * for the <code>SecureRandom</code> class.
31 * All the abstract methods in this class must be implemented by each
32 * service provider who wishes to supply the implementation
33 * of a cryptographically strong pseudo-random number generator.
34 *
35 * @version 1.19, 05/05/07
36 *
37 * @see SecureRandom
38 * @since 1.2
39 */
40
41 public abstract class SecureRandomSpi implements java.io.Serializable {
42
43 private static final long serialVersionUID = -2991854161009191830L;
44
45 /**
46 * Reseeds this random object. The given seed supplements, rather than
47 * replaces, the existing seed. Thus, repeated calls are guaranteed
48 * never to reduce randomness.
49 *
50 * @param seed the seed.
51 */
52 protected abstract void engineSetSeed(byte[] seed);
53
54 /**
55 * Generates a user-specified number of random bytes.
56 *
57 * <p> If a call to <code>engineSetSeed</code> had not occurred previously,
58 * the first call to this method forces this SecureRandom implementation
59 * to seed itself. This self-seeding will not occur if
60 * <code>engineSetSeed</code> was previously called.
61 *
62 * @param bytes the array to be filled in with random bytes.
63 */
64 protected abstract void engineNextBytes(byte[] bytes);
65
66 /**
67 * Returns the given number of seed bytes. This call may be used to
68 * seed other random number generators.
69 *
70 * @param numBytes the number of seed bytes to generate.
71 *
72 * @return the seed bytes.
73 */
74 protected abstract byte[] engineGenerateSeed(int numBytes);
75 }
|