mirror of
git://git.gnupg.org/gnupg.git
synced 2024-09-24 15:31:41 +02:00
Add convenience function to hash a buffer.
* cipher/sha1.c (sha1_hash_buffer): New. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
d2323ce6fd
commit
2e7a3ed390
@ -52,7 +52,7 @@ static void
|
|||||||
burn_stack (int bytes)
|
burn_stack (int bytes)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
wipememory(buf,sizeof buf);
|
wipememory(buf,sizeof buf);
|
||||||
bytes -= sizeof buf;
|
bytes -= sizeof buf;
|
||||||
if (bytes > 0)
|
if (bytes > 0)
|
||||||
@ -323,6 +323,23 @@ sha1_read( SHA1_CONTEXT *hd )
|
|||||||
return hd->buf;
|
return hd->buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************
|
||||||
|
* Shortcut functions which puts the hash value of the supplied buffer
|
||||||
|
* into outbuf which must have a size of 20 bytes.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
sha1_hash_buffer (char *outbuf, const char *buffer, size_t length)
|
||||||
|
{
|
||||||
|
SHA1_CONTEXT hd;
|
||||||
|
|
||||||
|
sha1_init (&hd);
|
||||||
|
sha1_write (&hd, (byte*)buffer, length);
|
||||||
|
sha1_final (&hd);
|
||||||
|
memcpy (outbuf, hd.buf, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
* Return some information about the algorithm. We need algo here to
|
* Return some information about the algorithm. We need algo here to
|
||||||
* distinguish different flavors of the algorithm.
|
* distinguish different flavors of the algorithm.
|
||||||
|
@ -157,6 +157,7 @@ void md_stop_debug( MD_HANDLE a );
|
|||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
void rmd160_hash_buffer (char *outbuf, const char *buffer, size_t length);
|
void rmd160_hash_buffer (char *outbuf, const char *buffer, size_t length);
|
||||||
|
void sha1_hash_buffer (char *outbuf, const char *buffer, size_t length);
|
||||||
|
|
||||||
|
|
||||||
/*-- cipher.c --*/
|
/*-- cipher.c --*/
|
||||||
|
Loading…
Reference in New Issue
Block a user