/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package java.security;

import java.io.Serializable;

/**
 * {@code SecureRandomSpi} is the <i>Service Provider Interface</i> (<b>SPI</b>) definition
 * for {@link SecureRandom}.
 *
 * @see SecureRandom
 */
public abstract class SecureRandomSpi implements Serializable {

    private static final long serialVersionUID = -2991854161009191830L;

    /**
     * Reseeds this {@code SecureRandomSpi} instance with the specified {@code
     * seed}. The seed of this {@code SecureRandomSpi} instance is supplemented,
     * not replaced.
     *
     * @param seed
     *            the new seed.
     */
    protected abstract void engineSetSeed(byte[] seed);

    /**
     * Generates and stores random bytes in the given {@code byte[]} for each
     * array element.
     *
     * @param bytes
     *            the {@code byte[]} to be filled with random bytes.
     */
    protected abstract void engineNextBytes(byte[] bytes);

    /**
     * Generates and returns the specified number of seed bytes, computed using
     * the seed generation algorithm used by this {@code SecureRandomSpi}.
     *
     * @param numBytes
     *            the number of seed bytes.
     * @return the seed bytes
     */
    protected abstract byte[] engineGenerateSeed(int numBytes);
}
