mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Access all hashes and MACs through the standard API.
All the hash-specific state structures, and the functions that directly accessed them, are now local to the source files implementing the hashes themselves. Everywhere we previously used those types or functions, we're now using the standard ssh_hash or ssh2_mac API. The 'simple' functions (hmacmd5_simple, SHA_Simple etc) are now a pair of wrappers in sshauxcrypt.c, each of which takes an algorithm structure and can do the same conceptual thing regardless of what it is.
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* sshauxcrypt.c: wrapper functions on ciphers for use in other
|
||||
* contexts than the main SSH packet protocol, such as encrypting
|
||||
* private key files and performing XDM-AUTHORIZATION-1.
|
||||
* sshauxcrypt.c: wrapper functions on crypto primitives for use in
|
||||
* other contexts than the main SSH packet protocol, such as
|
||||
* encrypting private key files and performing XDM-AUTHORIZATION-1.
|
||||
*
|
||||
* These all work through the standard cipher APIs, so they don't need
|
||||
* to live in the same actual source files as the ciphers they wrap,
|
||||
* and I think it keeps things tidier to have them out of the way here
|
||||
* instead.
|
||||
* These all work through the standard cipher/hash/MAC APIs, so they
|
||||
* don't need to live in the same actual source files as the ciphers
|
||||
* they wrap, and I think it keeps things tidier to have them out of
|
||||
* the way here instead.
|
||||
*/
|
||||
|
||||
#include "ssh.h"
|
||||
@ -150,3 +150,19 @@ void des_decrypt_xdmauth(const void *keydata, void *blk, int len)
|
||||
ssh_cipher_free(c);
|
||||
}
|
||||
|
||||
void hash_simple(const ssh_hashalg *alg, ptrlen data, void *output)
|
||||
{
|
||||
ssh_hash *hash = ssh_hash_new(alg);
|
||||
put_datapl(hash, data);
|
||||
ssh_hash_final(hash, output);
|
||||
}
|
||||
|
||||
void mac_simple(const ssh2_macalg *alg, ptrlen key, ptrlen data, void *output)
|
||||
{
|
||||
ssh2_mac *mac = ssh2_mac_new(alg, NULL);
|
||||
ssh2_mac_setkey(mac, key);
|
||||
ssh2_mac_start(mac);
|
||||
put_datapl(mac, data);
|
||||
ssh2_mac_genresult(mac, output);
|
||||
ssh2_mac_free(mac);
|
||||
}
|
||||
|
Reference in New Issue
Block a user