diff options
author | Werner Koch <[email protected]> | 2000-03-13 18:19:12 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2000-03-13 18:19:12 +0000 |
commit | 14a2e006bcd829671191c127d7ad3288995db8f9 (patch) | |
tree | ca819fd1b70778754f9ef438a62269e28896a7e6 /cipher/md.c | |
parent | See ChangeLog: Mon Feb 21 22:43:01 CET 2000 Werner Koch (diff) | |
download | gnupg-14a2e006bcd829671191c127d7ad3288995db8f9.tar.gz gnupg-14a2e006bcd829671191c127d7ad3288995db8f9.zip |
See ChangeLog: Mon Mar 13 19:22:46 CET 2000 Werner Koch
Diffstat (limited to 'cipher/md.c')
-rw-r--r-- | cipher/md.c | 13 |
1 files changed, 10 insertions, 3 deletions
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 |