Skip to content

Commit 9b222be

Browse files
committed
Support passing ssl library key handles to algorithms
1 parent 71c3d36 commit 9b222be

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/jwt-cpp/jwt.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,18 @@ namespace jwt {
15701570
throw error::ecdsa_exception(error::ecdsa_error::invalid_key_size);
15711571
}
15721572

1573+
ecdsa(helper::evp_pkey_handle private_key, const EVP_MD* (*md)(), std::string name, size_t siglen)
1574+
: pkey(std::move(private_key)), md(md), alg_name(std::move(name)), signature_length(siglen) {
1575+
if (pkey) {
1576+
check_private_key(pkey.get());
1577+
} else {
1578+
throw error::ecdsa_exception(error::ecdsa_error::no_key_provided);
1579+
}
1580+
size_t keysize = EVP_PKEY_bits(pkey.get());
1581+
if (keysize != signature_length * 4 && (signature_length != 132 || keysize != 521))
1582+
throw error::ecdsa_exception(error::ecdsa_error::invalid_key_size);
1583+
}
1584+
15731585
/**
15741586
* Sign jwt data
15751587
* \param data The data to sign

0 commit comments

Comments
 (0)