ladybird/Libraries/LibCrypto/ASN1/PEM.h
devgianlu 57ecd72256 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.
2024-11-30 11:17:44 +01:00

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);
}