mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-10-07 04:02:18 +03:00
mega-renaming to avoid exporting symbols not starting with MHD
This commit is contained in:
1 parent
7ba36f02ae
commit
6ff7b62145
156 files changed
+9535
-9575
No files matched your search
@@ -14,7 +14,6 @@ liblgl_la_LDFLAGS = -lgcrypt
|
||||
liblgl_la_SOURCES = \
|
||||
sha1.c sha1.h \
|
||||
gc-libgcrypt.c \
|
||||
time_r.c \
|
||||
rijndael-api-fst.c rijndael-api-fst.h \
|
||||
gc-pbkdf2-sha1.c gc.h \
|
||||
rijndael-alg-fst.c rijndael-alg-fst.h \
|
||||
|
||||
+20
-20
@@ -54,13 +54,13 @@
|
||||
* unsigned char plaintext[8];
|
||||
* unsigned char ciphertext[8];
|
||||
* unsigned char recoverd[8];
|
||||
* gl_des_ctx context;
|
||||
* MHD_gl_des_ctx context;
|
||||
*
|
||||
* // Fill 'key' and 'plaintext' with some data
|
||||
* ....
|
||||
*
|
||||
* // Set up the DES encryption context
|
||||
* gl_des_setkey(&context, key);
|
||||
* MHD_gl_des_setkey(&context, key);
|
||||
*
|
||||
* // Encrypt the plaintext
|
||||
* des_ecb_encrypt(&context, plaintext, ciphertext);
|
||||
@@ -77,20 +77,20 @@
|
||||
* unsigned char plaintext[8];
|
||||
* unsigned char ciphertext[8];
|
||||
* unsigned char recoverd[8];
|
||||
* gl_3des_ctx context;
|
||||
* MHD_gl_3des_ctx context;
|
||||
*
|
||||
* // If you would like to use two 64bit keys, fill 'key1' and'key2'
|
||||
* // then setup the encryption context:
|
||||
* gl_3des_set2keys(&context, key1, key2);
|
||||
* MHD_gl_3des_set2keys(&context, key1, key2);
|
||||
*
|
||||
* // To use three 64bit keys with Triple-DES use:
|
||||
* gl_3des_set3keys(&context, key1, key2, key3);
|
||||
* MHD_gl_3des_set3keys(&context, key1, key2, key3);
|
||||
*
|
||||
* // Encrypting plaintext with Triple-DES
|
||||
* gl_3des_ecb_encrypt(&context, plaintext, ciphertext);
|
||||
* MHD_gl_3des_ecb_encrypt(&context, plaintext, ciphertext);
|
||||
*
|
||||
* // Decrypting ciphertext to recover the plaintext with Triple-DES
|
||||
* gl_3des_ecb_decrypt(&context, ciphertext, recoverd);
|
||||
* MHD_gl_3des_ecb_decrypt(&context, ciphertext, recoverd);
|
||||
*/
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ static const unsigned char weak_keys[64][8] = {
|
||||
};
|
||||
|
||||
bool
|
||||
gl_des_is_weak_key (const char *key)
|
||||
MHD_gl_des_is_weak_key (const char *key)
|
||||
{
|
||||
char work[8];
|
||||
int i, left, right, middle, cmp_result;
|
||||
@@ -518,7 +518,7 @@ des_key_schedule (const char *_rawkey, uint32_t * subkey)
|
||||
}
|
||||
|
||||
void
|
||||
gl_des_setkey (gl_des_ctx * ctx, const char *key)
|
||||
MHD_gl_des_setkey (MHD_gl_des_ctx * ctx, const char *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -532,18 +532,18 @@ gl_des_setkey (gl_des_ctx * ctx, const char *key)
|
||||
}
|
||||
|
||||
bool
|
||||
gl_des_makekey (gl_des_ctx * ctx, const char *key, size_t keylen)
|
||||
MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, size_t keylen)
|
||||
{
|
||||
if (keylen != 8)
|
||||
return false;
|
||||
|
||||
gl_des_setkey (ctx, key);
|
||||
MHD_gl_des_setkey (ctx, key);
|
||||
|
||||
return !gl_des_is_weak_key (key);
|
||||
return !MHD_gl_des_is_weak_key (key);
|
||||
}
|
||||
|
||||
void
|
||||
gl_des_ecb_crypt (gl_des_ctx * ctx, const char *_from, char *_to, int mode)
|
||||
MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *_from, char *_to, int mode)
|
||||
{
|
||||
const unsigned char *from = (const unsigned char *) _from;
|
||||
unsigned char *to = (unsigned char *) _to;
|
||||
@@ -565,7 +565,7 @@ READ_64BIT_DATA (from, left, right)
|
||||
FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)}
|
||||
|
||||
void
|
||||
gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2)
|
||||
MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -589,7 +589,7 @@ gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2)
|
||||
}
|
||||
|
||||
void
|
||||
gl_3des_set3keys (gl_3des_ctx * ctx, const char *key1,
|
||||
MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx, const char *key1,
|
||||
const char *key2, const char *key3)
|
||||
{
|
||||
int i;
|
||||
@@ -612,7 +612,7 @@ gl_3des_set3keys (gl_3des_ctx * ctx, const char *key1,
|
||||
}
|
||||
|
||||
void
|
||||
gl_3des_ecb_crypt (gl_3des_ctx * ctx, const char *_from, char *_to, int mode)
|
||||
MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *_from, char *_to, int mode)
|
||||
{
|
||||
const unsigned char *from = (const unsigned char *) _from;
|
||||
unsigned char *to = (unsigned char *) _to;
|
||||
@@ -650,13 +650,13 @@ READ_64BIT_DATA (from, left, right)
|
||||
FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)}
|
||||
|
||||
bool
|
||||
gl_3des_makekey (gl_3des_ctx * ctx, const char *key, size_t keylen)
|
||||
MHD_gl_3des_makekey (MHD_gl_3des_ctx * ctx, const char *key, size_t keylen)
|
||||
{
|
||||
if (keylen != 24)
|
||||
return false;
|
||||
|
||||
gl_3des_set3keys (ctx, key, key + 8, key + 16);
|
||||
MHD_gl_3des_set3keys (ctx, key, key + 8, key + 16);
|
||||
|
||||
return !(gl_des_is_weak_key (key)
|
||||
|| gl_des_is_weak_key (key + 8) || gl_des_is_weak_key (key + 16));
|
||||
return !(MHD_gl_des_is_weak_key (key)
|
||||
|| MHD_gl_des_is_weak_key (key + 8) || MHD_gl_des_is_weak_key (key + 16));
|
||||
}
|
||||
+14
-14
@@ -34,7 +34,7 @@ typedef struct
|
||||
{
|
||||
uint32_t encrypt_subkeys[32];
|
||||
uint32_t decrypt_subkeys[32];
|
||||
} gl_des_ctx;
|
||||
} MHD_gl_des_ctx;
|
||||
|
||||
/*
|
||||
* Encryption/Decryption context of Triple-DES
|
||||
@@ -43,11 +43,11 @@ typedef struct
|
||||
{
|
||||
uint32_t encrypt_subkeys[96];
|
||||
uint32_t decrypt_subkeys[96];
|
||||
} gl_3des_ctx;
|
||||
} MHD_gl_3des_ctx;
|
||||
|
||||
/* Check whether the 8 byte key is weak. Does not check the parity
|
||||
* bits of the key but simple ignore them. */
|
||||
extern bool gl_des_is_weak_key (const char *key);
|
||||
extern bool MHD_gl_des_is_weak_key (const char *key);
|
||||
|
||||
/*
|
||||
* DES
|
||||
@@ -57,20 +57,20 @@ extern bool gl_des_is_weak_key (const char *key);
|
||||
/* Fill a DES context CTX with subkeys calculated from 64bit KEY.
|
||||
* Does not check parity bits, but simply ignore them. Does not check
|
||||
* for weak keys. */
|
||||
extern void gl_des_setkey (gl_des_ctx * ctx, const char *key);
|
||||
extern void MHD_gl_des_setkey (MHD_gl_des_ctx * ctx, const char *key);
|
||||
|
||||
/* Fill a DES context CTX with subkeys calculated from 64bit KEY, with
|
||||
* weak key checking. Does not check parity bits, but simply ignore
|
||||
* them. */
|
||||
extern bool gl_des_makekey (gl_des_ctx * ctx, const char *key, size_t keylen);
|
||||
extern bool MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, size_t keylen);
|
||||
|
||||
/* Electronic Codebook Mode DES encryption/decryption of data
|
||||
* according to 'mode'. */
|
||||
extern void
|
||||
gl_des_ecb_crypt (gl_des_ctx * ctx, const char *from, char *to, int mode);
|
||||
MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *from, char *to, int mode);
|
||||
|
||||
#define gl_des_ecb_encrypt(ctx, from, to) gl_des_ecb_crypt(ctx, from, to, 0)
|
||||
#define gl_des_ecb_decrypt(ctx, from, to) gl_des_ecb_crypt(ctx, from, to, 1)
|
||||
#define MHD_gl_des_ecb_encrypt(ctx, from, to) MHD_gl_des_ecb_crypt(ctx, from, to, 0)
|
||||
#define MHD_gl_des_ecb_decrypt(ctx, from, to) MHD_gl_des_ecb_crypt(ctx, from, to, 1)
|
||||
|
||||
/* Triple-DES
|
||||
* ----------
|
||||
@@ -80,7 +80,7 @@ gl_des_ecb_crypt (gl_des_ctx * ctx, const char *from, char *to, int mode);
|
||||
* 64bit keys in KEY1 and KEY2. Does not check the parity bits of the
|
||||
* keys, but simply ignore them. Does not check for weak keys. */
|
||||
extern void
|
||||
gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2);
|
||||
MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2);
|
||||
|
||||
/*
|
||||
* Fill a Triple-DES context CTX with subkeys calculated from three
|
||||
@@ -88,22 +88,22 @@ gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2);
|
||||
* of the keys, but simply ignore them. Does not check for weak
|
||||
* keys. */
|
||||
extern void
|
||||
gl_3des_set3keys (gl_3des_ctx * ctx,
|
||||
MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx,
|
||||
const char *key1, const char *key2, const char *key3);
|
||||
|
||||
/* Fill a Triple-DES context CTX with subkeys calculated from three
|
||||
* concatenated 64bit keys in KEY, with weak key checking. Does not
|
||||
* check the parity bits of the keys, but simply ignore them. */
|
||||
extern bool
|
||||
gl_3des_makekey (gl_3des_ctx * ctx, const char *key, size_t keylen);
|
||||
MHD_gl_3des_makekey (MHD_gl_3des_ctx * ctx, const char *key, size_t keylen);
|
||||
|
||||
/* Electronic Codebook Mode Triple-DES encryption/decryption of data
|
||||
* according to 'mode'. Sometimes this mode is named 'EDE' mode
|
||||
* (Encryption-Decryption-Encryption). */
|
||||
extern void
|
||||
gl_3des_ecb_crypt (gl_3des_ctx * ctx, const char *from, char *to, int mode);
|
||||
MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *from, char *to, int mode);
|
||||
|
||||
#define gl_3des_ecb_encrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,0)
|
||||
#define gl_3des_ecb_decrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,1)
|
||||
#define MHD_gl_3des_ecb_encrypt(ctx, from, to) MHD_gl_3des_ecb_crypt(ctx,from,to,0)
|
||||
#define MHD_gl_3des_ecb_decrypt(ctx, from, to) MHD_gl_3des_ecb_crypt(ctx,from,to,1)
|
||||
|
||||
#endif /* DES_H */
|
||||
@@ -68,13 +68,13 @@
|
||||
#undef close
|
||||
|
||||
Gc_rc
|
||||
gc_init (void)
|
||||
MHD_gc_init (void)
|
||||
{
|
||||
return GC_OK;
|
||||
}
|
||||
|
||||
void
|
||||
gc_done (void)
|
||||
MHD_gc_done (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -139,19 +139,19 @@ randomize (int level, char *data, size_t datalen)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_nonce (char *data, size_t datalen)
|
||||
MHD_gc_nonce (char *data, size_t datalen)
|
||||
{
|
||||
return randomize (0, data, datalen);
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_pseudo_random (char *data, size_t datalen)
|
||||
MHD_gc_pseudo_random (char *data, size_t datalen)
|
||||
{
|
||||
return randomize (1, data, datalen);
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_random (char *data, size_t datalen)
|
||||
MHD_gc_random (char *data, size_t datalen)
|
||||
{
|
||||
return randomize (2, data, datalen);
|
||||
}
|
||||
@@ -160,17 +160,17 @@ gc_random (char *data, size_t datalen)
|
||||
|
||||
/* Memory allocation. */
|
||||
void
|
||||
gc_set_allocators (gc_malloc_t func_malloc,
|
||||
gc_malloc_t secure_malloc,
|
||||
gc_secure_check_t secure_check,
|
||||
gc_realloc_t func_realloc, gc_free_t func_free)
|
||||
MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
|
||||
MHD_gc_malloc_t secure_malloc,
|
||||
MHD_gc_secure_check_t secure_check,
|
||||
MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ciphers. */
|
||||
|
||||
typedef struct _gc_cipher_ctx
|
||||
typedef struct _MHD_gc_cipher_ctx
|
||||
{
|
||||
Gc_cipher alg;
|
||||
Gc_cipher_mode mode;
|
||||
@@ -182,20 +182,20 @@ typedef struct _gc_cipher_ctx
|
||||
arcfour_context arcfourContext;
|
||||
#endif
|
||||
#ifdef GNULIB_GC_DES
|
||||
gl_des_ctx desContext;
|
||||
MHD_gl_des_ctx desContext;
|
||||
#endif
|
||||
#ifdef GNULIB_GC_RIJNDAEL
|
||||
rijndaelKeyInstance aesEncKey;
|
||||
rijndaelKeyInstance aesDecKey;
|
||||
rijndaelCipherInstance aesContext;
|
||||
#endif
|
||||
} _gc_cipher_ctx;
|
||||
} _MHD_gc_cipher_ctx;
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_open (Gc_cipher alg,
|
||||
Gc_cipher_mode mode, gc_cipher_handle * outhandle)
|
||||
MHD_gc_cipher_open (Gc_cipher alg,
|
||||
Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle)
|
||||
{
|
||||
_gc_cipher_ctx *ctx;
|
||||
_MHD_gc_cipher_ctx *ctx;
|
||||
Gc_rc rc = GC_OK;
|
||||
|
||||
ctx = calloc (sizeof (*ctx), 1);
|
||||
@@ -277,9 +277,9 @@ gc_cipher_open (Gc_cipher alg,
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
|
||||
MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *key)
|
||||
{
|
||||
_gc_cipher_ctx *ctx = handle;
|
||||
_MHD_gc_cipher_ctx *ctx = handle;
|
||||
|
||||
switch (ctx->alg)
|
||||
{
|
||||
@@ -300,7 +300,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
|
||||
case GC_DES:
|
||||
if (keylen != 8)
|
||||
return GC_INVALID_CIPHER;
|
||||
gl_des_setkey (&ctx->desContext, key);
|
||||
MHD_gl_des_setkey (&ctx->desContext, key);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -341,9 +341,9 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
|
||||
MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv)
|
||||
{
|
||||
_gc_cipher_ctx *ctx = handle;
|
||||
_MHD_gc_cipher_ctx *ctx = handle;
|
||||
|
||||
switch (ctx->alg)
|
||||
{
|
||||
@@ -395,9 +395,9 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
|
||||
{
|
||||
_gc_cipher_ctx *ctx = handle;
|
||||
_MHD_gc_cipher_ctx *ctx = handle;
|
||||
|
||||
switch (ctx->alg)
|
||||
{
|
||||
@@ -438,7 +438,7 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
#ifdef GNULIB_GC_DES
|
||||
case GC_DES:
|
||||
for (; len >= 8; len -= 8, data += 8)
|
||||
gl_des_ecb_encrypt (&ctx->desContext, data, data);
|
||||
MHD_gl_des_ecb_encrypt (&ctx->desContext, data, data);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -465,9 +465,9 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
|
||||
{
|
||||
_gc_cipher_ctx *ctx = handle;
|
||||
_MHD_gc_cipher_ctx *ctx = handle;
|
||||
|
||||
switch (ctx->alg)
|
||||
{
|
||||
@@ -510,7 +510,7 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
#ifdef GNULIB_GC_DES
|
||||
case GC_DES:
|
||||
for (; len >= 8; len -= 8, data += 8)
|
||||
gl_des_ecb_decrypt (&ctx->desContext, data, data);
|
||||
MHD_gl_des_ecb_decrypt (&ctx->desContext, data, data);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -537,9 +537,9 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_close (gc_cipher_handle handle)
|
||||
MHD_gc_cipher_close (MHD_gc_cipher_handle handle)
|
||||
{
|
||||
_gc_cipher_ctx *ctx = handle;
|
||||
_MHD_gc_cipher_ctx *ctx = handle;
|
||||
|
||||
if (ctx)
|
||||
free (ctx);
|
||||
@@ -551,23 +551,23 @@ gc_cipher_close (gc_cipher_handle handle)
|
||||
|
||||
#define MAX_DIGEST_SIZE 20
|
||||
|
||||
typedef struct _gc_hash_ctx
|
||||
typedef struct _MHD_gc_hash_ctx
|
||||
{
|
||||
Gc_hash alg;
|
||||
Gc_hash_mode mode;
|
||||
char hash[MAX_DIGEST_SIZE];
|
||||
#ifdef GNULIB_GC_MD5
|
||||
struct md5_ctx md5Context;
|
||||
struct MHD_md5_ctx md5Context;
|
||||
#endif
|
||||
#ifdef GNULIB_GC_SHA1
|
||||
struct sha1_ctx sha1Context;
|
||||
struct MHD_sha1_ctx sha1Context;
|
||||
#endif
|
||||
} _gc_hash_ctx;
|
||||
} _MHD_gc_hash_ctx;
|
||||
|
||||
Gc_rc
|
||||
gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
|
||||
MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, MHD_gc_hash_handle * outhandle)
|
||||
{
|
||||
_gc_hash_ctx *ctx;
|
||||
_MHD_gc_hash_ctx *ctx;
|
||||
Gc_rc rc = GC_OK;
|
||||
|
||||
ctx = calloc (sizeof (*ctx), 1);
|
||||
@@ -581,13 +581,13 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
|
||||
{
|
||||
#ifdef GNULIB_GC_MD5
|
||||
case GC_MD5:
|
||||
md5_init_ctx (&ctx->md5Context);
|
||||
MHD_md5_init_ctx (&ctx->md5Context);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_GC_SHA1
|
||||
case GC_SHA1:
|
||||
sha1_init_ctx (&ctx->sha1Context);
|
||||
MHD_sha1_init_ctx (&ctx->sha1Context);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -615,10 +615,10 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
|
||||
MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle)
|
||||
{
|
||||
_gc_hash_ctx *in = handle;
|
||||
_gc_hash_ctx *out;
|
||||
_MHD_gc_hash_ctx *in = handle;
|
||||
_MHD_gc_hash_ctx *out;
|
||||
|
||||
*outhandle = out = calloc (sizeof (*out), 1);
|
||||
if (!out)
|
||||
@@ -630,7 +630,7 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
|
||||
}
|
||||
|
||||
size_t
|
||||
gc_hash_digest_length (Gc_hash hash)
|
||||
MHD_gc_hash_digest_length (Gc_hash hash)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
@@ -664,21 +664,21 @@ gc_hash_digest_length (Gc_hash hash)
|
||||
}
|
||||
|
||||
void
|
||||
gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
|
||||
MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data)
|
||||
{
|
||||
_gc_hash_ctx *ctx = handle;
|
||||
_MHD_gc_hash_ctx *ctx = handle;
|
||||
|
||||
switch (ctx->alg)
|
||||
{
|
||||
#ifdef GNULIB_GC_MD5
|
||||
case GC_MD5:
|
||||
md5_process_bytes (data, len, &ctx->md5Context);
|
||||
MHD_md5_process_bytes (data, len, &ctx->md5Context);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_GC_SHA1
|
||||
case GC_SHA1:
|
||||
sha1_process_bytes (data, len, &ctx->sha1Context);
|
||||
MHD_sha1_process_bytes (data, len, &ctx->sha1Context);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -688,23 +688,23 @@ gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
|
||||
}
|
||||
|
||||
const char *
|
||||
gc_hash_read (gc_hash_handle handle)
|
||||
MHD_gc_hash_read (MHD_gc_hash_handle handle)
|
||||
{
|
||||
_gc_hash_ctx *ctx = handle;
|
||||
_MHD_gc_hash_ctx *ctx = handle;
|
||||
const char *ret = NULL;
|
||||
|
||||
switch (ctx->alg)
|
||||
{
|
||||
#ifdef GNULIB_GC_MD5
|
||||
case GC_MD5:
|
||||
md5_finish_ctx (&ctx->md5Context, ctx->hash);
|
||||
MHD_md5_finish_ctx (&ctx->md5Context, ctx->hash);
|
||||
ret = ctx->hash;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_GC_SHA1
|
||||
case GC_SHA1:
|
||||
sha1_finish_ctx (&ctx->sha1Context, ctx->hash);
|
||||
MHD_sha1_finish_ctx (&ctx->sha1Context, ctx->hash);
|
||||
ret = ctx->hash;
|
||||
break;
|
||||
#endif
|
||||
@@ -717,27 +717,27 @@ gc_hash_read (gc_hash_handle handle)
|
||||
}
|
||||
|
||||
void
|
||||
gc_hash_close (gc_hash_handle handle)
|
||||
MHD_gc_hash_close (MHD_gc_hash_handle handle)
|
||||
{
|
||||
_gc_hash_ctx *ctx = handle;
|
||||
_MHD_gc_hash_ctx *ctx = handle;
|
||||
|
||||
free (ctx);
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
|
||||
MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
|
||||
{
|
||||
switch (hash)
|
||||
{
|
||||
#ifdef GNULIB_GC_MD5
|
||||
case GC_MD5:
|
||||
md5_buffer (in, inlen, resbuf);
|
||||
MHD_md5_buffer (in, inlen, resbuf);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_GC_SHA1
|
||||
case GC_SHA1:
|
||||
sha1_buffer (in, inlen, resbuf);
|
||||
MHD_sha1_buffer (in, inlen, resbuf);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -750,38 +750,38 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
|
||||
|
||||
#ifdef GNULIB_GC_MD5
|
||||
Gc_rc
|
||||
gc_md5 (const void *in, size_t inlen, void *resbuf)
|
||||
MHD_gc_md5 (const void *in, size_t inlen, void *resbuf)
|
||||
{
|
||||
md5_buffer (in, inlen, resbuf);
|
||||
MHD_md5_buffer (in, inlen, resbuf);
|
||||
return GC_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_GC_SHA1
|
||||
Gc_rc
|
||||
gc_sha1 (const void *in, size_t inlen, void *resbuf)
|
||||
MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf)
|
||||
{
|
||||
sha1_buffer (in, inlen, resbuf);
|
||||
MHD_sha1_buffer (in, inlen, resbuf);
|
||||
return GC_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_GC_HMAC_MD5
|
||||
Gc_rc
|
||||
gc_hmac_md5 (const void *key, size_t keylen,
|
||||
MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen,
|
||||
const void *in, size_t inlen, char *resbuf)
|
||||
{
|
||||
hmac_md5 (key, keylen, in, inlen, resbuf);
|
||||
MHD_hmac_md5 (key, keylen, in, inlen, resbuf);
|
||||
return GC_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_GC_HMAC_SHA1
|
||||
Gc_rc
|
||||
gc_hmac_sha1 (const void *key,
|
||||
MHD_gc_MHD_hmac_sha1 (const void *key,
|
||||
size_t keylen, const void *in, size_t inlen, char *resbuf)
|
||||
{
|
||||
hmac_sha1 (key, keylen, in, inlen, resbuf);
|
||||
MHD_hmac_sha1 (key, keylen, in, inlen, resbuf);
|
||||
return GC_OK;
|
||||
}
|
||||
#endif
|
||||
@@ -36,7 +36,7 @@
|
||||
/* Initialization. */
|
||||
|
||||
Gc_rc
|
||||
gc_init (void)
|
||||
MHD_gc_init (void)
|
||||
{
|
||||
gcry_error_t err;
|
||||
|
||||
@@ -54,7 +54,7 @@ gc_init (void)
|
||||
}
|
||||
|
||||
void
|
||||
gc_done (void)
|
||||
MHD_gc_done (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -64,21 +64,21 @@ gc_done (void)
|
||||
/* Randomness. */
|
||||
|
||||
Gc_rc
|
||||
gc_nonce (char *data, size_t datalen)
|
||||
MHD_gc_nonce (char *data, size_t datalen)
|
||||
{
|
||||
gcry_create_nonce ((unsigned char *) data, datalen);
|
||||
return GC_OK;
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_pseudo_random (char *data, size_t datalen)
|
||||
MHD_gc_pseudo_random (char *data, size_t datalen)
|
||||
{
|
||||
gcry_randomize ((unsigned char *) data, datalen, GCRY_STRONG_RANDOM);
|
||||
return GC_OK;
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_random (char *data, size_t datalen)
|
||||
MHD_gc_random (char *data, size_t datalen)
|
||||
{
|
||||
gcry_randomize ((unsigned char *) data, datalen, GCRY_VERY_STRONG_RANDOM);
|
||||
return GC_OK;
|
||||
@@ -89,10 +89,10 @@ gc_random (char *data, size_t datalen)
|
||||
/* Memory allocation. */
|
||||
|
||||
void
|
||||
gc_set_allocators (gc_malloc_t func_malloc,
|
||||
gc_malloc_t secure_malloc,
|
||||
gc_secure_check_t secure_check,
|
||||
gc_realloc_t func_realloc, gc_free_t func_free)
|
||||
MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
|
||||
MHD_gc_malloc_t secure_malloc,
|
||||
MHD_gc_secure_check_t secure_check,
|
||||
MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free)
|
||||
{
|
||||
gcry_set_allocation_handler (func_malloc, secure_malloc, secure_check,
|
||||
func_realloc, func_free);
|
||||
@@ -101,8 +101,8 @@ gc_set_allocators (gc_malloc_t func_malloc,
|
||||
/* Ciphers. */
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_open (Gc_cipher alg,
|
||||
Gc_cipher_mode mode, gc_cipher_handle * outhandle)
|
||||
MHD_gc_cipher_open (Gc_cipher alg,
|
||||
Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle)
|
||||
{
|
||||
int gcryalg, gcrymode;
|
||||
gcry_error_t err;
|
||||
@@ -179,7 +179,7 @@ gc_cipher_open (Gc_cipher alg,
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
|
||||
MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *key)
|
||||
{
|
||||
gcry_error_t err;
|
||||
|
||||
@@ -191,7 +191,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
|
||||
MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv)
|
||||
{
|
||||
gcry_error_t err;
|
||||
|
||||
@@ -203,7 +203,7 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
|
||||
{
|
||||
if (gcry_cipher_encrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) !=
|
||||
0)
|
||||
@@ -213,7 +213,7 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
|
||||
{
|
||||
if (gcry_cipher_decrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) !=
|
||||
0)
|
||||
@@ -223,7 +223,7 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_cipher_close (gc_cipher_handle handle)
|
||||
MHD_gc_cipher_close (MHD_gc_cipher_handle handle)
|
||||
{
|
||||
gcry_cipher_close (handle);
|
||||
|
||||
@@ -232,17 +232,17 @@ gc_cipher_close (gc_cipher_handle handle)
|
||||
|
||||
/* Hashes. */
|
||||
|
||||
typedef struct _gc_hash_ctx
|
||||
typedef struct _MHD_gc_hash_ctx
|
||||
{
|
||||
Gc_hash alg;
|
||||
Gc_hash_mode mode;
|
||||
gcry_md_hd_t gch;
|
||||
} _gc_hash_ctx;
|
||||
} _MHD_gc_hash_ctx;
|
||||
|
||||
Gc_rc
|
||||
gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
|
||||
MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, MHD_gc_hash_handle * outhandle)
|
||||
{
|
||||
_gc_hash_ctx *ctx;
|
||||
_MHD_gc_hash_ctx *ctx;
|
||||
int gcryalg = 0, gcrymode = 0;
|
||||
gcry_error_t err;
|
||||
Gc_rc rc = GC_OK;
|
||||
@@ -322,10 +322,10 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
|
||||
MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle)
|
||||
{
|
||||
_gc_hash_ctx *in = handle;
|
||||
_gc_hash_ctx *out;
|
||||
_MHD_gc_hash_ctx *in = handle;
|
||||
_MHD_gc_hash_ctx *out;
|
||||
int err;
|
||||
|
||||
*outhandle = out = calloc (sizeof (*out), 1);
|
||||
@@ -345,7 +345,7 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
|
||||
}
|
||||
|
||||
size_t
|
||||
gc_hash_digest_length (Gc_hash hash)
|
||||
MHD_gc_hash_digest_length (Gc_hash hash)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
@@ -391,23 +391,23 @@ gc_hash_digest_length (Gc_hash hash)
|
||||
}
|
||||
|
||||
void
|
||||
gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key)
|
||||
MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, const char *key)
|
||||
{
|
||||
_gc_hash_ctx *ctx = handle;
|
||||
_MHD_gc_hash_ctx *ctx = handle;
|
||||
gcry_md_setkey (ctx->gch, key, len);
|
||||
}
|
||||
|
||||
void
|
||||
gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
|
||||
MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data)
|
||||
{
|
||||
_gc_hash_ctx *ctx = handle;
|
||||
_MHD_gc_hash_ctx *ctx = handle;
|
||||
gcry_md_write (ctx->gch, data, len);
|
||||
}
|
||||
|
||||
const char *
|
||||
gc_hash_read (gc_hash_handle handle)
|
||||
MHD_gc_hash_read (MHD_gc_hash_handle handle)
|
||||
{
|
||||
_gc_hash_ctx *ctx = handle;
|
||||
_MHD_gc_hash_ctx *ctx = handle;
|
||||
const char *digest;
|
||||
{
|
||||
gcry_md_final (ctx->gch);
|
||||
@@ -418,9 +418,9 @@ gc_hash_read (gc_hash_handle handle)
|
||||
}
|
||||
|
||||
void
|
||||
gc_hash_close (gc_hash_handle handle)
|
||||
MHD_gc_hash_close (MHD_gc_hash_handle handle)
|
||||
{
|
||||
_gc_hash_ctx *ctx = handle;
|
||||
_MHD_gc_hash_ctx *ctx = handle;
|
||||
|
||||
gcry_md_close (ctx->gch);
|
||||
|
||||
@@ -428,7 +428,7 @@ gc_hash_close (gc_hash_handle handle)
|
||||
}
|
||||
|
||||
Gc_rc
|
||||
gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
|
||||
MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
|
||||
{
|
||||
int gcryalg;
|
||||
|
||||
@@ -482,7 +482,7 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
|
||||
/* One-call interface. */
|
||||
#ifdef GNULIB_GC_MD5
|
||||
Gc_rc
|
||||
gc_md5 (const void *in, size_t inlen, void *resbuf)
|
||||
MHD_gc_md5 (const void *in, size_t inlen, void *resbuf)
|
||||
{
|
||||
size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
|
||||
gcry_md_hd_t hd;
|
||||
@@ -514,7 +514,7 @@ gc_md5 (const void *in, size_t inlen, void *resbuf)
|
||||
|
||||
#ifdef GNULIB_GC_SHA1
|
||||
Gc_rc
|
||||
gc_sha1 (const void *in, size_t inlen, void *resbuf)
|
||||
MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf)
|
||||
{
|
||||
size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
|
||||
gcry_md_hd_t hd;
|
||||
@@ -546,7 +546,7 @@ gc_sha1 (const void *in, size_t inlen, void *resbuf)
|
||||
|
||||
#ifdef GNULIB_GC_HMAC_MD5
|
||||
Gc_rc
|
||||
gc_hmac_md5 (const void *key, size_t keylen,
|
||||
MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen,
|
||||
const void *in, size_t inlen, char *resbuf)
|
||||
{
|
||||
size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
|
||||
@@ -586,7 +586,7 @@ gc_hmac_md5 (const void *key, size_t keylen,
|
||||
|
||||
#ifdef GNULIB_GC_HMAC_SHA1
|
||||
Gc_rc
|
||||
gc_hmac_sha1 (const void *key,
|
||||
MHD_gc_MHD_hmac_sha1 (const void *key,
|
||||
size_t keylen, const void *in, size_t inlen, char *resbuf)
|
||||
{
|
||||
size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
*/
|
||||
|
||||
Gc_rc
|
||||
gc_pbkdf2_sha1 (const char *P, size_t Plen,
|
||||
MHD_gc_pbkdf2_sha1 (const char *P, size_t Plen,
|
||||
const char *S, size_t Slen,
|
||||
unsigned int c, char *DK, size_t dkLen)
|
||||
{
|
||||
@@ -161,10 +161,10 @@ gc_pbkdf2_sha1 (const char *P, size_t Plen,
|
||||
tmp[Slen + 2] = (i & 0x0000ff00) >> 8;
|
||||
tmp[Slen + 3] = (i & 0x000000ff) >> 0;
|
||||
|
||||
rc = gc_hmac_sha1 (P, Plen, tmp, tmplen, U);
|
||||
rc = MHD_gc_MHD_hmac_sha1 (P, Plen, tmp, tmplen, U);
|
||||
}
|
||||
else
|
||||
rc = gc_hmac_sha1 (P, Plen, U, hLen, U);
|
||||
rc = MHD_gc_MHD_hmac_sha1 (P, Plen, U, hLen, U);
|
||||
|
||||
if (rc != GC_OK)
|
||||
{
|
||||
|
||||
+39
-39
@@ -58,7 +58,7 @@ enum Gc_hash_mode
|
||||
};
|
||||
typedef enum Gc_hash_mode Gc_hash_mode;
|
||||
|
||||
typedef void *gc_hash_handle;
|
||||
typedef void *MHD_gc_hash_handle;
|
||||
|
||||
#define GC_MD2_DIGEST_SIZE 16
|
||||
#define GC_MD4_DIGEST_SIZE 16
|
||||
@@ -93,49 +93,49 @@ enum Gc_cipher_mode
|
||||
};
|
||||
typedef enum Gc_cipher_mode Gc_cipher_mode;
|
||||
|
||||
typedef void *gc_cipher_handle;
|
||||
typedef void *MHD_gc_cipher_handle;
|
||||
|
||||
/* Call before respectively after any other functions. */
|
||||
Gc_rc gc_init (void);
|
||||
void gc_done (void);
|
||||
Gc_rc MHD_gc_init (void);
|
||||
void MHD_gc_done (void);
|
||||
|
||||
/* Memory allocation (avoid). */
|
||||
typedef void *(*gc_malloc_t) (size_t n);
|
||||
typedef int (*gc_secure_check_t) (const void *);
|
||||
typedef void *(*gc_realloc_t) (void *p, size_t n);
|
||||
typedef void (*gc_free_t) (void *);
|
||||
void gc_set_allocators (gc_malloc_t func_malloc,
|
||||
gc_malloc_t secure_malloc,
|
||||
gc_secure_check_t secure_check,
|
||||
gc_realloc_t func_realloc, gc_free_t func_free);
|
||||
typedef void *(*MHD_gc_malloc_t) (size_t n);
|
||||
typedef int (*MHD_gc_secure_check_t) (const void *);
|
||||
typedef void *(*MHD_gc_realloc_t) (void *p, size_t n);
|
||||
typedef void (*MHD_gc_free_t) (void *);
|
||||
void MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
|
||||
MHD_gc_malloc_t secure_malloc,
|
||||
MHD_gc_secure_check_t secure_check,
|
||||
MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free);
|
||||
|
||||
/* Randomness. */
|
||||
Gc_rc gc_nonce (char *data, size_t datalen);
|
||||
Gc_rc gc_pseudo_random (char *data, size_t datalen);
|
||||
Gc_rc gc_random (char *data, size_t datalen);
|
||||
Gc_rc MHD_gc_nonce (char *data, size_t datalen);
|
||||
Gc_rc MHD_gc_pseudo_random (char *data, size_t datalen);
|
||||
Gc_rc MHD_gc_random (char *data, size_t datalen);
|
||||
|
||||
/* Ciphers. */
|
||||
Gc_rc gc_cipher_open (Gc_cipher cipher,
|
||||
Gc_cipher_mode mode, gc_cipher_handle * outhandle);
|
||||
Gc_rc gc_cipher_setkey (gc_cipher_handle handle,
|
||||
Gc_rc MHD_gc_cipher_open (Gc_cipher cipher,
|
||||
Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle);
|
||||
Gc_rc MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle,
|
||||
size_t keylen, const char *key);
|
||||
Gc_rc gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv);
|
||||
Gc_rc gc_cipher_encrypt_inline (gc_cipher_handle handle,
|
||||
Gc_rc MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv);
|
||||
Gc_rc MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle,
|
||||
size_t len, char *data);
|
||||
Gc_rc gc_cipher_decrypt_inline (gc_cipher_handle handle,
|
||||
Gc_rc MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle,
|
||||
size_t len, char *data);
|
||||
Gc_rc gc_cipher_close (gc_cipher_handle handle);
|
||||
Gc_rc MHD_gc_cipher_close (MHD_gc_cipher_handle handle);
|
||||
|
||||
/* Hashes. */
|
||||
|
||||
Gc_rc gc_hash_open (Gc_hash hash,
|
||||
Gc_hash_mode mode, gc_hash_handle * outhandle);
|
||||
Gc_rc gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle);
|
||||
size_t gc_hash_digest_length (Gc_hash hash);
|
||||
void gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key);
|
||||
void gc_hash_write (gc_hash_handle handle, size_t len, const char *data);
|
||||
const char *gc_hash_read (gc_hash_handle handle);
|
||||
void gc_hash_close (gc_hash_handle handle);
|
||||
Gc_rc MHD_gc_hash_open (Gc_hash hash,
|
||||
Gc_hash_mode mode, MHD_gc_hash_handle * outhandle);
|
||||
Gc_rc MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle);
|
||||
size_t MHD_gc_hash_digest_length (Gc_hash hash);
|
||||
void MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, const char *key);
|
||||
void MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data);
|
||||
const char *MHD_gc_hash_read (MHD_gc_hash_handle handle);
|
||||
void MHD_gc_hash_close (MHD_gc_hash_handle handle);
|
||||
|
||||
/* Compute a hash value over buffer IN of INLEN bytes size using the
|
||||
algorithm HASH, placing the result in the pre-allocated buffer OUT.
|
||||
@@ -143,16 +143,16 @@ void gc_hash_close (gc_hash_handle handle);
|
||||
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. */
|
||||
Gc_rc gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out);
|
||||
Gc_rc MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out);
|
||||
|
||||
/* One-call interface. */
|
||||
Gc_rc gc_md2 (const void *in, size_t inlen, void *resbuf);
|
||||
Gc_rc gc_md4 (const void *in, size_t inlen, void *resbuf);
|
||||
Gc_rc gc_md5 (const void *in, size_t inlen, void *resbuf);
|
||||
Gc_rc gc_sha1 (const void *in, size_t inlen, void *resbuf);
|
||||
Gc_rc gc_hmac_md5 (const void *key,
|
||||
Gc_rc MHD_gc_md2 (const void *in, size_t inlen, void *resbuf);
|
||||
Gc_rc MHD_gc_md4 (const void *in, size_t inlen, void *resbuf);
|
||||
Gc_rc MHD_gc_md5 (const void *in, size_t inlen, void *resbuf);
|
||||
Gc_rc MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf);
|
||||
Gc_rc MHD_gc_MHD_hmac_md5 (const void *key,
|
||||
size_t keylen, const void *in, size_t inlen, char *resbuf);
|
||||
Gc_rc gc_hmac_sha1 (const void *key,
|
||||
Gc_rc MHD_gc_MHD_hmac_sha1 (const void *key,
|
||||
size_t keylen,
|
||||
const void *in, size_t inlen, char *resbuf);
|
||||
|
||||
@@ -163,7 +163,7 @@ Gc_rc gc_hmac_sha1 (const void *key,
|
||||
counts are 1000-20000). This function "stretches" the key to be
|
||||
exactly dkLen bytes long. GC_OK is returned on success, otherwise
|
||||
an Gc_rc error code is returned. */
|
||||
Gc_rc gc_pbkdf2_sha1 (const char *P,
|
||||
Gc_rc MHD_gc_pbkdf2_sha1 (const char *P,
|
||||
size_t Plen,
|
||||
const char *S,
|
||||
size_t Slen, unsigned int c, char *DK, size_t dkLen);
|
||||
@@ -285,7 +285,7 @@ Gc_rc gc_pbkdf2_sha1 (const char *P,
|
||||
requirement, what entropy quality it require, and call the proper API.
|
||||
Meeting the implied semantic properties should be the job for gnulib.
|
||||
|
||||
>> Perhaps gc_dev_random and gc_dev_urandom?
|
||||
>> Perhaps MHD_gc_dev_random and MHD_gc_dev_urandom?
|
||||
>
|
||||
> To some extent. I'd rather insulate the user from the details of
|
||||
> where the random numbers come from. On the other hand we need to
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
#define OPAD 0x5c
|
||||
|
||||
int
|
||||
hmac_md5 (const void *key, size_t keylen,
|
||||
MHD_hmac_md5 (const void *key, size_t keylen,
|
||||
const void *in, size_t inlen, void *resbuf)
|
||||
{
|
||||
struct md5_ctx inner;
|
||||
struct md5_ctx outer;
|
||||
struct MHD_md5_ctx inner;
|
||||
struct MHD_md5_ctx outer;
|
||||
char optkeybuf[16];
|
||||
char block[64];
|
||||
char innerhash[16];
|
||||
@@ -43,11 +43,11 @@ hmac_md5 (const void *key, size_t keylen,
|
||||
|
||||
if (keylen > 64)
|
||||
{
|
||||
struct md5_ctx keyhash;
|
||||
struct MHD_md5_ctx keyhash;
|
||||
|
||||
md5_init_ctx (&keyhash);
|
||||
md5_process_bytes (key, keylen, &keyhash);
|
||||
md5_finish_ctx (&keyhash, optkeybuf);
|
||||
MHD_md5_init_ctx (&keyhash);
|
||||
MHD_md5_process_bytes (key, keylen, &keyhash);
|
||||
MHD_md5_finish_ctx (&keyhash, optkeybuf);
|
||||
|
||||
key = optkeybuf;
|
||||
keylen = 16;
|
||||
@@ -55,27 +55,27 @@ hmac_md5 (const void *key, size_t keylen,
|
||||
|
||||
/* Compute INNERHASH from KEY and IN. */
|
||||
|
||||
md5_init_ctx (&inner);
|
||||
MHD_md5_init_ctx (&inner);
|
||||
|
||||
memset (block, IPAD, sizeof (block));
|
||||
memxor (block, key, keylen);
|
||||
MHD_memxor (block, key, keylen);
|
||||
|
||||
md5_process_block (block, 64, &inner);
|
||||
md5_process_bytes (in, inlen, &inner);
|
||||
MHD_md5_process_block (block, 64, &inner);
|
||||
MHD_md5_process_bytes (in, inlen, &inner);
|
||||
|
||||
md5_finish_ctx (&inner, innerhash);
|
||||
MHD_md5_finish_ctx (&inner, innerhash);
|
||||
|
||||
/* Compute result from KEY and INNERHASH. */
|
||||
|
||||
md5_init_ctx (&outer);
|
||||
MHD_md5_init_ctx (&outer);
|
||||
|
||||
memset (block, OPAD, sizeof (block));
|
||||
memxor (block, key, keylen);
|
||||
MHD_memxor (block, key, keylen);
|
||||
|
||||
md5_process_block (block, 64, &outer);
|
||||
md5_process_bytes (innerhash, 16, &outer);
|
||||
MHD_md5_process_block (block, 64, &outer);
|
||||
MHD_md5_process_bytes (innerhash, 16, &outer);
|
||||
|
||||
md5_finish_ctx (&outer, resbuf);
|
||||
MHD_md5_finish_ctx (&outer, resbuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -30,11 +30,11 @@
|
||||
#define OPAD 0x5c
|
||||
|
||||
int
|
||||
hmac_sha1 (const void *key, size_t keylen,
|
||||
MHD_hmac_sha1 (const void *key, size_t keylen,
|
||||
const void *in, size_t inlen, void *resbuf)
|
||||
{
|
||||
struct sha1_ctx inner;
|
||||
struct sha1_ctx outer;
|
||||
struct MHD_sha1_ctx inner;
|
||||
struct MHD_sha1_ctx outer;
|
||||
char optkeybuf[20];
|
||||
char block[64];
|
||||
char innerhash[20];
|
||||
@@ -43,11 +43,11 @@ hmac_sha1 (const void *key, size_t keylen,
|
||||
|
||||
if (keylen > 64)
|
||||
{
|
||||
struct sha1_ctx keyhash;
|
||||
struct MHD_sha1_ctx keyhash;
|
||||
|
||||
sha1_init_ctx (&keyhash);
|
||||
sha1_process_bytes (key, keylen, &keyhash);
|
||||
sha1_finish_ctx (&keyhash, optkeybuf);
|
||||
MHD_sha1_init_ctx (&keyhash);
|
||||
MHD_sha1_process_bytes (key, keylen, &keyhash);
|
||||
MHD_sha1_finish_ctx (&keyhash, optkeybuf);
|
||||
|
||||
key = optkeybuf;
|
||||
keylen = 20;
|
||||
@@ -55,27 +55,27 @@ hmac_sha1 (const void *key, size_t keylen,
|
||||
|
||||
/* Compute INNERHASH from KEY and IN. */
|
||||
|
||||
sha1_init_ctx (&inner);
|
||||
MHD_sha1_init_ctx (&inner);
|
||||
|
||||
memset (block, IPAD, sizeof (block));
|
||||
memxor (block, key, keylen);
|
||||
MHD_memxor (block, key, keylen);
|
||||
|
||||
sha1_process_block (block, 64, &inner);
|
||||
sha1_process_bytes (in, inlen, &inner);
|
||||
MHD_sha1_process_block (block, 64, &inner);
|
||||
MHD_sha1_process_bytes (in, inlen, &inner);
|
||||
|
||||
sha1_finish_ctx (&inner, innerhash);
|
||||
MHD_sha1_finish_ctx (&inner, innerhash);
|
||||
|
||||
/* Compute result from KEY and INNERHASH. */
|
||||
|
||||
sha1_init_ctx (&outer);
|
||||
MHD_sha1_init_ctx (&outer);
|
||||
|
||||
memset (block, OPAD, sizeof (block));
|
||||
memxor (block, key, keylen);
|
||||
MHD_memxor (block, key, keylen);
|
||||
|
||||
sha1_process_block (block, 64, &outer);
|
||||
sha1_process_bytes (innerhash, 20, &outer);
|
||||
MHD_sha1_process_block (block, 64, &outer);
|
||||
MHD_sha1_process_bytes (innerhash, 20, &outer);
|
||||
|
||||
sha1_finish_ctx (&outer, resbuf);
|
||||
MHD_sha1_finish_ctx (&outer, resbuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
KEYLEN bytes, writing the output to pre-allocated 16 byte minimum
|
||||
RESBUF buffer. Return 0 on success. */
|
||||
int
|
||||
hmac_md5 (const void *key, size_t keylen,
|
||||
MHD_hmac_md5 (const void *key, size_t keylen,
|
||||
const void *buffer, size_t buflen, void *resbuf);
|
||||
|
||||
/* Compute Hashed Message Authentication Code with SHA-1, over BUFFER
|
||||
@@ -35,7 +35,7 @@ hmac_md5 (const void *key, size_t keylen,
|
||||
output to pre-allocated 20 byte minimum RESBUF buffer. Return 0 on
|
||||
success. */
|
||||
int
|
||||
hmac_sha1 (const void *key, size_t keylen,
|
||||
MHD_hmac_sha1 (const void *key, size_t keylen,
|
||||
const void *in, size_t inlen, void *resbuf);
|
||||
|
||||
#endif /* HMAC_H */
|
||||
+29
-29
@@ -40,13 +40,13 @@
|
||||
# endif
|
||||
/* We need to keep the namespace clean so define the MD5 function
|
||||
protected using leading __ . */
|
||||
# define md5_init_ctx __md5_init_ctx
|
||||
# define md5_process_block __md5_process_block
|
||||
# define md5_process_bytes __md5_process_bytes
|
||||
# define md5_finish_ctx __md5_finish_ctx
|
||||
# define md5_read_ctx __md5_read_ctx
|
||||
# define md5_stream __md5_stream
|
||||
# define md5_buffer __md5_buffer
|
||||
# define MHD_md5_init_ctx __MHD_md5_init_ctx
|
||||
# define MHD_md5_process_block __MHD_md5_process_block
|
||||
# define MHD_md5_process_bytes __MHD_md5_process_bytes
|
||||
# define MHD_md5_finish_ctx __MHD_md5_finish_ctx
|
||||
# define MHD_md5_read_ctx __MHD_md5_read_ctx
|
||||
# define MHD_md5_stream __MHD_md5_stream
|
||||
# define MHD_md5_buffer __MHD_md5_buffer
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
@@ -69,7 +69,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
|
||||
/* Initialize structure containing state of computation.
|
||||
(RFC 1321, 3.3: Step 3) */
|
||||
void
|
||||
md5_init_ctx (struct md5_ctx *ctx)
|
||||
MHD_md5_init_ctx (struct MHD_md5_ctx *ctx)
|
||||
{
|
||||
ctx->A = 0x67452301;
|
||||
ctx->B = 0xefcdab89;
|
||||
@@ -86,7 +86,7 @@ md5_init_ctx (struct md5_ctx *ctx)
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32-bit value. */
|
||||
void *
|
||||
md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
|
||||
MHD_md5_read_ctx (const struct MHD_md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
((uint32_t *) resbuf)[0] = SWAP (ctx->A);
|
||||
((uint32_t *) resbuf)[1] = SWAP (ctx->B);
|
||||
@@ -102,7 +102,7 @@ md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32-bit value. */
|
||||
void *
|
||||
md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
|
||||
MHD_md5_finish_ctx (struct MHD_md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
/* Take yet unprocessed bytes into account. */
|
||||
uint32_t bytes = ctx->buflen;
|
||||
@@ -120,23 +120,23 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
|
||||
memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
|
||||
|
||||
/* Process last bytes. */
|
||||
md5_process_block (ctx->buffer, size * 4, ctx);
|
||||
MHD_md5_process_block (ctx->buffer, size * 4, ctx);
|
||||
|
||||
return md5_read_ctx (ctx, resbuf);
|
||||
return MHD_md5_read_ctx (ctx, resbuf);
|
||||
}
|
||||
|
||||
/* Compute MD5 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 16 bytes
|
||||
beginning at RESBLOCK. */
|
||||
int
|
||||
md5_stream (FILE * stream, void *resblock)
|
||||
MHD_md5_stream (FILE * stream, void *resblock)
|
||||
{
|
||||
struct md5_ctx ctx;
|
||||
struct MHD_md5_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
md5_init_ctx (&ctx);
|
||||
MHD_md5_init_ctx (&ctx);
|
||||
|
||||
/* Iterate over full file contents. */
|
||||
while (1)
|
||||
@@ -177,17 +177,17 @@ md5_stream (FILE * stream, void *resblock)
|
||||
/* Process buffer with BLOCKSIZE bytes. Note that
|
||||
BLOCKSIZE % 64 == 0
|
||||
*/
|
||||
md5_process_block (buffer, BLOCKSIZE, &ctx);
|
||||
MHD_md5_process_block (buffer, BLOCKSIZE, &ctx);
|
||||
}
|
||||
|
||||
process_partial_block:
|
||||
|
||||
/* Process any remaining bytes. */
|
||||
if (sum > 0)
|
||||
md5_process_bytes (buffer, sum, &ctx);
|
||||
MHD_md5_process_bytes (buffer, sum, &ctx);
|
||||
|
||||
/* Construct result in desired memory. */
|
||||
md5_finish_ctx (&ctx, resblock);
|
||||
MHD_md5_finish_ctx (&ctx, resblock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -196,23 +196,23 @@ process_partial_block:
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
void *
|
||||
md5_buffer (const char *buffer, size_t len, void *resblock)
|
||||
MHD_md5_buffer (const char *buffer, size_t len, void *resblock)
|
||||
{
|
||||
struct md5_ctx ctx;
|
||||
struct MHD_md5_ctx ctx;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
md5_init_ctx (&ctx);
|
||||
MHD_md5_init_ctx (&ctx);
|
||||
|
||||
/* Process whole buffer but last len % 64 bytes. */
|
||||
md5_process_bytes (buffer, len, &ctx);
|
||||
MHD_md5_process_bytes (buffer, len, &ctx);
|
||||
|
||||
/* Put result in desired memory area. */
|
||||
return md5_finish_ctx (&ctx, resblock);
|
||||
return MHD_md5_finish_ctx (&ctx, resblock);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
MHD_md5_process_bytes (const void *buffer, size_t len, struct MHD_md5_ctx *ctx)
|
||||
{
|
||||
/* When we already have some bits in our internal buffer concatenate
|
||||
both inputs first. */
|
||||
@@ -226,7 +226,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
|
||||
if (ctx->buflen > 64)
|
||||
{
|
||||
md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
MHD_md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
|
||||
ctx->buflen &= 63;
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
@@ -248,14 +248,14 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
if (UNALIGNED_P (buffer))
|
||||
while (len > 64)
|
||||
{
|
||||
md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
|
||||
MHD_md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
|
||||
buffer = (const char *) buffer + 64;
|
||||
len -= 64;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
md5_process_block (buffer, len & ~63, ctx);
|
||||
MHD_md5_process_block (buffer, len & ~63, ctx);
|
||||
buffer = (const char *) buffer + (len & ~63);
|
||||
len &= 63;
|
||||
}
|
||||
@@ -270,7 +270,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
left_over += len;
|
||||
if (left_over >= 64)
|
||||
{
|
||||
md5_process_block (ctx->buffer, 64, ctx);
|
||||
MHD_md5_process_block (ctx->buffer, 64, ctx);
|
||||
left_over -= 64;
|
||||
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
|
||||
}
|
||||
@@ -292,7 +292,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
It is assumed that LEN % 64 == 0. */
|
||||
|
||||
void
|
||||
md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
MHD_md5_process_block (const void *buffer, size_t len, struct MHD_md5_ctx *ctx)
|
||||
{
|
||||
uint32_t correct_words[16];
|
||||
const uint32_t *words = buffer;
|
||||
|
||||
+18
-18
@@ -45,17 +45,17 @@
|
||||
#endif
|
||||
|
||||
#ifndef _LIBC
|
||||
# define __md5_buffer md5_buffer
|
||||
# define __md5_finish_ctx md5_finish_ctx
|
||||
# define __md5_init_ctx md5_init_ctx
|
||||
# define __md5_process_block md5_process_block
|
||||
# define __md5_process_bytes md5_process_bytes
|
||||
# define __md5_read_ctx md5_read_ctx
|
||||
# define __md5_stream md5_stream
|
||||
# define __MHD_md5_buffer MHD_md5_buffer
|
||||
# define __MHD_md5_finish_ctx MHD_md5_finish_ctx
|
||||
# define __MHD_md5_init_ctx MHD_md5_init_ctx
|
||||
# define __MHD_md5_process_block MHD_md5_process_block
|
||||
# define __MHD_md5_process_bytes MHD_md5_process_bytes
|
||||
# define __MHD_md5_read_ctx MHD_md5_read_ctx
|
||||
# define __MHD_md5_stream MHD_md5_stream
|
||||
#endif
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
struct md5_ctx
|
||||
struct MHD_md5_ctx
|
||||
{
|
||||
uint32_t A;
|
||||
uint32_t B;
|
||||
@@ -69,28 +69,28 @@ struct md5_ctx
|
||||
|
||||
/*
|
||||
* The following three functions are build up the low level used in
|
||||
* the functions `md5_stream' and `md5_buffer'.
|
||||
* the functions `MHD_md5_stream' and `MHD_md5_buffer'.
|
||||
*/
|
||||
|
||||
/* Initialize structure containing state of computation.
|
||||
(RFC 1321, 3.3: Step 3) */
|
||||
extern void
|
||||
__md5_init_ctx (struct md5_ctx *ctx)
|
||||
__MHD_md5_init_ctx (struct MHD_md5_ctx *ctx)
|
||||
__THROW;
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is necessary that LEN is a multiple of 64!!! */
|
||||
extern void __md5_process_block (const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx) __THROW;
|
||||
extern void __MHD_md5_process_block (const void *buffer, size_t len,
|
||||
struct MHD_md5_ctx *ctx) __THROW;
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is NOT required that LEN is a multiple of 64. */
|
||||
extern void __md5_process_bytes (const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx) __THROW;
|
||||
extern void __MHD_md5_process_bytes (const void *buffer, size_t len,
|
||||
struct MHD_md5_ctx *ctx) __THROW;
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
in first 16 bytes following RESBUF. The result is always in little
|
||||
@@ -99,7 +99,7 @@ __md5_init_ctx (struct md5_ctx *ctx)
|
||||
|
||||
IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
|
||||
boundary. */
|
||||
extern void *__md5_finish_ctx (struct md5_ctx *ctx,
|
||||
extern void *__MHD_md5_finish_ctx (struct MHD_md5_ctx *ctx,
|
||||
void *resbuf) __THROW;
|
||||
|
||||
|
||||
@@ -109,20 +109,20 @@ __md5_init_ctx (struct md5_ctx *ctx)
|
||||
|
||||
IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
|
||||
boundary. */
|
||||
extern void *__md5_read_ctx (const struct md5_ctx *ctx,
|
||||
extern void *__MHD_md5_read_ctx (const struct MHD_md5_ctx *ctx,
|
||||
void *resbuf) __THROW;
|
||||
|
||||
|
||||
/* Compute MD5 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 16 bytes
|
||||
beginning at RESBLOCK. */
|
||||
extern int __md5_stream (FILE * stream, void *resblock) __THROW;
|
||||
extern int __MHD_md5_stream (FILE * stream, void *resblock) __THROW;
|
||||
|
||||
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
extern void *__md5_buffer (const char *buffer, size_t len,
|
||||
extern void *__MHD_md5_buffer (const char *buffer, size_t len,
|
||||
void *resblock) __THROW;
|
||||
|
||||
#endif /* md5.h */
|
||||
@@ -26,11 +26,11 @@
|
||||
# define __builtin_expect(expr, val) (expr)
|
||||
#endif
|
||||
|
||||
#undef memmem
|
||||
#undef MHD_memmem
|
||||
|
||||
/* Return the first occurrence of NEEDLE in HAYSTACK. */
|
||||
void *
|
||||
memmem (haystack, haystack_len, needle, needle_len)
|
||||
MHD_memmem (haystack, haystack_len, needle, needle_len)
|
||||
const void *haystack;
|
||||
size_t haystack_len;
|
||||
const void *needle;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* memxor.c -- perform binary exclusive OR operation of two memory blocks.
|
||||
/* MHD_memxor.c -- perform binary exclusive OR operation of two memory blocks.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -15,7 +15,7 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Written by Simon Josefsson. The interface was inspired by memxor
|
||||
/* Written by Simon Josefsson. The interface was inspired by MHD_memxor
|
||||
in Niels Möller's Nettle. */
|
||||
|
||||
#include "MHD_config.h"
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "memxor.h"
|
||||
|
||||
void *
|
||||
memxor (void *restrict dest, const void *restrict src, size_t n)
|
||||
MHD_memxor (void *restrict dest, const void *restrict src, size_t n)
|
||||
{
|
||||
char const *s = src;
|
||||
char *d = dest;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* memxor.h -- perform binary exclusive OR operation on memory blocks.
|
||||
/* MHD_memxor.h -- perform binary exclusive OR operation on memory blocks.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -15,7 +15,7 @@
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Written by Simon Josefsson. The interface was inspired by memxor
|
||||
/* Written by Simon Josefsson. The interface was inspired by MHD_memxor
|
||||
in Niels Möller's Nettle. */
|
||||
|
||||
#ifndef MEMXOR_H
|
||||
@@ -26,6 +26,6 @@
|
||||
/* Compute binary exclusive OR of memory areas DEST and SRC, putting
|
||||
the result in DEST, of length N bytes. Returns a pointer to
|
||||
DEST. */
|
||||
void *memxor (void *restrict dest, const void *restrict src, size_t n);
|
||||
void *MHD_memxor (void *restrict dest, const void *restrict src, size_t n);
|
||||
|
||||
#endif /* MEMXOR_H */
|
||||
+23
-23
@@ -53,9 +53,9 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
|
||||
|
||||
/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
|
||||
initialize it to the start constants of the SHA1 algorithm. This
|
||||
must be called before using hash in the call to sha1_hash. */
|
||||
must be called before using hash in the call to MHD_sha1_hash. */
|
||||
void
|
||||
sha1_init_ctx (struct sha1_ctx *ctx)
|
||||
MHD_sha1_init_ctx (struct MHD_sha1_ctx *ctx)
|
||||
{
|
||||
ctx->A = 0x67452301;
|
||||
ctx->B = 0xefcdab89;
|
||||
@@ -73,7 +73,7 @@ sha1_init_ctx (struct sha1_ctx *ctx)
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32-bit value. */
|
||||
void *
|
||||
sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
|
||||
MHD_sha1_read_ctx (const struct MHD_sha1_ctx *ctx, void *resbuf)
|
||||
{
|
||||
((uint32_t *) resbuf)[0] = SWAP (ctx->A);
|
||||
((uint32_t *) resbuf)[1] = SWAP (ctx->B);
|
||||
@@ -90,7 +90,7 @@ sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32-bit value. */
|
||||
void *
|
||||
sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
|
||||
MHD_sha1_finish_ctx (struct MHD_sha1_ctx *ctx, void *resbuf)
|
||||
{
|
||||
/* Take yet unprocessed bytes into account. */
|
||||
uint32_t bytes = ctx->buflen;
|
||||
@@ -108,23 +108,23 @@ sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
|
||||
memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
|
||||
|
||||
/* Process last bytes. */
|
||||
sha1_process_block (ctx->buffer, size * 4, ctx);
|
||||
MHD_sha1_process_block (ctx->buffer, size * 4, ctx);
|
||||
|
||||
return sha1_read_ctx (ctx, resbuf);
|
||||
return MHD_sha1_read_ctx (ctx, resbuf);
|
||||
}
|
||||
|
||||
/* Compute SHA1 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 16 bytes
|
||||
beginning at RESBLOCK. */
|
||||
int
|
||||
sha1_stream (FILE * stream, void *resblock)
|
||||
MHD_sha1_stream (FILE * stream, void *resblock)
|
||||
{
|
||||
struct sha1_ctx ctx;
|
||||
struct MHD_sha1_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha1_init_ctx (&ctx);
|
||||
MHD_sha1_init_ctx (&ctx);
|
||||
|
||||
/* Iterate over full file contents. */
|
||||
while (1)
|
||||
@@ -165,17 +165,17 @@ sha1_stream (FILE * stream, void *resblock)
|
||||
/* Process buffer with BLOCKSIZE bytes. Note that
|
||||
BLOCKSIZE % 64 == 0
|
||||
*/
|
||||
sha1_process_block (buffer, BLOCKSIZE, &ctx);
|
||||
MHD_sha1_process_block (buffer, BLOCKSIZE, &ctx);
|
||||
}
|
||||
|
||||
process_partial_block:;
|
||||
|
||||
/* Process any remaining bytes. */
|
||||
if (sum > 0)
|
||||
sha1_process_bytes (buffer, sum, &ctx);
|
||||
MHD_sha1_process_bytes (buffer, sum, &ctx);
|
||||
|
||||
/* Construct result in desired memory. */
|
||||
sha1_finish_ctx (&ctx, resblock);
|
||||
MHD_sha1_finish_ctx (&ctx, resblock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -184,22 +184,22 @@ process_partial_block:;
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
void *
|
||||
sha1_buffer (const char *buffer, size_t len, void *resblock)
|
||||
MHD_sha1_buffer (const char *buffer, size_t len, void *resblock)
|
||||
{
|
||||
struct sha1_ctx ctx;
|
||||
struct MHD_sha1_ctx ctx;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
sha1_init_ctx (&ctx);
|
||||
MHD_sha1_init_ctx (&ctx);
|
||||
|
||||
/* Process whole buffer but last len % 64 bytes. */
|
||||
sha1_process_bytes (buffer, len, &ctx);
|
||||
MHD_sha1_process_bytes (buffer, len, &ctx);
|
||||
|
||||
/* Put result in desired memory area. */
|
||||
return sha1_finish_ctx (&ctx, resblock);
|
||||
return MHD_sha1_finish_ctx (&ctx, resblock);
|
||||
}
|
||||
|
||||
void
|
||||
sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
||||
MHD_sha1_process_bytes (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx)
|
||||
{
|
||||
/* When we already have some bits in our internal buffer concatenate
|
||||
both inputs first. */
|
||||
@@ -213,7 +213,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
||||
|
||||
if (ctx->buflen > 64)
|
||||
{
|
||||
sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
MHD_sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
|
||||
ctx->buflen &= 63;
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
@@ -235,14 +235,14 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
||||
if (UNALIGNED_P (buffer))
|
||||
while (len > 64)
|
||||
{
|
||||
sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
|
||||
MHD_sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
|
||||
buffer = (const char *) buffer + 64;
|
||||
len -= 64;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sha1_process_block (buffer, len & ~63, ctx);
|
||||
MHD_sha1_process_block (buffer, len & ~63, ctx);
|
||||
buffer = (const char *) buffer + (len & ~63);
|
||||
len &= 63;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
||||
left_over += len;
|
||||
if (left_over >= 64)
|
||||
{
|
||||
sha1_process_block (ctx->buffer, 64, ctx);
|
||||
MHD_sha1_process_block (ctx->buffer, 64, ctx);
|
||||
left_over -= 64;
|
||||
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
|
||||
}
|
||||
@@ -284,7 +284,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
||||
Most of this code comes from GnuPG's cipher/sha1.c. */
|
||||
|
||||
void
|
||||
sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
||||
MHD_sha1_process_block (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx)
|
||||
{
|
||||
const uint32_t *words = buffer;
|
||||
size_t nwords = len / sizeof (uint32_t);
|
||||
|
||||
+10
-10
@@ -23,7 +23,7 @@
|
||||
# include <stdint.h>
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
struct sha1_ctx
|
||||
struct MHD_sha1_ctx
|
||||
{
|
||||
uint32_t A;
|
||||
uint32_t B;
|
||||
@@ -38,21 +38,21 @@ struct sha1_ctx
|
||||
|
||||
|
||||
/* Initialize structure containing state of computation. */
|
||||
extern void sha1_init_ctx (struct sha1_ctx *ctx);
|
||||
extern void MHD_sha1_init_ctx (struct MHD_sha1_ctx *ctx);
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is necessary that LEN is a multiple of 64!!! */
|
||||
extern void sha1_process_block (const void *buffer, size_t len,
|
||||
struct sha1_ctx *ctx);
|
||||
extern void MHD_sha1_process_block (const void *buffer, size_t len,
|
||||
struct MHD_sha1_ctx *ctx);
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is NOT required that LEN is a multiple of 64. */
|
||||
extern void sha1_process_bytes (const void *buffer, size_t len,
|
||||
struct sha1_ctx *ctx);
|
||||
extern void MHD_sha1_process_bytes (const void *buffer, size_t len,
|
||||
struct MHD_sha1_ctx *ctx);
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
in first 20 bytes following RESBUF. The result is always in little
|
||||
@@ -61,7 +61,7 @@ extern void sha1_process_bytes (const void *buffer, size_t len,
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF be correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
|
||||
extern void *MHD_sha1_finish_ctx (struct MHD_sha1_ctx *ctx, void *resbuf);
|
||||
|
||||
|
||||
/* Put result from CTX in first 20 bytes following RESBUF. The result is
|
||||
@@ -70,18 +70,18 @@ extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
|
||||
extern void *MHD_sha1_read_ctx (const struct MHD_sha1_ctx *ctx, void *resbuf);
|
||||
|
||||
|
||||
/* Compute SHA1 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 20 bytes
|
||||
beginning at RESBLOCK. */
|
||||
extern int sha1_stream (FILE * stream, void *resblock);
|
||||
extern int MHD_sha1_stream (FILE * stream, void *resblock);
|
||||
|
||||
/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
|
||||
extern void *MHD_sha1_buffer (const char *buffer, size_t len, void *resblock);
|
||||
|
||||
#endif
|
||||
@@ -1,46 +0,0 @@
|
||||
/* Reentrant time functions like localtime_r.
|
||||
|
||||
Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#include "MHD_config.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static struct tm *
|
||||
copy_tm_result (struct tm *dest, struct tm const *src)
|
||||
{
|
||||
if (!src)
|
||||
return 0;
|
||||
*dest = *src;
|
||||
return dest;
|
||||
}
|
||||
|
||||
struct tm *
|
||||
gmtime_r (time_t const *restrict t, struct tm *restrict tp)
|
||||
{
|
||||
return copy_tm_result (tp, gmtime (t));
|
||||
}
|
||||
|
||||
struct tm *
|
||||
localtime_r (time_t const *restrict t, struct tm *restrict tp)
|
||||
{
|
||||
return copy_tm_result (tp, localtime (t));
|
||||
}
|
||||
Reference in new issue
Block a user