suggested by Bruno Haible <bruno@clisp.org>.
+2005-10-12 Simon Josefsson <jas@extundo.com>
+
+ * gc.h, gc-gnulib.c, gc-libgcrypt.c: Use Gc_rc for return types,
+ suggested by Bruno Haible <bruno@clisp.org>.
+
2005-10-12 Simon Josefsson <jas@extundo.com>
* gc-libgcrypt.c (gc_hmac_sha1): New function.
# include "hmac.h"
#endif
-int
+Gc_rc
gc_init (void)
{
- return 0;
+ return GC_OK;
}
void
/* Randomness. */
-static int
+static Gc_rc
randomize (int level, char *data, size_t datalen)
{
int fd;
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);
/* Hashes. */
-int
+Gc_rc
gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
{
switch (hash)
}
#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
/* Initialization. */
-int
+Gc_rc
gc_init (void)
{
gcry_error_t err;
/* 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);
/* Hashes. */
-int
+Gc_rc
gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
{
int gcryalg;
/* 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);
#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);
#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)
{
#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)
{
#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). */
GC_<HASH>_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: