115ae2509SBrad Bishop#!/bin/sh
215ae2509SBrad Bishop#
315ae2509SBrad Bishop# Copied from ima-evm-utils.
415ae2509SBrad Bishop#
515ae2509SBrad Bishop# This program is free software; you can redistribute it and/or
615ae2509SBrad Bishop# modify it under the terms of the GNU General Public License
715ae2509SBrad Bishop# version 2 as published by the Free Software Foundation.
815ae2509SBrad Bishop#
915ae2509SBrad Bishop# This program is distributed in the hope that it will be useful,
1015ae2509SBrad Bishop# but WITHOUT ANY WARRANTY; without even the implied warranty of
1115ae2509SBrad Bishop# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1215ae2509SBrad Bishop# GNU General Public License for more details.
1315ae2509SBrad Bishop#
1415ae2509SBrad Bishop# You should have received a copy of the GNU General Public License
1515ae2509SBrad Bishop# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1615ae2509SBrad Bishop
1715ae2509SBrad BishopGENKEY=ima-local-ca.genkey
1815ae2509SBrad Bishop
1915ae2509SBrad Bishopcat << __EOF__ >$GENKEY
2015ae2509SBrad Bishop[ req ]
2115ae2509SBrad Bishopdistinguished_name = req_distinguished_name
2215ae2509SBrad Bishopprompt = no
2315ae2509SBrad Bishopstring_mask = utf8only
2415ae2509SBrad Bishopx509_extensions = v3_ca
2515ae2509SBrad Bishop
2615ae2509SBrad Bishop[ req_distinguished_name ]
2715ae2509SBrad BishopO = example.com
2815ae2509SBrad BishopCN = meta-intel-iot-security example certificate signing key
2915ae2509SBrad BishopemailAddress = john.doe@example.com
3015ae2509SBrad Bishop
3115ae2509SBrad Bishop[ v3_ca ]
3215ae2509SBrad BishopbasicConstraints=CA:TRUE
3315ae2509SBrad BishopsubjectKeyIdentifier=hash
3415ae2509SBrad BishopauthorityKeyIdentifier=keyid:always,issuer
35*dc9d6147SAndrew GeisslerkeyUsage = cRLSign, keyCertSign
3615ae2509SBrad Bishop__EOF__
3715ae2509SBrad Bishop
38*dc9d6147SAndrew Geissleropenssl req -new -x509 -utf8 -sha256 -days 36500 -batch -config $GENKEY \
39*dc9d6147SAndrew Geissler        -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 \
4015ae2509SBrad Bishop        -outform DER -out ima-local-ca.x509 -keyout ima-local-ca.priv
4115ae2509SBrad Bishop
4215ae2509SBrad Bishopopenssl x509 -inform DER -in ima-local-ca.x509 -out ima-local-ca.pem
43