diff options
Diffstat (limited to 'cipher/md.c')
-rw-r--r-- | cipher/md.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/cipher/md.c b/cipher/md.c index e8ac8ac24..29d6afed8 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -557,10 +557,7 @@ gcry_md_ctl( GCRY_MD_HD hd, int cmd, byte *buffer, size_t buflen) if( cmd == GCRYCTL_FINALIZE ) md_final( hd ); else if( cmd == GCRYCTL_SET_KEY ) { - if( !(hd->ctx->macpads ) ) - rc = GCRYERR_CONFLICT; - else if ( !(rc = prepare_macpads( hd, buffer, buflen )) ) - gcry_md_reset( hd ); + rc = gcry_md_setkey ( hd, buffer, buflen ); } else if( cmd == GCRYCTL_START_DUMP ) { md_start_debug( hd, buffer ); @@ -574,6 +571,20 @@ gcry_md_ctl( GCRY_MD_HD hd, int cmd, byte *buffer, size_t buflen) } +int +gcry_md_setkey( GCRY_MD_HD hd, const char *key, size_t keylen ) +{ + int rc = 0; + + if( !(hd->ctx->macpads ) ) + rc = GCRYERR_CONFLICT; + else if ( !(rc = prepare_macpads( hd, key, keylen )) ) + gcry_md_reset( hd ); + + return rc; +} + + /**************** * if ALGO is null get the digest for the used algo (which should be only one) */ |