File: tst_sign.sh

package info (click to toggle)
oath-toolkit 2.6.13-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,060 kB
  • sloc: ansic: 52,694; sh: 7,440; yacc: 1,847; xml: 1,841; makefile: 573
file content (50 lines) | stat: -rwxr-xr-x 1,566 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

# tst_sign.sh - test that pskctool can sign and verify
# Copyright (C) 2012-2025 Simon Josefsson

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

set -e

PSKCTOOL=${PSKCTOOL:-../pskctool}

srcdir="${srcdir:-.}"
pskc_all="$srcdir/pskc-all.xml"
pskc_all_signed="$srcdir/pskc-all-signed.xml"
pskc_ee_key="$srcdir/pskc-ee-key.pem"
pskc_ee_crt="$srcdir/pskc-ee-crt.pem"
pskc_root_crt="$srcdir/pskc-root-crt.pem"

$PSKCTOOL --info --strict --debug $pskc_all > tmp-pre-human.txt

$PSKCTOOL --sign \
    --sign-key $pskc_ee_key \
    --sign-crt $pskc_ee_crt \
    $pskc_all | sed 's,4</X509Cert,4\n</X509Cert,' > tmp-signed.xml

diff -ur $pskc_all_signed tmp-signed.xml

$PSKCTOOL --info --strict --debug tmp-signed.xml \
    | sed 's/Signed: YES/Signed: NO/' > tmp-post-human.txt

diff -ur tmp-pre-human.txt tmp-post-human.txt

$PSKCTOOL --verify --quiet \
    --verify-crt $pskc_root_crt \
    tmp-signed.xml

rm -f tmp-pre-human.txt tmp-signed.xml tmp-post-human.txt

exit 0