chromium/net/tools/transport_security_state_generator/cert_util.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/tools/transport_security_state_generator/cert_util.h"

#include <string>
#include <string_view>

#include "base/base64.h"
#include "base/files/file_util.h"
#include "base/numerics/clamped_math.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "net/tools/transport_security_state_generator/spki_hash.h"
#include "third_party/boringssl/src/include/openssl/crypto.h"

SPKIHash;

namespace {

static const char kPEMBeginBlock[] =;
static const char kPEMEndBlock[] =;

// Tries to extract the BASE64 encoded DER structure from |pem_input| by looking
// for the block type in |expected_block_type|. Only attempts the locate the
// first matching block. Other blocks are ignored. Returns true on success and
// copies the der structure to |*der_output|. Returns false on error.
bool ParsePEM(std::string_view pem_input,
              std::string_view expected_block_type,
              std::string* der_output) {}

// Attempts to extract the first entry of type |nid| from |*name|. Returns true
// if the field exists and was extracted. Returns false when the field was not
// found or the data could not be extracted.
bool ExtractFieldFromX509Name(X509_NAME* name, int nid, std::string* field) {}

}  // namespace

bssl::UniquePtr<X509> GetX509CertificateFromPEM(std::string_view pem_data) {}

bool ExtractSubjectNameFromCertificate(X509* certificate, std::string* name) {}

bool CalculateSPKIHashFromCertificate(X509* certificate, SPKIHash* out_hash) {}

bool CalculateSPKIHashFromKey(std::string_view pem_key, SPKIHash* out_hash) {}