GME  13
apr_random.h
Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_RANDOM_H
00018 #define APR_RANDOM_H
00019 
00025 #include "apr_pools.h"
00026 #include "apr_thread_proc.h"
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif /* __cplusplus */
00031 
00038 typedef struct apr_crypto_hash_t apr_crypto_hash_t;
00039 
00040 typedef void apr_crypto_hash_init_t(apr_crypto_hash_t *hash);
00041 typedef void apr_crypto_hash_add_t(apr_crypto_hash_t *hash, const void *data,
00042                                    apr_size_t bytes);
00043 typedef void apr_crypto_hash_finish_t(apr_crypto_hash_t *hash,
00044                                       unsigned char *result);
00045 
00046 
00047 /* FIXME: make this opaque */
00048 struct apr_crypto_hash_t {
00049     apr_crypto_hash_init_t *init;
00050     apr_crypto_hash_add_t *add;
00051     apr_crypto_hash_finish_t *finish;
00052     apr_size_t size;
00053     void *data;
00054 };
00055 
00060 APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p);
00061 
00063 typedef struct apr_random_t apr_random_t;
00064 
00073 APR_DECLARE(void) apr_random_init(apr_random_t *g, apr_pool_t *p,
00074                                   apr_crypto_hash_t *pool_hash,
00075                                   apr_crypto_hash_t *key_hash,
00076                                   apr_crypto_hash_t *prng_hash);
00081 APR_DECLARE(apr_random_t *) apr_random_standard_new(apr_pool_t *p);
00082 
00089 APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g,
00090                                          const void *entropy_,
00091                                          apr_size_t bytes);
00098 APR_DECLARE(apr_status_t) apr_random_insecure_bytes(apr_random_t *g,
00099                                                     void *random,
00100                                                     apr_size_t bytes);
00101 
00108 APR_DECLARE(apr_status_t) apr_random_secure_bytes(apr_random_t *g,
00109                                                   void *random,
00110                                                   apr_size_t bytes);
00116 APR_DECLARE(void) apr_random_barrier(apr_random_t *g);
00117 
00123 APR_DECLARE(apr_status_t) apr_random_secure_ready(apr_random_t *r);
00124 
00130 APR_DECLARE(apr_status_t) apr_random_insecure_ready(apr_random_t *r);
00131 
00145 APR_DECLARE(void) apr_random_after_fork(apr_proc_t *proc);
00146 
00149 #ifdef __cplusplus
00150 }
00151 #endif
00152 
00153 #endif /* !APR_RANDOM_H */