Where can I find the proper version of below — to do things like

        apr_crypto_hash_t * sha256_ctx = apr_crypto_sha256_new(pool); 

        apr_hash(sha256_ctx, …...

? Or was this abstracting in apr_random of the hash something which was never 
completed (nor had its MD2, MD5 and friends folded in) ?

Dw.


Index: apr_random.c
===================================================================
--- apr_random.c        (revision 1779018)
+++ apr_random.c        (working copy)
@@ -53,6 +53,36 @@
 #define crypt_setkey(c,k)       (c)->set_key((c)->data,k)
 #define crypt_crypt(c,out,in)   (c)->crypt((c)->date,out,in)
 
+APR_DECLARE(apr_status_t) apr_hash_init(apr_crypto_hash_t *key_hash) {
+    hash_init(key_hash);
+    return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_hash_add(apr_crypto_hash_t * key_hash, const 
void * addvuff, apr_size_t addbytes) {
+    hash_add(key_hash, addvuff, addbytes);
+    return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_hash_finish(apr_crypto_hash_t * key_hash, void 
** resultp, apr_size_t *resultlenp, apr_pool_t * pool) {
+    if (*resultp == NULL)
+      *resultp = apr_palloc(pool, key_hash->size);
+    else if (*resultlenp < key_hash->size)
+        return APR_EINVAL;
+
+    hash_finish(key_hash, *resultp);
+    *resultlenp = key_hash->size;
+
+    return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_hash(apr_crypto_hash_t * key_hash, void ** 
resultp, apr_size_t *resultlenp, const void * inbuff, apr_size_t inbytes, 
apr_pool_t * pool) {
+    hash_init(key_hash);
+    hash_add(key_hash, inbuff, inbytes);
+
+    return apr_hash_finish(key_hash, resultp, resultlenp, pool);
+}

Reply via email to