From: Simon Josefsson Date: Wed, 12 Oct 2005 11:57:13 +0000 (+0000) Subject: * gc.h, gc-gnulib.c, gc-libgcrypt.c: Use Gc_rc for return types, X-Git-Tag: cvs-readonly~2819 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=ecbe47ca1c551b24c8a4d7309daba56006956849;p=gnulib.git * gc.h, gc-gnulib.c, gc-libgcrypt.c: Use Gc_rc for return types, suggested by Bruno Haible . --- diff --git a/lib/ChangeLog b/lib/ChangeLog index bf2ead8b4..a6d902aa8 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,10 @@ 2005-10-12 Simon Josefsson + * gc.h, gc-gnulib.c, gc-libgcrypt.c: Use Gc_rc for return types, + suggested by Bruno Haible . + +2005-10-12 Simon Josefsson + * gc-libgcrypt.c (gc_hmac_sha1): New function. * gc-gnulib.c (gc_hmac_sha1): New function. diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c index e0e37b059..9bdb81333 100644 --- a/lib/gc-gnulib.c +++ b/lib/gc-gnulib.c @@ -47,10 +47,10 @@ # include "hmac.h" #endif -int +Gc_rc gc_init (void) { - return 0; + return GC_OK; } void @@ -61,7 +61,7 @@ gc_done (void) /* Randomness. */ -static int +static Gc_rc randomize (int level, char *data, size_t datalen) { int fd; @@ -113,19 +113,19 @@ randomize (int level, char *data, size_t datalen) return GC_OK; } -int +Gc_rc gc_nonce (char *data, size_t datalen) { return randomize (0, data, datalen); } -int +Gc_rc gc_pseudo_random (char *data, size_t datalen) { return randomize (1, data, datalen); } -int +Gc_rc gc_random (char *data, size_t datalen) { return randomize (2, data, datalen); @@ -144,7 +144,7 @@ gc_set_allocators (gc_malloc_t func_malloc, /* Hashes. */ -int +Gc_rc gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) { switch (hash) @@ -169,39 +169,39 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) } #ifdef GC_USE_MD5 -int +Gc_rc gc_md5 (const void *in, size_t inlen, void *resbuf) { md5_buffer (in, inlen, resbuf); - return 0; + return GC_OK; } #endif #ifdef GC_USE_SHA1 -int +Gc_rc gc_sha1 (const void *in, size_t inlen, void *resbuf) { sha1_buffer (in, inlen, resbuf); - return 0; + return GC_OK; } #endif #ifdef GC_USE_HMAC_MD5 -int +Gc_rc gc_hmac_md5 (const void *key, size_t keylen, const void *in, size_t inlen, char *resbuf) { hmac_md5 (key, keylen, in, inlen, resbuf); - return 0; + return GC_OK; } #endif #ifdef GC_USE_HMAC_SHA1 -int +Gc_rc gc_hmac_sha1 (const void *key, size_t keylen, const void *in, size_t inlen, char *resbuf) { hmac_sha1 (key, keylen, in, inlen, resbuf); - return 0; + return GC_OK; } #endif diff --git a/lib/gc-libgcrypt.c b/lib/gc-libgcrypt.c index 765235677..349d5619b 100644 --- a/lib/gc-libgcrypt.c +++ b/lib/gc-libgcrypt.c @@ -34,7 +34,7 @@ /* Initialization. */ -int +Gc_rc gc_init (void) { gcry_error_t err; @@ -61,21 +61,21 @@ gc_done (void) /* Randomness. */ -int +Gc_rc gc_nonce (char *data, size_t datalen) { gcry_create_nonce ((unsigned char *) data, datalen); return GC_OK; } -int +Gc_rc gc_pseudo_random (char *data, size_t datalen) { gcry_randomize ((unsigned char *) data, datalen, GCRY_STRONG_RANDOM); return GC_OK; } -int +Gc_rc gc_random (char *data, size_t datalen) { gcry_randomize ((unsigned char *) data, datalen, GCRY_VERY_STRONG_RANDOM); @@ -96,7 +96,7 @@ gc_set_allocators (gc_malloc_t func_malloc, /* Hashes. */ -int +Gc_rc gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) { int gcryalg; @@ -127,7 +127,7 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) /* One-call interface. */ #ifdef GC_USE_MD5 -int +Gc_rc gc_md5 (const void *in, size_t inlen, void *resbuf) { size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD5); @@ -159,7 +159,7 @@ gc_md5 (const void *in, size_t inlen, void *resbuf) #endif #ifdef GC_USE_SHA1 -int +Gc_rc gc_sha1 (const void *in, size_t inlen, void *resbuf) { size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1); @@ -191,7 +191,7 @@ gc_sha1 (const void *in, size_t inlen, void *resbuf) #endif #ifdef GC_USE_HMAC_MD5 -int +Gc_rc gc_hmac_md5 (const void *key, size_t keylen, const void *in, size_t inlen, char *resbuf) { @@ -231,7 +231,7 @@ gc_hmac_md5 (const void *key, size_t keylen, #endif #ifdef GC_USE_HMAC_SHA1 -int +Gc_rc gc_hmac_sha1 (const void *key, size_t keylen, const void *in, size_t inlen, char *resbuf) { diff --git a/lib/gc.h b/lib/gc.h index c66d31a6b..43a7ff6c5 100644 --- a/lib/gc.h +++ b/lib/gc.h @@ -50,7 +50,7 @@ typedef enum Gc_hash Gc_hash; #define GC_SHA1_DIGEST_SIZE 20 /* Call before respectively after any other functions. */ -extern int gc_init (void); +extern Gc_rc gc_init (void); extern void gc_done (void); /* Memory allocation (avoid). */ @@ -72,18 +72,18 @@ extern void gc_set_allocators (gc_malloc_t func_malloc, GC__DIGEST_SIZE. For example, for GC_MD5 the output buffer must be 16 bytes. The return value is 0 (GC_OK) on success, or another Gc_rc error code. */ -extern int +extern Gc_rc gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out); /* One-call interface. */ -extern int gc_md5 (const void *in, size_t inlen, void *resbuf); -extern int gc_sha1 (const void *in, size_t inlen, void *resbuf); -extern int gc_hmac_md5 (const void *key, size_t keylen, - const void *in, size_t inlen, - char *resbuf); -extern int gc_hmac_sha1 (const void *key, size_t keylen, - const void *in, size_t inlen, - char *resbuf); +extern Gc_rc gc_md5 (const void *in, size_t inlen, void *resbuf); +extern Gc_rc gc_sha1 (const void *in, size_t inlen, void *resbuf); +extern Gc_rc gc_hmac_md5 (const void *key, size_t keylen, + const void *in, size_t inlen, + char *resbuf); +extern Gc_rc gc_hmac_sha1 (const void *key, size_t keylen, + const void *in, size_t inlen, + char *resbuf); /* TODO: