3 # Copyright 2018 Intel Corporation
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # Receives two arguments 1. srk_handle 2. password
20 docker login -u docker -p docker nexus3.onap.org:10001
21 docker pull nexus3.onap.org:10001/onap/aaf/distcenter
22 docker pull nexus3.onap.org:10001/onap/aaf/abrmd
23 docker pull nexus3.onap.org:10001/onap/aaf/testcaservice
24 docker pull nexus3.onap.org:10001/onap/aaf/aaf_cm
26 ABRMD_DATA="$(pwd)/data/abrmd"
27 SEC_FOLDER="$(pwd)/data/abrmd/cred"
29 DISTCENTER_DATA="$(pwd)/data/distcenter"
30 DISTCENTER_SEC="$(pwd)/data/distcenter/data"
32 CASERVICE_DATA="$(pwd)/data/caservice"
35 mkdir -p $(pwd)/data/abrmd/cred
36 echo $1 > $ABRMD_DATA/cred/srk_handle.txt
37 echo $2 > $ABRMD_DATA/cred/opass.txt
39 cp $ABRMD_DATA/cred/opass.txt $CASERVICE_DATA/ipass.txt
40 base64 $ABRMD_DATA/cred/opass.txt > $ABRMD_DATA/cred/opass
41 base64 $ABRMD_DATA/cred/srk_handle.txt > $ABRMD_DATA/cred/srk_handle
44 if [ -e /dev/tpm0 ]; then
46 echo "found tpm device"
48 # Running the abrmd container for tpm init
50 docker run --privileged -device=/dev/tpm0 -e ABRMD_DATA=/abrmd/data \
51 -e TPM_NODE_NAME=testnode \
52 -v $SEC_FOLDER:/abrmd/cred \
53 -v $ABRMD_DATA:/abrmd/data \
54 --entrypoint /abrmd/bin/initialize_tpm.sh \
55 --name tpm-init nexus3.onap.org:10001/onap/aaf/abrmd
58 mkdir -p $DISTCENTER_DATA/host_testnode
59 ls $ABRMD_DATA/host_testnode/
60 cp $ABRMD_DATA/host_testnode/out_parent_public \
61 $DISTCENTER_DATA/host_testnode/
63 docker run -d --privileged -device=/dev/tpm0 \
64 -v /tmp/run/dbus:/var/run/dbus:rw \
65 --entrypoint /abrmd/bin/run_abrmd.sh \
66 --name abrmd nexus3.onap.org:10001/onap/aaf/abrmd
72 # Running the distcenter container
74 docker run -v $DISTCENTER_DATA:/distcenter/data \
75 --name distcenter nexus3.onap.org:10001/onap/aaf/distcenter
78 mkdir -p $CASERVICE_DATA/host_testnode
79 if [ -f $DISTCENTER_DATA/privkey.pem.gpg ]; then
80 cp $DISTCENTER_DATA/privkey.pem.gpg $CASERVICE_DATA/host_testnode/
81 cp $DISTCENTER_DATA/ca.cert $CASERVICE_DATA/host_testnode/
82 cp $DISTCENTER_DATA/passphrase $CASERVICE_DATA/host_testnode/
84 cp $DISTCENTER_DATA/host_testnode/* \
85 $CASERVICE_DATA/host_testnode
86 cp $SEC_FOLDER/srk_handle $CASERVICE_DATA/host_testnode/
89 cp $CASERVICE_DATA/passphrase-ipass $CASERVICE_DATA/host_testnode/
90 cp $CASERVICE_DATA/passphrase-pin $CASERVICE_DATA/host_testnode/
92 cat passphrase-ipass | gpg --symmetric -z 9 --require-secmem \
93 --cipher-algo AES256 --s2k-cipher-algo AES256 --s2k-digest-algo SHA512 \
94 --s2k-mode 3 --s2k-count 65000000 --compress-algo BZIP2 \
95 --passphrase-fd 0 ipass.txt
96 cat passphrase-pin | gpg --symmetric -z 9 --require-secmem \
97 --cipher-algo AES256 --s2k-cipher-algo AES256 --s2k-digest-algo SHA512 \
98 --s2k-mode 3 --s2k-count 65000000 --compress-algo BZIP2 \
99 --passphrase-fd 0 upin.txt
100 cat passphrase-pin | gpg --symmetric -z 9 --require-secmem \
101 --cipher-algo AES256 --s2k-cipher-algo AES256 --s2k-digest-algo SHA512 \
102 --s2k-mode 3 --s2k-count 65000000 --compress-algo BZIP2 \
103 --passphrase-fd 0 sopin.txt
104 cp $CASERVICE_DATA/*.gpg $CASERVICE_DATA/host_testnode/
105 cp $ABRMD_DATA/cred/srk_handle.txt $CASERVICE_DATA/host_testnode/tpm-handle.txt
106 cp $ABRMD_DATA/cred/opass $CASERVICE_DATA/host_testnode/prk_passwd