LibCrypto: Return PEM type when decoding and sanity check footer

Improve PEM decoding by parsing the header and returning it along the
data. Also verify if the header is equal to the footer.
This commit is contained in:
devgianlu 2024-11-29 20:30:42 +01:00 committed by Andreas Kling
commit 57ecd72256
Notes: github-actions[bot] 2024-11-30 10:18:56 +00:00
4 changed files with 75 additions and 20 deletions

View file

@ -266,7 +266,7 @@ void RSA::import_private_key(ReadonlyBytes bytes, bool pem)
{
ByteBuffer buffer;
if (pem) {
buffer = decode_pem(bytes);
buffer = decode_pem(bytes).data;
bytes = buffer;
}
@ -282,7 +282,7 @@ void RSA::import_public_key(ReadonlyBytes bytes, bool pem)
{
ByteBuffer buffer;
if (pem) {
buffer = decode_pem(bytes);
buffer = decode_pem(bytes).data;
bytes = buffer;
}