diff options
Diffstat (limited to 'cipher')
-rw-r--r-- | cipher/ChangeLog | 4 | ||||
-rw-r--r-- | cipher/md.c | 13 |
2 files changed, 14 insertions, 3 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog index c0657d727..a81189702 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,7 @@ +Mon Mar 13 19:22:46 CET 2000 Werner Koch <[email protected]> + + * md.c (gcry_md_hash_buffer): Add support for the other algorithms. + Mon Jan 31 16:37:34 CET 2000 Werner Koch <[email protected]> * genprime.c (generate_elg_prime): Fixed returned factors which never diff --git a/cipher/md.c b/cipher/md.c index bc0a6c30d..680558db2 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -596,15 +596,22 @@ gcry_md_get( GCRY_MD_HD hd, int algo, byte *buffer, int buflen ) * Shortcut function to hash a buffer with a given algo. The only supported * algorithm is RIPE-MD. The supplied digest buffer must be large enough * to store the resulting hash. No error is returned, the function will - * abort on an invalite algo. DISABLED_ALGOS are ignored here. + * abort on an invalid algo. DISABLED_ALGOS are ignored here. */ void gcry_md_hash_buffer( int algo, char *digest, const char *buffer, size_t length) { if( algo == GCRY_MD_RMD160 ) rmd160_hash_buffer( digest, buffer, length ); - else - BUG(); + else { /* for the others we do not have a fast function, so + * we use the normal functions to do it */ + GCRY_MD_HD h = md_open( algo, 0 ); + if( !h ) + BUG(); /* algo not available */ + md_write( h, (byte*)buffer, length ); + md_final( h ); + memcpy( digest, md_read( h, algo ), md_digest_length( algo ) ); + } } static int |