mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 10:06:03 +00:00
LibCrypto: Implement RSA_PSS_EMSA
with OpenSSL
This commit is contained in:
parent
cce000d57c
commit
3eeb35e787
Notes:
github-actions[bot]
2025-01-17 11:44:25 +00:00
Author: https://github.com/devgianlu
Commit: 3eeb35e787
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3252
Reviewed-by: https://github.com/gmta ✅
4 changed files with 86 additions and 0 deletions
|
@ -454,4 +454,12 @@ ErrorOr<void> RSA_OAEP_EME::configure(OpenSSL_PKEY_CTX& ctx)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> RSA_PSS_EMSA::configure(OpenSSL_PKEY_CTX& ctx)
|
||||
{
|
||||
OPENSSL_TRY(EVP_PKEY_CTX_set_rsa_padding(ctx.ptr(), RSA_PKCS1_PSS_PADDING));
|
||||
OPENSSL_TRY(EVP_PKEY_CTX_set_rsa_mgf1_md(ctx.ptr(), TRY(hash_kind_to_hash_type(m_hash_kind))));
|
||||
OPENSSL_TRY(EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx.ptr(), m_salt_length.value_or(RSA_PSS_SALTLEN_MAX)));
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -344,4 +344,28 @@ private:
|
|||
Optional<ReadonlyBytes> m_label {};
|
||||
};
|
||||
|
||||
class RSA_PSS_EMSA : public RSA_EMSA {
|
||||
public:
|
||||
template<typename... Args>
|
||||
RSA_PSS_EMSA(Hash::HashKind hash_kind, Args... args)
|
||||
: RSA_EMSA(hash_kind, args...)
|
||||
{
|
||||
}
|
||||
|
||||
~RSA_PSS_EMSA() = default;
|
||||
|
||||
virtual ByteString class_name() const override
|
||||
{
|
||||
return "RSA_PSS-EMSA";
|
||||
}
|
||||
|
||||
void set_salt_length(int value) { m_salt_length = value; }
|
||||
|
||||
protected:
|
||||
ErrorOr<void> configure(OpenSSL_PKEY_CTX& ctx) override;
|
||||
|
||||
private:
|
||||
Optional<int> m_salt_length;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue