Skip to content

Commit

Permalink
Fix CDoc 1 OID usage (open-eid#1242)
Browse files Browse the repository at this point in the history
IB-7935

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Jan 24, 2024
1 parent 79f720d commit 21231cd
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions client/Crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <QtNetwork/QSslKey>

#include <openssl/aes.h>
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
#include <openssl/core_names.h>
#endif
#include <openssl/ec.h>
#include <openssl/err.h>
#include <openssl/evp.h>
Expand Down Expand Up @@ -163,9 +166,24 @@ QByteArray Crypto::concatKDF(QCryptographicHash::Algorithm hashAlg, quint32 keyD

QByteArray Crypto::curve_oid(EVP_PKEY *key)
{
ASN1_OBJECT *obj = OBJ_nid2obj(EC_GROUP_get_curve_name(EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(key))));
QByteArray buf(50, 0);
buf.resize(int(OBJ_obj2txt(buf.data(), buf.size(), obj, 0)));
#if OPENSSL_VERSION_NUMBER < 0x30000000L
int nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(key)));
#else
std::array<char, 64> group{};
size_t size = group.size();
if(EVP_PKEY_get_utf8_string_param(key, OSSL_PKEY_PARAM_GROUP_NAME, group.data(), group.size(), &size) != 1)
{
buf.clear();
return buf;
}
int nid = OBJ_sn2nid(group.data());
#endif
ASN1_OBJECT *obj = OBJ_nid2obj(nid);
if(int size = OBJ_obj2txt(buf.data(), buf.size(), obj, 1); size != NID_undef)
buf.resize(size);
else
buf.clear();
return buf;
}

Expand Down

0 comments on commit 21231cd

Please sign in to comment.