mirror of
https://github.com/cryb-to/cryb-to.git
synced 2024-11-14 09:45:40 +00:00
Fix various bugs relating to digest algorithm registration and wrapping
This commit is contained in:
parent
8d087eeb64
commit
398abda6b0
7 changed files with 15 additions and 14 deletions
|
@ -66,6 +66,6 @@ const digest_algorithm *get_digest_algorithm(const char *);
|
|||
#define digest_final(alg, ctx, md) \
|
||||
(alg)->final((ctx), (md))
|
||||
#define digest_complete(alg, buf, len, md) \
|
||||
(alg)->update((buf), (len), (md))
|
||||
(alg)->complete((buf), (len), (md))
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#define md2_final cryb_md2_final
|
||||
#define md2_complete cryb_md2_complete
|
||||
|
||||
extern digest_algorithm md2_algorithm;
|
||||
extern digest_algorithm md2_digest;
|
||||
|
||||
/**
|
||||
* \brief MD2 context structure
|
||||
|
|
|
@ -52,8 +52,6 @@ typedef struct {
|
|||
uint64_t bitlen;
|
||||
} sha1_ctx;
|
||||
|
||||
extern digest_algorithm sha1_algorithm;
|
||||
|
||||
void sha1_init(sha1_ctx *);
|
||||
void sha1_update(sha1_ctx *, const void *, size_t);
|
||||
void sha1_final(sha1_ctx *, uint8_t *);
|
||||
|
|
|
@ -3,6 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
|||
lib_LTLIBRARIES = libcryb-digest.la
|
||||
|
||||
libcryb_digest_la_SOURCES = \
|
||||
digest.c \
|
||||
md2.c \
|
||||
md4.c \
|
||||
md5.c \
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
|
||||
#include "cryb/impl.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cryb/digest.h>
|
||||
#include <cryb/md2.h>
|
||||
#include <cryb/md4.h>
|
||||
#include <cryb/md5.h>
|
||||
|
@ -46,13 +48,13 @@ static void
|
|||
init_digest_algorithms(void)
|
||||
{
|
||||
static const digest_algorithm *algorithms[] = {
|
||||
&md2_algorithm,
|
||||
&md4_algorithm,
|
||||
&md5_algorithm,
|
||||
&sha1_algorithm,
|
||||
&sha256_algorithm,
|
||||
&sha384_algorithm,
|
||||
&sha512_algorithm,
|
||||
&md2_digest,
|
||||
&md4_digest,
|
||||
&md5_digest,
|
||||
&sha1_digest,
|
||||
&sha256_digest,
|
||||
&sha384_digest,
|
||||
&sha512_digest,
|
||||
NULL
|
||||
};
|
||||
cryb_digest_algorithms = algorithms;
|
||||
|
@ -64,7 +66,7 @@ get_digest_algorithm(const char *name)
|
|||
const digest_algorithm **algp;
|
||||
|
||||
if (cryb_digest_algorithms == NULL)
|
||||
cryb_init_digest_algorithms();
|
||||
init_digest_algorithms();
|
||||
for (algp = cryb_digest_algorithms; *algp != NULL; ++algp)
|
||||
if (strcasecmp((*algp)->name, name) == 0)
|
||||
return (*algp);
|
||||
|
|
|
@ -175,7 +175,7 @@ void md2_complete( const void *input, int ilen, uint8_t *output )
|
|||
memset( &ctx, 0, sizeof( md2_ctx ) );
|
||||
}
|
||||
|
||||
digest_algorithm md2_algorithm = {
|
||||
digest_algorithm md2_digest = {
|
||||
.name = "md2",
|
||||
.contextlen = sizeof(md2_ctx),
|
||||
.blocklen = MD2_BLOCK_LEN,
|
||||
|
|
|
@ -250,7 +250,7 @@ void md4_complete( const void *input, int ilen, uint8_t *output )
|
|||
memset( &ctx, 0, sizeof( md4_ctx ) );
|
||||
}
|
||||
|
||||
digest_algorithm md4_algorithm = {
|
||||
digest_algorithm md4_digest = {
|
||||
.name = "md4",
|
||||
.contextlen = sizeof(md4_ctx),
|
||||
.blocklen = MD4_BLOCK_LEN,
|
||||
|
|
Loading…
Reference in a new issue