mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibCrypto: Prevent exporting invalid DER RSAPrivateKey
This commit is contained in:
parent
7180c5f13b
commit
3431b3235c
Notes:
github-actions[bot]
2025-02-17 23:03:35 +00:00
Author: https://github.com/devgianlu Commit: https://github.com/LadybirdBrowser/ladybird/commit/3431b3235c1 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3606
1 changed files with 4 additions and 0 deletions
|
@ -121,6 +121,10 @@ public:
|
|||
|
||||
ErrorOr<ByteBuffer> export_as_der() const
|
||||
{
|
||||
if (m_prime_1.is_zero() || m_prime_2.is_zero()) {
|
||||
return Error::from_string_literal("Cannot export private key without prime factors");
|
||||
}
|
||||
|
||||
ASN1::Encoder encoder;
|
||||
TRY(encoder.write_constructed(ASN1::Class::Universal, ASN1::Kind::Sequence, [&]() -> ErrorOr<void> {
|
||||
TRY(encoder.write(0x00u)); // version
|
||||
|
|
Loading…
Add table
Reference in a new issue