apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk-Willem van Gulik <di...@webweaving.org>
Subject Re: SHA256 and friends.
Date Thu, 19 Jan 2017 18:29:28 GMT
On 19 Jan 2017, at 15:20, Dirk-Willem van Gulik <dirkx@webweaving.org> wrote:
> 
> 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) ?

Am wondering now it if makes sense to create a new directory with:

	hash/*

section (or something in crypto) where I cull things/move out of the current apr_random, sha256_glue
and apr_md4/5 and apr_sha1 - and
then all give them below treatment.

It would make wiring them up to OS specific things or to nss/openssl/CommonCrypto also a bit
easier.

And then perhaps come up with a few extra apr_hash things that do a subset of what we currently
do in the various apr_sha/md’s.

Or is that not worth it - as mid to long term md4/md5 and sha1 will evaporate.

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);
> +}
> 


Mime
View raw message