mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-17 07:41:54 +00:00
Improve PEM decoding by parsing the header and returning it along the data. Also verify if the header is equal to the footer.
31 lines
560 B
C++
31 lines
560 B
C++
/*
|
|
* Copyright (c) 2020, Ali Mohammad Pur <mpfard@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
namespace Crypto {
|
|
|
|
enum class PEMType {
|
|
Unknown,
|
|
Certificate,
|
|
PrivateKey,
|
|
PublicKey,
|
|
RSAPrivateKey,
|
|
RSAPublicKey
|
|
};
|
|
|
|
struct DecodedPEM {
|
|
PEMType type { PEMType::Unknown };
|
|
ByteBuffer data;
|
|
};
|
|
|
|
DecodedPEM decode_pem(ReadonlyBytes);
|
|
ErrorOr<Vector<DecodedPEM>> decode_pems(ReadonlyBytes);
|
|
ErrorOr<ByteBuffer> encode_pem(ReadonlyBytes, PEMType = PEMType::Certificate);
|
|
|
|
}
|