mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-12-02 17:24:39 +00:00
correcting usage of rsa_exception in ecdsa alg
This commit is contained in:
@@ -337,16 +337,16 @@ namespace jwt {
|
||||
if (!private_key.empty()) {
|
||||
std::unique_ptr<BIO, decltype(&BIO_free_all)> privkey_bio(BIO_new(BIO_s_mem()), BIO_free_all);
|
||||
if ((size_t)BIO_write(privkey_bio.get(), private_key.data(), private_key.size()) != private_key.size())
|
||||
throw rsa_exception("failed to load private key: bio_write failed");
|
||||
throw ecdsa_exception("failed to load private key: bio_write failed");
|
||||
pkey.reset(PEM_read_bio_ECPrivateKey(privkey_bio.get(), nullptr, nullptr, const_cast<char*>(private_key_password.c_str())), EC_KEY_free);
|
||||
if (!pkey)
|
||||
throw rsa_exception("failed to load private key: PEM_read_bio_ECPrivateKey failed");
|
||||
throw ecdsa_exception("failed to load private key: PEM_read_bio_ECPrivateKey failed");
|
||||
size_t keysize = EC_GROUP_get_degree(EC_KEY_get0_group(pkey.get()));
|
||||
if(keysize != signature_length*4 && (signature_length != 132 || keysize != 521))
|
||||
throw ecdsa_exception("invalid key size");
|
||||
}
|
||||
if(!pkey)
|
||||
throw rsa_exception("at least one of public or private key need to be present");
|
||||
throw ecdsa_exception("at least one of public or private key need to be present");
|
||||
|
||||
if(EC_KEY_check_key(pkey.get()) == 0)
|
||||
throw ecdsa_exception("failed to load key: key is invalid");
|
||||
|
||||
Reference in New Issue
Block a user