Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

apr_random.h

00001 /* Copyright 2000-2004 The Apache Software Foundation 00002 * 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 */ 00015 00016 #ifndef APR_RANDOM_H 00017 #define APR_RANDOM_H 00018 00019 #include <apr_pools.h> 00020 00021 typedef struct apr_crypto_hash_t apr_crypto_hash_t; 00022 00023 typedef void apr_crypto_hash_init_t(apr_crypto_hash_t *hash); 00024 typedef void apr_crypto_hash_add_t(apr_crypto_hash_t *hash,const void *data, 00025 apr_size_t bytes); 00026 typedef void apr_crypto_hash_finish_t(apr_crypto_hash_t *hash, 00027 unsigned char *result); 00028 00029 /* FIXME: make this opaque */ 00030 struct apr_crypto_hash_t { 00031 apr_crypto_hash_init_t *init; 00032 apr_crypto_hash_add_t *add; 00033 apr_crypto_hash_finish_t *finish; 00034 apr_size_t size; 00035 void *data; 00036 }; 00037 00038 APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p); 00039 00040 typedef struct apr_random_t apr_random_t; 00041 00042 APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, 00043 apr_crypto_hash_t *pool_hash, 00044 apr_crypto_hash_t *key_hash, 00045 apr_crypto_hash_t *prng_hash); 00046 APR_DECLARE(apr_random_t *) apr_random_standard_new(apr_pool_t *p); 00047 APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g, 00048 const void *entropy_, 00049 apr_size_t bytes); 00050 APR_DECLARE(apr_status_t) apr_random_insecure_bytes(apr_random_t *g, 00051 void *random, 00052 apr_size_t bytes); 00053 APR_DECLARE(apr_status_t) apr_random_secure_bytes(apr_random_t *g, 00054 void *random, 00055 apr_size_t bytes); 00056 APR_DECLARE(void) apr_random_barrier(apr_random_t *g); 00057 APR_DECLARE(apr_status_t) apr_random_secure_ready(apr_random_t *r); 00058 APR_DECLARE(apr_status_t) apr_random_insecure_ready(apr_random_t *r); 00059 00060 /* Call this in the child after forking to mix the randomness 00061 pools. Note that its generally a bad idea to fork a process with a 00062 real PRNG in it - better to have the PRNG externally and get the 00063 randomness from there. However, if you really must do it, then you 00064 should supply all your entropy to all the PRNGs - don't worry, they 00065 won't produce the same output. 00066 00067 Note that apr_proc_fork() calls this for you, so only weird 00068 applications need ever call it themselves. 00069 */ 00070 struct apr_proc_t; 00071 APR_DECLARE(void) apr_random_after_fork(struct apr_proc_t *proc); 00072 00073 #endif /* ndef APR_RANDOM_H */

Generated on Thu Sep 16 13:47:10 2004 for Apache Portable Runtime by doxygen 1.3.7