forked from openthread/openthread
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tcat_ble_client] Added TCAT Commissioner and Device certs compatible…
… with Thread cert test; added scripts for example certificate generation; README files updated.
- Loading branch information
Showing
36 changed files
with
574 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Copyright (c) 2024, The OpenThread Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
# Makefile for creating TCAT example certificates (except CA). | ||
|
||
all: DeviceCert1 CommCert1 CommCert2 | ||
|
||
DeviceCert1: ext/DeviceCert1.ext | ||
./create-cert-tcat-device.sh DeviceCert1 ca | ||
|
||
CommCert1: ext/CommCert1.ext | ||
./create-cert-tcat-commissioner.sh CommCert1 ca | ||
|
||
CommCert2: ext/CommCert2.ext | ||
./create-cert-tcat-commissioner.sh CommCert2 ca | ||
|
||
clean: | ||
rm -rf ./output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICHjCCAcSgAwIBAgIBATAKBggqhkjOPQQDAjBmMR0wGwYDVQQDDBRUQ0FUIEV4 | ||
YW1wbGUgQ0EgJ2NhJzEUMBIGA1UECgwLRXhhbXBsZSBJbmMxFTATBgNVBAcMDEV4 | ||
YW1wbGUgQ2l0eTELMAkGA1UECAwCQ0ExCzAJBgNVBAYTAlVTMB4XDTI0MDUwNTE5 | ||
MTAyMloXDTQ0MDQzMDE5MTAyMlowZjEdMBsGA1UEAwwUVENBVCBFeGFtcGxlIENB | ||
ICdjYScxFDASBgNVBAoMC0V4YW1wbGUgSW5jMRUwEwYDVQQHDAxFeGFtcGxlIENp | ||
dHkxCzAJBgNVBAgMAkNBMQswCQYDVQQGEwJVUzBZMBMGByqGSM49AgEGCCqGSM49 | ||
AwEHA0IABFncszwFxinmWPeDoRwFlx8yX0CIxksmjs5YC/ThBcNkqFA53CyjxsHz | ||
wFEn7jMhJM7MzQzNBx5AbAy6ruJ9uf+jYzBhMB8GA1UdEQQYMBaBFGNhLWFkbWlu | ||
QGV4YW1wbGUub3JnMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0G | ||
A1UdDgQWBBTgTKehLD14MpkRU+S6azYhYsAkKjAKBggqhkjOPQQDAgNIADBFAiA2 | ||
Wp9JGbwiqbW0l0fTS+AKdp6xFXkmuePftuUTsnMKcgIhAPdC1zdx8fHPoTnRLpiH | ||
Pt2/QkcSashR9zOp9MrBnRPb | ||
-----END CERTIFICATE----- |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2024, The OpenThread Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
# Create the certificate of an example CA for TCAT. This single CA creates both the | ||
# TCAT Device certificates, as well as the TCAT Commissioner certificates that | ||
# work for those TCAT Devices. | ||
|
||
if [ $# -ne 1 ]; then | ||
echo "Usage: ./create-cert-ca.sh <NameOfCA>" | ||
exit 1 | ||
fi | ||
set -eu | ||
|
||
# days certificate is valid | ||
(( VALIDITY=20*365 )) | ||
|
||
NAME=${1} | ||
|
||
# create csr | ||
openssl req -new -key "ca/${NAME}_key.pem" -out "${NAME}.csr" \ | ||
-subj "/CN=TCAT Example CA '${NAME}'/O=Example Inc/L=Example City/ST=CA/C=US" | ||
|
||
# self-sign csr | ||
mkdir -p output >& /dev/null | ||
openssl x509 -set_serial 0x01 -extfile "ext/${NAME}.ext" \ | ||
-extensions "${NAME}" -req -in "${NAME}.csr" \ | ||
-signkey "ca/${NAME}_key.pem" -out "ca/${NAME}_cert.pem" \ | ||
-days "${VALIDITY}" -sha256 | ||
|
||
# delete temp files | ||
rm -f "${NAME}.csr" | ||
|
||
# show result | ||
openssl x509 -text -in "ca/${NAME}_cert.pem" |
62 changes: 62 additions & 0 deletions
62
tools/tcat_ble_client/auth-generate/create-cert-tcat-commissioner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2024, The OpenThread Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
# Script to generate a TCAT Commissioner X509v3 certificate. | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "Usage: ./create-cert-tcat-commissioner.sh <NameOfCommissioner> <NameOfCA>" | ||
exit 1 | ||
fi | ||
set -eu | ||
|
||
# number of days certificate is valid | ||
(( VALIDITY="14" )) | ||
echo "create-cert-tcat-commissioner.sh - Using validity param -days ${VALIDITY}" | ||
|
||
NAME=${1} | ||
CANAME=${2} | ||
(( ID=${NAME:0-1} )) | ||
|
||
echo " TCAT commissioner name : ${NAME}" | ||
echo " TCAT commissioner CA name: ${CANAME}" | ||
echo " Numeric serial ID : ${ID}" | ||
|
||
# create csr for TCAT Commissioner | ||
openssl req -new -key "keys/${NAME}_key.pem" -out "${NAME}.csr" -subj \ | ||
"/CN=TCAT Example ${NAME}/serialNumber=3523-1543-000${ID}" | ||
|
||
# sign csr by CA | ||
mkdir -p output >& /dev/null | ||
openssl x509 -set_serial "92429${ID}" -CAform PEM -CA "ca/${CANAME}_cert.pem" \ | ||
-CAkey "ca/${CANAME}_key.pem" -extfile "ext/${NAME}.ext" -extensions \ | ||
"${NAME}" -req -in "${NAME}.csr" -out "output/${NAME}_cert.pem" \ | ||
-days "${VALIDITY}" -sha256 | ||
|
||
# delete temp files | ||
rm -f "${NAME}.csr" |
67 changes: 67 additions & 0 deletions
67
tools/tcat_ble_client/auth-generate/create-cert-tcat-device.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2024, The OpenThread Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
# Script to generate a TCAT Device X509v3 certificate. | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "Usage: ./create-cert-tcat-device.sh <NameOfDevice> <NameOfCA>" | ||
exit 1 | ||
fi | ||
set -eu | ||
|
||
# days certificate is valid | ||
SECONDS1=$(date +%s) # time now | ||
SECONDS2=$(date --date="2999-12-31 23:59:59Z" +%s) # target end time | ||
(( VALIDITY="(${SECONDS2}-${SECONDS1})/(24*3600)" )) | ||
echo "create-cert-tcat-device.sh - Using validity param -days ${VALIDITY}" | ||
|
||
NAME="${1}" | ||
CANAME="${2}" | ||
(( ID=${NAME:0-1} )) | ||
(( SERIAL=13800+ID )) | ||
|
||
echo " TCAT device name : ${NAME}" | ||
echo " TCAT device CA name: ${CANAME}" | ||
echo " Numeric serial ID : ${ID}" | ||
|
||
# create csr for device. | ||
# conform to 802.1AR guidelines, using only CN + serialNumber when | ||
# manufacturer is already present as CA. CN is not even mandatory, but just good practice. | ||
openssl req -new -key "keys/${NAME}_key.pem" -out "${NAME}.csr" -subj \ | ||
"/CN=TCAT Example ${NAME}/serialNumber=4723-9833-000${ID}" | ||
|
||
# sign csr by CA | ||
mkdir -p output >& /dev/null | ||
openssl x509 -set_serial "${SERIAL}" -CAform PEM -CA "ca/${CANAME}_cert.pem" \ | ||
-CAkey "ca/${CANAME}_key.pem" -extfile "ext/${NAME}.ext" -extensions \ | ||
"${NAME}" -req -in "${NAME}.csr" -out "output/${NAME}_cert.pem" \ | ||
-days "${VALIDITY}" -sha256 | ||
|
||
# delete temp files | ||
rm -f "${NAME}.csr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file contains X509v3 extension definitions for OpenSSL | ||
# certificate generation. | ||
|
||
[ CommCert1 ] | ||
keyUsage = critical,digitalSignature, nonRepudiation, \ | ||
keyEncipherment, dataEncipherment | ||
basicConstraints = CA:FALSE | ||
subjectKeyIdentifier = none | ||
authorityKeyIdentifier=keyid | ||
|
||
# Include TCAT specified fields | ||
1.3.6.1.4.1.44970.3 = ASN1:OCTETSTRING:2101010101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file contains X509v3 extension definitions for OpenSSL | ||
# certificate generation. | ||
|
||
[ CommCert2 ] | ||
keyUsage = critical,digitalSignature, nonRepudiation, \ | ||
keyEncipherment, dataEncipherment | ||
basicConstraints = CA:FALSE | ||
subjectKeyIdentifier = none | ||
authorityKeyIdentifier=keyid | ||
|
||
# Include TCAT specified fields | ||
1.3.6.1.4.1.44970.1 = ASN1:IA5STRING:DefaultDomain | ||
1.3.6.1.4.1.44970.3 = ASN1:OCTETSTRING:211F3F3F3F | ||
1.3.6.1.4.1.44970.4 = ASN1:UTF8STRING:OpenThread-c64e | ||
1.3.6.1.4.1.44970.5 = ASN1:OCTETSTRING:ef1398c2fd504b67 |
Oops, something went wrong.