#include "util/crypto/certificate_utils.h"
#include <openssl/asn1.h>
#include <openssl/bio.h>
#include <openssl/bn.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/ssl.h>
#include <openssl/x509v3.h>
#include <time.h>
#include <string>
#include "util/crypto/openssl_util.h"
#include "util/crypto/sha2.h"
#include "util/osp_logging.h"
namespace openscreen {
namespace {
enum KeyUsageBits { … };
bool AddCertificateField(X509_NAME* certificate_name,
std::string_view field,
std::string_view value) { … }
bssl::UniquePtr<ASN1_TIME> ToAsn1Time(std::chrono::seconds time_since_epoch) { … }
bssl::UniquePtr<X509> CreateCertificateInternal(
std::string_view name,
std::chrono::seconds certificate_duration,
const EVP_PKEY& key_pair,
std::chrono::seconds time_since_unix_epoch,
bool make_ca,
X509* issuer,
EVP_PKEY* issuer_key) { … }
}
bssl::UniquePtr<EVP_PKEY> GenerateRsaKeyPair(int key_bits) { … }
ErrorOr<bssl::UniquePtr<X509>> CreateSelfSignedX509Certificate(
std::string_view name,
std::chrono::seconds duration,
const EVP_PKEY& key_pair,
std::chrono::seconds time_since_unix_epoch,
bool make_ca,
X509* issuer,
EVP_PKEY* issuer_key) { … }
ErrorOr<std::vector<uint8_t>> ExportX509CertificateToDer(
const X509& certificate) { … }
ErrorOr<bssl::UniquePtr<X509>> ImportCertificate(const uint8_t* der_x509_cert,
int der_x509_cert_length) { … }
ErrorOr<bssl::UniquePtr<EVP_PKEY>> ImportRSAPrivateKey(
const uint8_t* der_rsa_private_key,
int key_length) { … }
std::string GetSpkiTlv(X509* cert) { … }
ErrorOr<uint64_t> ParseDerUint64(const ASN1_INTEGER* asn1int) { … }
}