Back to index

courier  0.68.2
hmac.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2001-2005 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 #define       SHA1_INTERNAL
00006 #include      "sha1.h"
00007 #include      "../libhmac/hmac.h"
00008 
00009 
00010 static void alloc_context_sha1( void (*func)(void *, void *), void *arg)
00011 {
00012 struct SHA1_CONTEXT c;
00013 
00014        (*func)((void *)&c, arg);
00015 }
00016 
00017 static void alloc_hash_sha1( void (*func)(unsigned char *, void *), void *arg)
00018 {
00019 unsigned char c[SHA1_DIGEST_SIZE];
00020 
00021        (*func)(c, arg);
00022 }
00023 
00024 struct hmac_hashinfo hmac_sha1 = {
00025        "sha1",
00026        SHA1_BLOCK_SIZE,
00027        SHA1_DIGEST_SIZE,
00028        sizeof(struct SHA1_CONTEXT),
00029        (void (*)(void *))sha1_context_init,
00030        (void (*)(void *, const void *, unsigned))sha1_context_hashstream,
00031        (void (*)(void *, unsigned long))sha1_context_endstream,
00032        (void (*)(void *, unsigned char *))sha1_context_digest,
00033        (void (*)(void *, const unsigned char *))sha1_context_restore,
00034         alloc_context_sha1,
00035        alloc_hash_sha1};
00036 
00037 static void alloc_context_sha256( void (*func)(void *, void *), void *arg)
00038 {
00039 struct SHA256_CONTEXT c;
00040 
00041        (*func)((void *)&c, arg);
00042 }
00043 
00044 static void alloc_hash_sha256( void (*func)(unsigned char *, void *), void *arg)
00045 {
00046 unsigned char c[SHA256_DIGEST_SIZE];
00047 
00048        (*func)(c, arg);
00049 }
00050 
00051 struct hmac_hashinfo hmac_sha256 = {
00052        "sha256",
00053        SHA256_BLOCK_SIZE,
00054        SHA256_DIGEST_SIZE,
00055        sizeof(struct SHA256_CONTEXT),
00056        (void (*)(void *))sha256_context_init,
00057        (void (*)(void *, const void *, unsigned))sha256_context_hashstream,
00058        (void (*)(void *, unsigned long))sha256_context_endstream,
00059        (void (*)(void *, unsigned char *))sha256_context_digest,
00060        (void (*)(void *, const unsigned char *))sha256_context_restore,
00061         alloc_context_sha256,
00062        alloc_hash_sha256};