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

apr_random.h

00001 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as 00002 * applicable. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * 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 00020 #include <apr_pools.h> 00021 00022 typedef struct apr_crypto_hash_t apr_crypto_hash_t; 00023 00024 typedef void apr_crypto_hash_init_t(apr_crypto_hash_t *hash); 00025 typedef void apr_crypto_hash_add_t(apr_crypto_hash_t *hash,const void *data, 00026 apr_size_t bytes); 00027 typedef void apr_crypto_hash_finish_t(apr_crypto_hash_t *hash, 00028 unsigned char *result); 00029 00030 /* FIXME: make this opaque */ 00031 struct apr_crypto_hash_t { 00032 apr_crypto_hash_init_t *init; 00033 apr_crypto_hash_add_t *add; 00034 apr_crypto_hash_finish_t *finish; 00035 apr_size_t size; 00036 void *data; 00037 }; 00038 00039 APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p); 00040 00041 typedef struct apr_random_t apr_random_t; 00042 00043 APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, 00044 apr_crypto_hash_t *pool_hash, 00045 apr_crypto_hash_t *key_hash, 00046 apr_crypto_hash_t *prng_hash); 00047 APR_DECLARE(apr_random_t *) apr_random_standard_new(apr_pool_t *p); 00048 APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g, 00049 const void *entropy_, 00050 apr_size_t bytes); 00051 APR_DECLARE(apr_status_t) apr_random_insecure_bytes(apr_random_t *g, 00052 void *random, 00053 apr_size_t bytes); 00054 APR_DECLARE(apr_status_t) apr_random_secure_bytes(apr_random_t *g, 00055 void *random, 00056 apr_size_t bytes); 00057 APR_DECLARE(void) apr_random_barrier(apr_random_t *g); 00058 APR_DECLARE(apr_status_t) apr_random_secure_ready(apr_random_t *r); 00059 APR_DECLARE(apr_status_t) apr_random_insecure_ready(apr_random_t *r); 00060 00061 /* Call this in the child after forking to mix the randomness 00062 pools. Note that its generally a bad idea to fork a process with a 00063 real PRNG in it - better to have the PRNG externally and get the 00064 randomness from there. However, if you really must do it, then you 00065 should supply all your entropy to all the PRNGs - don't worry, they 00066 won't produce the same output. 00067 00068 Note that apr_proc_fork() calls this for you, so only weird 00069 applications need ever call it themselves. 00070 */ 00071 struct apr_proc_t; 00072 APR_DECLARE(void) apr_random_after_fork(struct apr_proc_t *proc); 00073 00074 #endif /* ndef APR_RANDOM_H */

Generated on Sun Nov 20 18:49:39 2005 for Apache Portable Runtime by doxygen 1.3.8