blob: 0ccca15b2c7ff3342a9d4cf61dbeb02abc4a6559 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * 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
26package 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 *
36 * @see SecureRandom
37 * @since 1.2
38 */
39
40public abstract class SecureRandomSpi implements java.io.Serializable {
41
42 private static final long serialVersionUID = -2991854161009191830L;
43
44 /**
45 * Reseeds this random object. The given seed supplements, rather than
46 * replaces, the existing seed. Thus, repeated calls are guaranteed
47 * never to reduce randomness.
48 *
49 * @param seed the seed.
50 */
51 protected abstract void engineSetSeed(byte[] seed);
52
53 /**
54 * Generates a user-specified number of random bytes.
55 *
56 * <p> If a call to <code>engineSetSeed</code> had not occurred previously,
57 * the first call to this method forces this SecureRandom implementation
58 * to seed itself. This self-seeding will not occur if
59 * <code>engineSetSeed</code> was previously called.
60 *
61 * @param bytes the array to be filled in with random bytes.
62 */
63 protected abstract void engineNextBytes(byte[] bytes);
64
65 /**
66 * Returns the given number of seed bytes. This call may be used to
67 * seed other random number generators.
68 *
69 * @param numBytes the number of seed bytes to generate.
70 *
71 * @return the seed bytes.
72 */
73 protected abstract byte[] engineGenerateSeed(int numBytes);
74}