File: pkcs12_validator.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (51 lines) | stat: -rw-r--r-- 2,051 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file contains a group of functions which are used for pkcs12 data
// validation before data import to chaps. They are used in kcer_chaps_util.cc,
// but they are not related to chaps, so they were moved to a separate file.

#ifndef CHROMEOS_ASH_COMPONENTS_KCER_HELPERS_PKCS12_VALIDATOR_H_
#define CHROMEOS_ASH_COMPONENTS_KCER_HELPERS_PKCS12_VALIDATOR_H_

#include <string>
#include <vector>

#include "base/memory/raw_ref.h"
#include "chromeos/ash/components/kcer/cert_cache.h"
#include "chromeos/ash/components/kcer/helpers/pkcs12_reader.h"
#include "third_party/boringssl/src/include/openssl/base.h"
#include "third_party/boringssl/src/include/openssl/stack.h"

namespace kcer::internal {

// Returns an error message corresponding to the given import error code.
std::string MakePkcs12CertImportErrorMessage(Pkcs12ReaderStatusCode error_code);

Error ConvertPkcs12ParsingError(Pkcs12ReaderStatusCode status);

// Finds or creates the correct nickname for the `cert` taking the
// `existing_certs` into account.
Pkcs12ReaderStatusCode GetNickname(
    const std::vector<scoped_refptr<const Cert>>& existing_certs,
    const base::flat_set<std::string_view>& existing_nicknames,
    X509* cert,
    const Pkcs12Reader& pkcs12_reader,
    std::string& cert_nickname);

// Filter out certs from (`certs`) which are not directly related to key_data
// (`key_data`), extracts nickname from the certificate or placing default
// nickname and stores certificates which will be installed to
// (`valid_certs_data`). Exported for unit tests only.
COMPONENT_EXPORT(KCER)
Pkcs12ReaderStatusCode ValidateAndPrepareCertData(
    const CertCache& cert_cache,
    const Pkcs12Reader& pkcs12_reader,
    bssl::UniquePtr<STACK_OF(X509)> certs,
    KeyData& key_data,
    std::vector<CertData>& valid_certs_data);

}  // namespace kcer::internal

#endif  // CHROMEOS_ASH_COMPONENTS_KCER_HELPERS_PKCS12_VALIDATOR_H_