Skip to content

Commit

Permalink
Implemented CHIP Certificate (chip-cert) Tool. (#6403)
Browse files Browse the repository at this point in the history
chip-cert tool provides command line interface (CLI) utility used
for generating and manipulating CHIP certificates and CHIP
private keys material.

chip-tool supports the following commands:
  - generate CHIP certificate
  - convert CHIP certificate format
  - convert CHIP private key format
  - validate CHIP certificate chain
  - resign CHIP certificate
  - print CHIP certificate
  • Loading branch information
emargolis authored May 13, 2021
1 parent 9a79283 commit f0e9f91
Show file tree
Hide file tree
Showing 15 changed files with 3,425 additions and 1 deletion.
5 changes: 5 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ assert(chip_root == "//")
import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/build/chip/tools.gni")

import("//src/crypto/crypto.gni")

if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
declare_args() {
chip_enable_python_modules =
Expand Down Expand Up @@ -107,6 +109,9 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
"${chip_root}/src/qrcodetool",
"${chip_root}/src/setup_payload",
]
if (chip_crypto == "openssl") {
deps += [ "${chip_root}/src/tools/chip-cert" ]
}
if (chip_enable_python_modules) {
deps += [ "${chip_root}/src/controller/python" ]
}
Expand Down
1 change: 0 additions & 1 deletion src/credentials/CHIPCert.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ class ChipDN
**/
bool IsEmpty() const { return RDNCount() == 0; }

protected:
ChipRDN rdn[CHIP_CONFIG_CERT_MAX_RDN_ATTRIBUTES];

uint8_t RDNCount() const;
Expand Down
54 changes: 54 additions & 0 deletions src/tools/chip-cert/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/tools.gni")

import("//build/config/linux/pkg_config.gni")

# TODO: Move it into common BUILD file to avoid multiple runs of pkg_config
pkg_config("openssl_config") {
packages = [ "openssl" ]
}

assert(chip_build_tools)

executable("chip-cert") {
sources = [
"CertUtils.cpp",
"Cmd_ConvertCert.cpp",
"Cmd_ConvertKey.cpp",
"Cmd_GenCert.cpp",
"Cmd_PrintCert.cpp",
"Cmd_ResignCert.cpp",
"Cmd_ValidateCert.cpp",
"GeneralUtils.cpp",
"KeyUtils.cpp",
"chip-cert.cpp",
"chip-cert.h",
]

public_configs = [ ":openssl_config" ]

cflags = [ "-Wconversion" ]

public_deps = [
"${chip_root}/src/credentials",
"${chip_root}/src/crypto",
"${chip_root}/src/lib/asn1",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
]
}
Loading

0 comments on commit f0e9f91

Please sign in to comment.