]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/apr/random/unix/sha2_glue.c
Restore the dbus directory that was not meant to be deleted in r252729.
[FreeBSD/FreeBSD.git] / contrib / apr / random / unix / sha2_glue.c
1 #include <apr.h>
2 #include <apr_random.h>
3 #include <apr_pools.h>
4 #include "sha2.h"
5
6 static void sha256_init(apr_crypto_hash_t *h)
7     {
8     apr__SHA256_Init(h->data);
9     }
10
11 static void sha256_add(apr_crypto_hash_t *h,const void *data,
12                           apr_size_t bytes)
13     {
14     apr__SHA256_Update(h->data,data,bytes);
15     }
16
17 static void sha256_finish(apr_crypto_hash_t *h,unsigned char *result)
18     {
19     apr__SHA256_Final(result,h->data);
20     }
21
22 APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p)
23     {
24     apr_crypto_hash_t *h=apr_palloc(p,sizeof *h);
25
26     h->data=apr_palloc(p,sizeof(SHA256_CTX));
27     h->init=sha256_init;
28     h->add=sha256_add;
29     h->finish=sha256_finish;
30     h->size=256/8;
31
32     return h;
33     }