Skip to content

Commit

Permalink
Add SHA3 hash algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
chris2511 committed Oct 5, 2024
1 parent e035241 commit e4c9d9f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Add SHA3 algorithms to th select box
* Close #593: App freezes/crashes when trying to export certain keys
* Close #306 #537: Allow Database-driver options in config file
* Close #537: macos: Compile mariadb-connector and qsqlmysql
Expand Down
5 changes: 4 additions & 1 deletion lib/digest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

const QList<int> digest::all_digests(
{ NID_md5, NID_ripemd160, NID_sha1,
NID_sha224, NID_sha256, NID_sha384, NID_sha512
NID_sha224, NID_sha256, NID_sha384, NID_sha512,
#ifndef LIBRESSL_VERSION_NUMBER
NID_sha3_224, NID_sha3_256, NID_sha3_384, NID_sha3_512,
#endif
});

int digest::default_md(NID_sha256);
Expand Down
2 changes: 2 additions & 0 deletions lib/pki_evp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,8 @@ void pki_evp::writeSSH2private(XFile &file) const
} else
#endif
writeKey(file, nullptr, nullptr, true);

EVP_PKEY_free(pkey);
}

bool pki_evp::verify(EVP_PKEY *pkey) const
Expand Down
16 changes: 11 additions & 5 deletions lib/pki_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,25 @@ QByteArray pki_key::ed25519PrivKey(const EVP_PKEY *) const
QList<int> pki_key::possibleHashNids()
{
QList<int> nids;
QList<int> allSha2 = { NID_sha224, NID_sha256, NID_sha384, NID_sha512 };
#ifndef LIBRESSL_VERSION_NUMBER
QList<int> allSha3 = { NID_sha3_224, NID_sha3_256, NID_sha3_384, NID_sha3_512 };
#else
QList<int> allSha3;
#endif

switch (EVP_PKEY_type(getKeyType())) {
case EVP_PKEY_RSA:
nids << NID_md5 << NID_ripemd160 << NID_sha1 << NID_sha224 << NID_sha256 <<
NID_sha384 << NID_sha512;
nids << NID_md5 << NID_ripemd160 << NID_sha1;
nids += allSha2 + allSha3;
break;
case EVP_PKEY_DSA:
nids << NID_sha1 << NID_sha256;
nids << NID_sha1 << NID_sha224 << NID_sha256;
break;
#ifndef OPENSSL_NO_EC
case EVP_PKEY_EC:
nids << NID_sha1 << NID_sha224 << NID_sha256 <<
NID_sha384 << NID_sha512;
nids << NID_sha1;
nids += allSha2 + allSha3;
break;
#ifdef EVP_PKEY_ED25519
case EVP_PKEY_ED25519:
Expand Down

0 comments on commit e4c9d9f

Please sign in to comment.