|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright (c) 2021 Project CHIP Authors |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# |
| 18 | + |
| 19 | +# Script that can be used to generate Certification Declaration (CD) |
| 20 | +# for testing purposes. |
| 21 | +# The script expects the path to the chip-cert tool binary as an input argument. |
| 22 | +# |
| 23 | +# Usage example when the script is run from the CHIP SDK root directory: |
| 24 | +# ./credentials/test/gen-test-cds.sh ./out/debug/standalone/chip-cert |
| 25 | +# |
| 26 | +# The result will be stored in: |
| 27 | +# credentials/test/certification-declaration |
| 28 | +# |
| 29 | +# If the intention is to re-generate a new set of CDs that replace the already |
| 30 | +# present ones then it is recommended to clear the folder: |
| 31 | +# rm credentials/test/certification-declaration/* |
| 32 | +# |
| 33 | + |
| 34 | +set -e |
| 35 | + |
| 36 | +here=${0%/*} |
| 37 | + |
| 38 | +dest_dir="$here/certification-declaration" |
| 39 | + |
| 40 | +mkdir -p "$dest_dir" |
| 41 | + |
| 42 | +if [ $# == 1 ]; then |
| 43 | + chip_cert_tool=$1 |
| 44 | +else |
| 45 | + echo "Error: Please specify exactly one input argument; the path to the chip-cert tool binary" |
| 46 | + exit |
| 47 | +fi |
| 48 | + |
| 49 | +cert_valid_from="2021-06-28 14:23:43" |
| 50 | +cert_lifetime=4294967295 |
| 51 | + |
| 52 | +format_version=1 |
| 53 | +vids=(FFF2 FFF3) |
| 54 | +pid0=8001 |
| 55 | +pid1=8002 |
| 56 | +device_type_id=0x1234 |
| 57 | +certificate_id0="ZIG20141ZB330001-24" |
| 58 | +certificate_id1="ZIG20142ZB330002-24" |
| 59 | +security_level=0 |
| 60 | +security_info=0 |
| 61 | +version_num=9876 |
| 62 | +certification_type=0 |
| 63 | +dac_origin_vendor_id=0xFFF1 |
| 64 | +dac_origin_product_id=0x8000 |
| 65 | + |
| 66 | +cd_signing_key="$dest_dir/Chip-Test-CD-Signing-Key.pem" |
| 67 | +cd_signing_cert="$dest_dir/Chip-Test-CD-Signing-Cert.pem" |
| 68 | + |
| 69 | +# Using gen-att-cert command to generate CD Signing Cert/Key: |
| 70 | +"$chip_cert_tool" gen-att-cert --type a --subject-cn "Matter Test CD Signing Authority" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --out-key "$cd_signing_key" --out "$cd_signing_cert" |
| 71 | + |
| 72 | +for vid in "${vids[@]}"; do |
| 73 | + |
| 74 | + "$chip_cert_tool" gen-cd --key "$cd_signing_key" --cert "$cd_signing_cert" --out "$dest_dir/Chip-Test-CD-$vid-$pid0.der" --format-version "$format_version" --vendor-id "0x$vid" --product-id "0x$pid0" --device-type-id "$device_type_id" --certificate-id "$certificate_id0" --security-level "$security_level" --security-info "$security_info" --version-number "$version_num" --certification-type "$certification_type" |
| 75 | + |
| 76 | + "$chip_cert_tool" gen-cd --key "$cd_signing_key" --cert "$cd_signing_cert" --out "$dest_dir/Chip-Test-CD-$vid-$pid1.der" --format-version "$format_version" --vendor-id "0x$vid" --product-id "0x$pid1" --device-type-id "$device_type_id" --certificate-id "$certificate_id1" --security-level "$security_level" --security-info "$security_info" --version-number "$version_num" --certification-type "$certification_type" |
| 77 | + |
| 78 | + "$chip_cert_tool" gen-cd --key "$cd_signing_key" --cert "$cd_signing_cert" --out "$dest_dir/Chip-Test-CD-$vid-$pid1-WithDACOrigin.der" --format-version "$format_version" --vendor-id "0x$vid" --product-id "0x$pid1" --device-type-id "$device_type_id" --certificate-id "$certificate_id1" --security-level "$security_level" --security-info "$security_info" --version-number "$version_num" --certification-type "$certification_type" --dac-origin-vendor-id "$dac_origin_vendor_id" --dac-origin-product-id "$dac_origin_product_id" |
| 79 | + |
| 80 | + "$chip_cert_tool" gen-cd --key "$cd_signing_key" --cert "$cd_signing_cert" --out "$dest_dir/Chip-Test-CD-$vid-$pid0-$pid1.der" --format-version "$format_version" --vendor-id "0x$vid" --product-id "0x$pid0" --product-id "0x$pid1" --device-type-id "$device_type_id" --certificate-id "$certificate_id1" --security-level "$security_level" --security-info "$security_info" --version-number "$version_num" --certification-type "$certification_type" |
| 81 | + |
| 82 | + "$chip_cert_tool" gen-cd --key "$cd_signing_key" --cert "$cd_signing_cert" --out "$dest_dir/Chip-Test-CD-$vid-$pid0-$pid1-WithDACOrigin.der" --format-version "$format_version" --vendor-id "0x$vid" --product-id "0x$pid0" --product-id "0x$pid1" --device-type-id "$device_type_id" --certificate-id "$certificate_id1" --security-level "$security_level" --security-info "$security_info" --version-number "$version_num" --certification-type "$certification_type" --dac-origin-vendor-id "$dac_origin_vendor_id" --dac-origin-product-id "$dac_origin_product_id" |
| 83 | + |
| 84 | +done |
0 commit comments