mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-05 21:42:47 -05:00
Rewrite the SHA-256 and SHA-1 hash function modules.
The new structure of those modules is along similar lines to the recent rewrite of AES, with selection of HW vs SW implementation being done by the main vtable instead of a subsidiary function pointer within it, freedom for each implementation to define its state structure however is most convenient, and space to drop in other hardware-accelerated implementations. I've removed the centralised test for compiler SHA-NI support in ssh.h, and instead duplicated it between the two SHA modules, on the grounds that once you start considering an open-ended set of hardware accelerators, the two hashes _need_ not go together. I've also added an extra test in cryptsuite that checks the point at which the end-of-hash padding switches to adding an extra cipher block. That was just because I was rewriting that padding code, was briefly worried that I might have got an off-by-one error in that part of it, and couldn't see any existing test that gave me confidence I hadn't.
This commit is contained in:
29
ssh.h
29
ssh.h
@ -558,8 +558,6 @@ struct ssh_cipher {
|
||||
const ssh_cipheralg *vt;
|
||||
};
|
||||
|
||||
bool supports_sha_ni(void);
|
||||
|
||||
struct ssh_cipheralg {
|
||||
ssh_cipher *(*new)(const ssh_cipheralg *alg);
|
||||
void (*free)(ssh_cipher *);
|
||||
@ -819,7 +817,11 @@ extern const ssh2_ciphers ssh2_arcfour;
|
||||
extern const ssh2_ciphers ssh2_ccp;
|
||||
extern const ssh_hashalg ssh_md5;
|
||||
extern const ssh_hashalg ssh_sha1;
|
||||
extern const ssh_hashalg ssh_sha1_hw;
|
||||
extern const ssh_hashalg ssh_sha1_sw;
|
||||
extern const ssh_hashalg ssh_sha256;
|
||||
extern const ssh_hashalg ssh_sha256_hw;
|
||||
extern const ssh_hashalg ssh_sha256_sw;
|
||||
extern const ssh_hashalg ssh_sha384;
|
||||
extern const ssh_hashalg ssh_sha512;
|
||||
extern const ssh_kexes ssh_diffiehellman_group1;
|
||||
@ -867,29 +869,6 @@ extern const char sshver[];
|
||||
*/
|
||||
extern bool ssh_fallback_cmd(Backend *backend);
|
||||
|
||||
/*
|
||||
* Check of compiler version
|
||||
*/
|
||||
#ifdef _FORCE_SHA_NI
|
||||
# define COMPILER_SUPPORTS_SHA_NI
|
||||
#elif defined(__clang__)
|
||||
# if __has_attribute(target) && __has_include(<shaintrin.h>) && (defined(__x86_64__) || defined(__i386))
|
||||
# define COMPILER_SUPPORTS_SHA_NI
|
||||
# endif
|
||||
#elif defined(__GNUC__)
|
||||
# if ((__GNUC__ >= 5) && (defined(__x86_64__) || defined(__i386)))
|
||||
# define COMPILER_SUPPORTS_SHA_NI
|
||||
# endif
|
||||
#elif defined (_MSC_VER)
|
||||
# if (defined(_M_X64) || defined(_M_IX86)) && _MSC_VER >= 1900
|
||||
# define COMPILER_SUPPORTS_SHA_NI
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _FORCE_SOFTWARE_SHA
|
||||
# undef COMPILER_SUPPORTS_SHA_NI
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The PRNG type, defined in sshprng.c. Visible data fields are
|
||||
* 'savesize', which suggests how many random bytes you should request
|
||||
|
Reference in New Issue
Block a user