rand.h revision 1.2
16878Sbae/*	$NetBSD: rand.h,v 1.2 2017/01/28 21:31:47 christos Exp $	*/
26878Sbae
36878Sbae
46878Sbae/*
56878Sbae * Copyright (c) 2006 Kungliga Tekniska H��gskolan
66878Sbae * (Royal Institute of Technology, Stockholm, Sweden).
76878Sbae * All rights reserved.
86878Sbae *
96878Sbae * Redistribution and use in source and binary forms, with or without
106878Sbae * modification, are permitted provided that the following conditions
116878Sbae * are met:
126878Sbae *
136878Sbae * 1. Redistributions of source code must retain the above copyright
146878Sbae *    notice, this list of conditions and the following disclaimer.
156878Sbae *
166878Sbae * 2. Redistributions in binary form must reproduce the above copyright
176878Sbae *    notice, this list of conditions and the following disclaimer in the
186878Sbae *    documentation and/or other materials provided with the distribution.
196878Sbae *
206878Sbae * 3. Neither the name of the Institute nor the names of its contributors
216878Sbae *    may be used to endorse or promote products derived from this software
226878Sbae *    without specific prior written permission.
236878Sbae *
246878Sbae * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
256878Sbae * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
266878Sbae * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
276878Sbae * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
286878Sbae * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
296878Sbae * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
306878Sbae * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
316878Sbae * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
326878Sbae * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
336878Sbae * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
346878Sbae * SUCH DAMAGE.
356878Sbae */
366878Sbae
376878Sbae/*
386878Sbae * Id
396878Sbae */
406878Sbae
416878Sbae#ifndef _HEIM_RAND_H
426878Sbae#define _HEIM_RAND_H 1
436878Sbae
446878Sbae#define RAND_METHOD hc_RAND_METHOD
456878Sbae
466878Sbaetypedef struct RAND_METHOD RAND_METHOD;
476878Sbae
486878Sbae#include <hcrypto/engine.h>
496878Sbae
506878Sbae/* symbol renaming */
516878Sbae#define RAND_bytes hc_RAND_bytes
526878Sbae#define RAND_pseudo_bytes hc_RAND_pseudo_bytes
536878Sbae#define RAND_seed hc_RAND_seed
546878Sbae#define RAND_cleanup hc_RAND_cleanup
556878Sbae#define RAND_add hc_RAND_add
566878Sbae#define RAND_set_rand_method hc_RAND_set_rand_method
576878Sbae#define RAND_get_rand_method hc_RAND_get_rand_method
586878Sbae#define RAND_set_rand_engine hc_RAND_set_rand_engine
596878Sbae#define RAND_file_name hc_RAND_file_name
606878Sbae#define RAND_load_file hc_RAND_load_file
616878Sbae#define RAND_write_file hc_RAND_write_file
626878Sbae#define RAND_status hc_RAND_status
636878Sbae#define RAND_fortuna_method hc_RAND_fortuna_method
646878Sbae#define RAND_unix_method hc_RAND_unix_method
656878Sbae#define RAND_w32crypto_method hc_RAND_w32crypto_method
666878Sbae
676878Sbae/*
686878Sbae *
696878Sbae */
706878Sbae
716878Sbaestruct RAND_METHOD
726878Sbae{
736878Sbae    void (*seed)(const void *, int);
746878Sbae    int (*bytes)(unsigned char *, int);
756878Sbae    void (*cleanup)(void);
766878Sbae    void (*add)(const void *, int, double);
776878Sbae    int (*pseudorand)(unsigned char *, int);
786878Sbae    int (*status)(void);
796878Sbae};
806878Sbae
816878Sbae/*
826878Sbae *
836878Sbae */
846878Sbae
856878Sbaeint	RAND_bytes(void *, size_t num);
866878Sbaeint	RAND_pseudo_bytes(void *, size_t);
876878Sbaevoid	RAND_seed(const void *, size_t);
886878Sbaevoid	RAND_cleanup(void);
896878Sbaevoid	RAND_add(const void *, size_t, double);
906878Sbae
916878Sbaeint	RAND_set_rand_method(const RAND_METHOD *);
926878Sbaeconst RAND_METHOD *
936878Sbae	RAND_get_rand_method(void);
946878Sbaeint	RAND_set_rand_engine(ENGINE *);
956878Sbae
966878Sbaeconst char *
976878Sbae	RAND_file_name(char *, size_t);
986878Sbaeint	RAND_load_file(const char *, size_t);
996878Sbaeint	RAND_write_file(const char *);
100int	RAND_status(void);
101
102
103const RAND_METHOD *	RAND_fortuna_method(void);
104const RAND_METHOD *	RAND_unix_method(void);
105const RAND_METHOD *	RAND_w32crypto_method(void);
106
107#endif /* _HEIM_RAND_H */
108