mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-12-25 03:12:10 +00:00
upstream: basic unit test for sshsig.[ch], including FIDO keys
verification only so far OpenBSD-Regress-ID: fb1f946c8fc59206bc6a6666e577b5d5d7e45896
This commit is contained in:
parent
e95c0a0e96
commit
5edfa1690e
1
.gitignore
vendored
1
.gitignore
vendored
@ -30,4 +30,5 @@ ssh-pkcs11-helper
|
||||
ssh-sk-helper
|
||||
sshd
|
||||
!regress/misc/fuzz-harness/Makefile
|
||||
!regress/unittests/sshsig/Makefile
|
||||
tags
|
||||
|
25
regress/unittests/sshsig/Makefile
Normal file
25
regress/unittests/sshsig/Makefile
Normal file
@ -0,0 +1,25 @@
|
||||
# $OpenBSD: Makefile,v 1.1 2020/06/19 04:32:09 djm Exp $
|
||||
|
||||
PROG=test_sshsig
|
||||
SRCS=tests.c
|
||||
|
||||
# From usr.bin/ssh
|
||||
SRCS+=sshbuf-getput-basic.c sshbuf-getput-crypto.c sshbuf-misc.c sshbuf.c
|
||||
SRCS+=sshbuf-io.c atomicio.c sshkey.c authfile.c cipher.c log.c ssh-rsa.c
|
||||
SRCS+=ssh-dss.c ssh-ecdsa.c ssh-ed25519.c mac.c umac.c umac128.c hmac.c misc.c
|
||||
SRCS+=ssherr.c uidswap.c cleanup.c xmalloc.c match.c krl.c fatal.c
|
||||
SRCS+=addrmatch.c bitmap.c sshsig.c
|
||||
SRCS+=ed25519.c hash.c ge25519.c fe25519.c sc25519.c verify.c
|
||||
SRCS+=cipher-chachapoly.c chacha.c poly1305.c ssh-ecdsa-sk.c ssh-sk.c
|
||||
SRCS+=ssh-ed25519-sk.c sk-usbhid.c
|
||||
|
||||
SRCS+=digest-openssl.c
|
||||
#SRCS+=digest-libc.c
|
||||
SRCS+=utf8.c
|
||||
|
||||
REGRESS_TARGETS=run-regress-${PROG}
|
||||
|
||||
run-regress-${PROG}: ${PROG}
|
||||
env ${TEST_ENV} ./${PROG} ${UNITTEST_ARGS} -d ${.CURDIR}/testdata
|
||||
|
||||
.include <bsd.regress.mk>
|
42
regress/unittests/sshsig/mktestdata.sh
Executable file
42
regress/unittests/sshsig/mktestdata.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
# $OpenBSD: mktestdata.sh,v 1.1 2020/06/19 04:32:09 djm Exp $
|
||||
|
||||
NAMESPACE=unittest
|
||||
|
||||
set -ex
|
||||
|
||||
cd testdata
|
||||
|
||||
if [ -f ../../../misc/sk-dummy/sk-dummy.so ] ; then
|
||||
SK_DUMMY=../../../misc/sk-dummy/sk-dummy.so
|
||||
elif [ -f ../../../misc/sk-dummy/obj/sk-dummy.so ] ; then
|
||||
SK_DUMMY=../../../misc/sk-dummy/obj/sk-dummy.so
|
||||
else
|
||||
echo "Can't find sk-dummy.so" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f signed-data namespace
|
||||
rm -f rsa dsa ecdsa ed25519 ecdsa_sk ed25519_sk
|
||||
rm -f rsa.sig dsa.sig ecdsa.sig ed25519.sig ecdsa_sk.sig ed25519_sk.sig
|
||||
|
||||
printf "This is a test, this is only a test" > signed-data
|
||||
printf "$NAMESPACE" > namespace
|
||||
|
||||
ssh-keygen -t rsa -C "RSA test" -N "" -f rsa -m PEM
|
||||
ssh-keygen -t dsa -C "DSA test" -N "" -f dsa -m PEM
|
||||
ssh-keygen -t ecdsa -C "ECDSA test" -N "" -f ecdsa -m PEM
|
||||
ssh-keygen -t ed25519 -C "ED25519 test key" -N "" -f ed25519
|
||||
ssh-keygen -w "$SK_DUMMY" -t ecdsa-sk -C "ECDSA-SK test key" \
|
||||
-N "" -f ecdsa_sk
|
||||
ssh-keygen -w "$SK_DUMMY" -t ed25519-sk -C "ED25519-SK test key" \
|
||||
-N "" -f ed25519_sk
|
||||
|
||||
ssh-keygen -Y sign -f rsa -n $NAMESPACE - < signed-data > rsa.sig
|
||||
ssh-keygen -Y sign -f dsa -n $NAMESPACE - < signed-data > dsa.sig
|
||||
ssh-keygen -Y sign -f ecdsa -n $NAMESPACE - < signed-data > ecdsa.sig
|
||||
ssh-keygen -Y sign -f ed25519 -n $NAMESPACE - < signed-data > ed25519.sig
|
||||
ssh-keygen -w "$SK_DUMMY" \
|
||||
-Y sign -f ecdsa_sk -n $NAMESPACE - < signed-data > ecdsa_sk.sig
|
||||
ssh-keygen -w "$SK_DUMMY" \
|
||||
-Y sign -f ed25519_sk -n $NAMESPACE - < signed-data > ed25519_sk.sig
|
12
regress/unittests/sshsig/testdata/dsa
vendored
Normal file
12
regress/unittests/sshsig/testdata/dsa
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
-----BEGIN DSA PRIVATE KEY-----
|
||||
MIIBuwIBAAKBgQCXpndQdz2mQVnk+lYOF3nxDT+h6SiJmUvBFhnFWBv8tG4pTOkb
|
||||
EwGufLEzGpzjTj+3bjVau7LFt37AFrqs4Num272BWNsYNIjOlGPgq7Xjv32FN00x
|
||||
JYh1DoRs1cGGnvohlsWEamGGhTHD1a9ipctPEBV+NrxtZMrl+pO/ZZg8vQIVAKJB
|
||||
P3iNYSpSuW74+q4WxLCuK8O3AoGAQldE+BIuxlvoG1IFiWesx0CU+H2KO0SEZc9A
|
||||
SX/qjOabh0Fb78ofTlEf9gWHFfat8SvSJQIOPMVlb76Lio8AAMT8Eaa/qQKKYmQL
|
||||
dNq4MLhhjxx5KLGt6J2JyFPExCv+qnHYHD59ngtLwKyqGjpSC8LPLktdXn8W/Aad
|
||||
Ly1K7+MCgYBsMHBczhSeUh8w7i20CVg4OlNTmfJRVU2tO6OpMxZ/quitRm3hLKSN
|
||||
u4xRkvHJwi4LhQtv1SXvLI5gs5P3gCG8tsIAiyCqLinHha63iBdJpqhnV/x/j7dB
|
||||
yJr3xJbnmLdWLkkCtNk1Ir1/CuEz+ufAyLGdKWksEAu1UUlb501BkwIVAILIa3Rg
|
||||
0h7J9lQpHJphvF3K0M1T
|
||||
-----END DSA PRIVATE KEY-----
|
1
regress/unittests/sshsig/testdata/dsa.pub
vendored
Normal file
1
regress/unittests/sshsig/testdata/dsa.pub
vendored
Normal file
@ -0,0 +1 @@
|
||||
ssh-dss AAAAB3NzaC1kc3MAAACBAJemd1B3PaZBWeT6Vg4XefENP6HpKImZS8EWGcVYG/y0bilM6RsTAa58sTManONOP7duNVq7ssW3fsAWuqzg26bbvYFY2xg0iM6UY+CrteO/fYU3TTEliHUOhGzVwYae+iGWxYRqYYaFMcPVr2Kly08QFX42vG1kyuX6k79lmDy9AAAAFQCiQT94jWEqUrlu+PquFsSwrivDtwAAAIBCV0T4Ei7GW+gbUgWJZ6zHQJT4fYo7RIRlz0BJf+qM5puHQVvvyh9OUR/2BYcV9q3xK9IlAg48xWVvvouKjwAAxPwRpr+pAopiZAt02rgwuGGPHHkosa3onYnIU8TEK/6qcdgcPn2eC0vArKoaOlILws8uS11efxb8Bp0vLUrv4wAAAIBsMHBczhSeUh8w7i20CVg4OlNTmfJRVU2tO6OpMxZ/quitRm3hLKSNu4xRkvHJwi4LhQtv1SXvLI5gs5P3gCG8tsIAiyCqLinHha63iBdJpqhnV/x/j7dByJr3xJbnmLdWLkkCtNk1Ir1/CuEz+ufAyLGdKWksEAu1UUlb501Bkw== DSA test
|
13
regress/unittests/sshsig/testdata/dsa.sig
vendored
Normal file
13
regress/unittests/sshsig/testdata/dsa.sig
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
-----BEGIN SSH SIGNATURE-----
|
||||
U1NIU0lHAAAAAQAAAbEAAAAHc3NoLWRzcwAAAIEAl6Z3UHc9pkFZ5PpWDhd58Q0/oekoiZ
|
||||
lLwRYZxVgb/LRuKUzpGxMBrnyxMxqc404/t241Wruyxbd+wBa6rODbptu9gVjbGDSIzpRj
|
||||
4Ku14799hTdNMSWIdQ6EbNXBhp76IZbFhGphhoUxw9WvYqXLTxAVfja8bWTK5fqTv2WYPL
|
||||
0AAAAVAKJBP3iNYSpSuW74+q4WxLCuK8O3AAAAgEJXRPgSLsZb6BtSBYlnrMdAlPh9ijtE
|
||||
hGXPQEl/6ozmm4dBW+/KH05RH/YFhxX2rfEr0iUCDjzFZW++i4qPAADE/BGmv6kCimJkC3
|
||||
TauDC4YY8ceSixreidichTxMQr/qpx2Bw+fZ4LS8Csqho6UgvCzy5LXV5/FvwGnS8tSu/j
|
||||
AAAAgGwwcFzOFJ5SHzDuLbQJWDg6U1OZ8lFVTa07o6kzFn+q6K1GbeEspI27jFGS8cnCLg
|
||||
uFC2/VJe8sjmCzk/eAIby2wgCLIKouKceFrreIF0mmqGdX/H+Pt0HImvfElueYt1YuSQK0
|
||||
2TUivX8K4TP658DIsZ0paSwQC7VRSVvnTUGTAAAACHVuaXR0ZXN0AAAAAAAAAAZzaGE1MT
|
||||
IAAAA3AAAAB3NzaC1kc3MAAAAodi5lr0pqBpO76OY4N1CtfR85BCgZ95qfVjP/e9lToj0q
|
||||
lwjSJJXUjw==
|
||||
-----END SSH SIGNATURE-----
|
5
regress/unittests/sshsig/testdata/ecdsa
vendored
Normal file
5
regress/unittests/sshsig/testdata/ecdsa
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
MHcCAQEEIFg0ZCSEB5LNeLsXYL25g3kqEWsqh52DR+yNOjyQJqyZoAoGCCqGSM49
|
||||
AwEHoUQDQgAE3sud88FV0N8FPspZSV7LWqj6uPPLRZiSsenNuEYAteWPyDgrZsWb
|
||||
LzXBuUJucepaCNuW/QWgHBRbrjWj3ERm3A==
|
||||
-----END EC PRIVATE KEY-----
|
1
regress/unittests/sshsig/testdata/ecdsa.pub
vendored
Normal file
1
regress/unittests/sshsig/testdata/ecdsa.pub
vendored
Normal file
@ -0,0 +1 @@
|
||||
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBN7LnfPBVdDfBT7KWUley1qo+rjzy0WYkrHpzbhGALXlj8g4K2bFmy81wblCbnHqWgjblv0FoBwUW641o9xEZtw= ECDSA test
|
7
regress/unittests/sshsig/testdata/ecdsa.sig
vendored
Normal file
7
regress/unittests/sshsig/testdata/ecdsa.sig
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
-----BEGIN SSH SIGNATURE-----
|
||||
U1NIU0lHAAAAAQAAAGgAAAATZWNkc2Etc2hhMi1uaXN0cDI1NgAAAAhuaXN0cDI1NgAAAE
|
||||
EE3sud88FV0N8FPspZSV7LWqj6uPPLRZiSsenNuEYAteWPyDgrZsWbLzXBuUJucepaCNuW
|
||||
/QWgHBRbrjWj3ERm3AAAAAh1bml0dGVzdAAAAAAAAAAGc2hhNTEyAAAAZQAAABNlY2RzYS
|
||||
1zaGEyLW5pc3RwMjU2AAAASgAAACEAycVNsTlE+XEZYyYiDxWZlliruf/pPMhEEMR/XLdQ
|
||||
a4MAAAAhALQt+5gES7L3uKGptHB6UZQMuZ2WyI0C6FJs4v6AtMIU
|
||||
-----END SSH SIGNATURE-----
|
13
regress/unittests/sshsig/testdata/ecdsa_sk
vendored
Normal file
13
regress/unittests/sshsig/testdata/ecdsa_sk
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAfwAAACJzay1lY2
|
||||
RzYS1zaGEyLW5pc3RwMjU2QG9wZW5zc2guY29tAAAACG5pc3RwMjU2AAAAQQSg1WuY0XE+
|
||||
VexOsrJsFYuxyVoe6eQ/oXmyz2pEHKZw9moyWehv+Fs7oZWFp3JVmOtybKQ6dvfUZYauQE
|
||||
/Ov4PAAAAABHNzaDoAAAGI6iV41+oleNcAAAAic2stZWNkc2Etc2hhMi1uaXN0cDI1NkBv
|
||||
cGVuc3NoLmNvbQAAAAhuaXN0cDI1NgAAAEEEoNVrmNFxPlXsTrKybBWLsclaHunkP6F5ss
|
||||
9qRBymcPZqMlnob/hbO6GVhadyVZjrcmykOnb31GWGrkBPzr+DwAAAAARzc2g6AQAAAOMt
|
||||
LS0tLUJFR0lOIEVDIFBSSVZBVEUgS0VZLS0tLS0KTUhjQ0FRRUVJQm9oeW54M2tpTFVEeS
|
||||
t5UjU3WXBXSU5KektnU1p6WnV2VTljYXFla3JGcW9Bb0dDQ3FHU000OQpBd0VIb1VRRFFn
|
||||
QUVvTlZybU5GeFBsWHNUckt5YkJXTHNjbGFIdW5rUDZGNXNzOXFSQnltY1BacU1sbm9iL2
|
||||
hiCk82R1ZoYWR5VlpqcmNteWtPbmIzMUdXR3JrQlB6citEd0E9PQotLS0tLUVORCBFQyBQ
|
||||
UklWQVRFIEtFWS0tLS0tCgAAAAAAAAARRUNEU0EtU0sgdGVzdCBrZXk=
|
||||
-----END OPENSSH PRIVATE KEY-----
|
1
regress/unittests/sshsig/testdata/ecdsa_sk.pub
vendored
Normal file
1
regress/unittests/sshsig/testdata/ecdsa_sk.pub
vendored
Normal file
@ -0,0 +1 @@
|
||||
sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20AAAAIbmlzdHAyNTYAAABBBKDVa5jRcT5V7E6ysmwVi7HJWh7p5D+hebLPakQcpnD2ajJZ6G/4WzuhlYWnclWY63JspDp299Rlhq5AT86/g8AAAAAEc3NoOg== ECDSA-SK test key
|
8
regress/unittests/sshsig/testdata/ecdsa_sk.sig
vendored
Normal file
8
regress/unittests/sshsig/testdata/ecdsa_sk.sig
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
-----BEGIN SSH SIGNATURE-----
|
||||
U1NIU0lHAAAAAQAAAH8AAAAic2stZWNkc2Etc2hhMi1uaXN0cDI1NkBvcGVuc3NoLmNvbQ
|
||||
AAAAhuaXN0cDI1NgAAAEEEoNVrmNFxPlXsTrKybBWLsclaHunkP6F5ss9qRBymcPZqMlno
|
||||
b/hbO6GVhadyVZjrcmykOnb31GWGrkBPzr+DwAAAAARzc2g6AAAACHVuaXR0ZXN0AAAAAA
|
||||
AAAAZzaGE1MTIAAAB3AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20A
|
||||
AABIAAAAIHohGwyy8iKT3zwd1TYA9V/Ioo7h/3zCJUtyq/Qigt/HAAAAIGzidTwq7D/kFa
|
||||
7Xjcp/KkdbIs4MfQpfAW/0OciajlpzARI0Vng=
|
||||
-----END SSH SIGNATURE-----
|
7
regress/unittests/sshsig/testdata/ed25519
vendored
Normal file
7
regress/unittests/sshsig/testdata/ed25519
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
QyNTUxOQAAACCJYs0iDdw0Fe/FTzY1b78I4H/j+R6mz2AmLtwTjHYwBAAAAJjpGas/6Rmr
|
||||
PwAAAAtzc2gtZWQyNTUxOQAAACCJYs0iDdw0Fe/FTzY1b78I4H/j+R6mz2AmLtwTjHYwBA
|
||||
AAAEDpSKRA1QKW6kYiQftGRWh+H0fNekzYLG6c3bzseoCpEolizSIN3DQV78VPNjVvvwjg
|
||||
f+P5HqbPYCYu3BOMdjAEAAAAEEVEMjU1MTkgdGVzdCBrZXkBAgMEBQ==
|
||||
-----END OPENSSH PRIVATE KEY-----
|
1
regress/unittests/sshsig/testdata/ed25519.pub
vendored
Normal file
1
regress/unittests/sshsig/testdata/ed25519.pub
vendored
Normal file
@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIlizSIN3DQV78VPNjVvvwjgf+P5HqbPYCYu3BOMdjAE ED25519 test key
|
6
regress/unittests/sshsig/testdata/ed25519.sig
vendored
Normal file
6
regress/unittests/sshsig/testdata/ed25519.sig
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
-----BEGIN SSH SIGNATURE-----
|
||||
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgiWLNIg3cNBXvxU82NW+/COB/4/
|
||||
keps9gJi7cE4x2MAQAAAAIdW5pdHRlc3QAAAAAAAAABnNoYTUxMgAAAFMAAAALc3NoLWVk
|
||||
MjU1MTkAAABAihQsbUzuNEFflk5Tw1+H9aLS7tZQk0RG8KW1DtOmDYYnWe3D3UKiG3fcJa
|
||||
DNg4vBWp1j1gLRiBMOF+gwYNegDg==
|
||||
-----END SSH SIGNATURE-----
|
8
regress/unittests/sshsig/testdata/ed25519_sk
vendored
Normal file
8
regress/unittests/sshsig/testdata/ed25519_sk
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAASgAAABpzay1zc2
|
||||
gtZWQyNTUxOUBvcGVuc3NoLmNvbQAAACCbGg2F0GK7nOm4pQmAyCuGEjnhvs5q0TtjPbdN
|
||||
//+yxwAAAARzc2g6AAAAuBw56jAcOeowAAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY2
|
||||
9tAAAAIJsaDYXQYruc6bilCYDIK4YSOeG+zmrRO2M9t03//7LHAAAABHNzaDoBAAAAQFXc
|
||||
6dCwWewIk1EBofAouGZApW8+s0XekXenxtb78+x0mxoNhdBiu5zpuKUJgMgrhhI54b7Oat
|
||||
E7Yz23Tf//sscAAAAAAAAAE0VEMjU1MTktU0sgdGVzdCBrZXkBAgMEBQY=
|
||||
-----END OPENSSH PRIVATE KEY-----
|
1
regress/unittests/sshsig/testdata/ed25519_sk.pub
vendored
Normal file
1
regress/unittests/sshsig/testdata/ed25519_sk.pub
vendored
Normal file
@ -0,0 +1 @@
|
||||
sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIJsaDYXQYruc6bilCYDIK4YSOeG+zmrRO2M9t03//7LHAAAABHNzaDo= ED25519-SK test key
|
7
regress/unittests/sshsig/testdata/ed25519_sk.sig
vendored
Normal file
7
regress/unittests/sshsig/testdata/ed25519_sk.sig
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
-----BEGIN SSH SIGNATURE-----
|
||||
U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgmxoNhd
|
||||
Biu5zpuKUJgMgrhhI54b7OatE7Yz23Tf//sscAAAAEc3NoOgAAAAh1bml0dGVzdAAAAAAA
|
||||
AAAGc2hhNTEyAAAAZwAAABpzay1zc2gtZWQyNTUxOUBvcGVuc3NoLmNvbQAAAEAi+7eTjW
|
||||
/+LQ2M+sCD+KFtH1n7VFFJon/SZFsxODyV8cWTlFKj617Ys1Ur5TV6uaEXQhck8rBA2oQI
|
||||
HTPANLIPARI0Vng=
|
||||
-----END SSH SIGNATURE-----
|
1
regress/unittests/sshsig/testdata/namespace
vendored
Normal file
1
regress/unittests/sshsig/testdata/namespace
vendored
Normal file
@ -0,0 +1 @@
|
||||
unittest
|
39
regress/unittests/sshsig/testdata/rsa
vendored
Normal file
39
regress/unittests/sshsig/testdata/rsa
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIG4wIBAAKCAYEA386lmjRHtJpyj87BrS+ssMmtvc/1SPN0gXTPs9jZ1hYAq98P
|
||||
ca3/RYVM4HaSu6COztQJ2ZnZD3Te/XeBnIU2mfuvQEl+DiwisGeNglVyRCi7787f
|
||||
PFFfcxzZfDa7EB2qY8S3oaSGZK8QqzuGwmGAImjlQXz6J+HCd/eD/58GoCSSirIE
|
||||
CFWCAt+uNrOC/EmgAzsbfcfaIbbVzA40tlgU3hO2J42kddz8CisDTtDKQABFcOaQ
|
||||
ZycSfn7HDP+WgXLXXBUI9wVM1Tif1f+9MX08xIsvCvGzo7yLgbbTFLSGr5SkA+tO
|
||||
rYuoA7V8fge0id/3pnVtG1Ui3I7vejeAwf0HZqtFeBEnOwkIJFmZeMtFeOVf+4ki
|
||||
4h1rDqAvSscN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E KEY-----
|
1
regress/unittests/sshsig/testdata/rsa.pub
vendored
Normal file
1
regress/unittests/sshsig/testdata/rsa.pub
vendored
Normal file
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDfzqWaNEe0mnKPzsGtL6ywya29z/VI83SBdM+z2NnWFgCr3w9xrf9FhUzgdpK7oI7O1AnZmdkPdN79d4GchTaZ+69ASX4OLCKwZ42CVXJEKLvvzt88UV9zHNl8NrsQHapjxLehpIZkrxCrO4bCYYAiaOVBfPon4cJ394P/nwagJJKKsgQIVYIC3642s4L8SaADOxt9x9ohttXMDjS2WBTeE7YnjaR13PwKKwNO0MpAAEVw5pBnJxJ+fscM/5aBctdcFQj3BUzVOJ/V/70xfTzEiy8K8bOjvIuBttMUtIavlKQD606ti6gDtXx+B7SJ3/emdW0bVSLcju96N4DB/Qdmq0V4ESc7CQgkWZl4y0V45V/7iSLiHWsOoC9Kxw28y0uno5elsABMBMC4RYSQhAGXWueCcR7SIL2JT2K0oxbqongW0hvgAIfUShTXHy+qsV5yDaG+p+TkJkEkhtXbwkW4aNpzc7EFnXsWpvyWOiZSKvUasRPbPro0yBvlOMMPsFU= RSA test
|
19
regress/unittests/sshsig/testdata/rsa.sig
vendored
Normal file
19
regress/unittests/sshsig/testdata/rsa.sig
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
-----BEGIN SSH SIGNATURE-----
|
||||
U1NIU0lHAAAAAQAAAZcAAAAHc3NoLXJzYQAAAAMBAAEAAAGBAN/OpZo0R7Saco/Owa0vrL
|
||||
DJrb3P9UjzdIF0z7PY2dYWAKvfD3Gt/0WFTOB2krugjs7UCdmZ2Q903v13gZyFNpn7r0BJ
|
||||
fg4sIrBnjYJVckQou+/O3zxRX3Mc2Xw2uxAdqmPEt6GkhmSvEKs7hsJhgCJo5UF8+ifhwn
|
||||
f3g/+fBqAkkoqyBAhVggLfrjazgvxJoAM7G33H2iG21cwONLZYFN4TtieNpHXc/AorA07Q
|
||||
ykAARXDmkGcnEn5+xwz/loFy11wVCPcFTNU4n9X/vTF9PMSLLwrxs6O8i4G20xS0hq+UpA
|
||||
PrTq2LqAO1fH4HtInf96Z1bRtVItyO73o3gMH9B2arRXgRJzsJCCRZmXjLRXjlX/uJIuId
|
||||
aw6gL0rHDbzLS6ejl6WwAEwEwLhFhJCEAZda54JxHtIgvYlPYrSjFuqieBbSG+AAh9RKFN
|
||||
cfL6qxXnINob6n5OQmQSSG1dvCRbho2nNzsQWdexam/JY6JlIq9RqxE9s+ujTIG+U4ww+w
|
||||
VQAAAAh1bml0dGVzdAAAAAAAAAAGc2hhNTEyAAABlAAAAAxyc2Etc2hhMi01MTIAAAGACi
|
||||
nEpBrQxZi0yOrrT6h98JFfZh0XXioih4fzmvtoV0yOReWClS+otGgXoJyZHcbaKNOjDwSM
|
||||
rIkUoX6OUJmtHYP0HRELnKw35m33LdBPXpFGS4tRS7NeSpvc04KtjT6jYXY9FjWy5hcn17
|
||||
Sxc/3DnJqLgJBur8acY7FeIzpWmKixPd/dGkEjdWoD9gO6szLczGuQgrOdYmSRL4yKadTJ
|
||||
lVjz5OSeKSYYGQy33US2XQassRRNYf4e9byTA3DKvHa/OcTt7lFerea0kZdDpAboqffz7T
|
||||
Yaw/hFskAYLIEdTW3aoXBGHSOvu8AkDOtb7qwuxGSQ27pjkDLDNsp1ceCFaCaQ6X83RZuK
|
||||
ACv9JUBI5KaSf81e0bs0KezJKkhB9czeZ6dk96qISbgayEBnvhYgXvUDKtHn7HzNlCJKfK
|
||||
5ABhNxfGG2CD+NKqcrndwFgS1sQO3hbA84zPQb26ShBovT8ytHBmW1F8ZK4O9Bz61Q6EZK
|
||||
vs/u6xP6LUean/so5daa
|
||||
-----END SSH SIGNATURE-----
|
1
regress/unittests/sshsig/testdata/signed-data
vendored
Normal file
1
regress/unittests/sshsig/testdata/signed-data
vendored
Normal file
@ -0,0 +1 @@
|
||||
This is a test, this is only a test
|
120
regress/unittests/sshsig/tests.c
Normal file
120
regress/unittests/sshsig/tests.c
Normal file
@ -0,0 +1,120 @@
|
||||
/* $OpenBSD: tests.c,v 1.1 2020/06/19 04:32:09 djm Exp $ */
|
||||
/*
|
||||
* Regress test for sshbuf.h buffer API
|
||||
*
|
||||
* Placed in the public domain
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#include "ssherr.h"
|
||||
#include "authfile.h"
|
||||
#include "sshkey.h"
|
||||
#include "sshbuf.h"
|
||||
#include "sshsig.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "test_helper.h"
|
||||
|
||||
static struct sshbuf *
|
||||
load_file(const char *name)
|
||||
{
|
||||
struct sshbuf *ret = NULL;
|
||||
|
||||
ASSERT_INT_EQ(sshbuf_load_file(test_data_file(name), &ret), 0);
|
||||
ASSERT_PTR_NE(ret, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct sshkey *
|
||||
load_key(const char *name)
|
||||
{
|
||||
struct sshkey *ret = NULL;
|
||||
ASSERT_INT_EQ(sshkey_load_public(test_data_file(name), &ret, NULL), 0);
|
||||
ASSERT_PTR_NE(ret, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
check_sig(const char *keyname, const char *signame, const struct sshbuf *msg,
|
||||
const char *namespace)
|
||||
{
|
||||
struct sshkey *k, *sign_key;
|
||||
struct sshbuf *sig, *rawsig;
|
||||
struct sshkey_sig_details *sig_details;
|
||||
|
||||
k = load_key(keyname);
|
||||
sig = load_file(signame);
|
||||
sign_key = NULL;
|
||||
sig_details = NULL;
|
||||
rawsig = NULL;
|
||||
ASSERT_INT_EQ(sshsig_dearmor(sig, &rawsig), 0);
|
||||
ASSERT_INT_EQ(sshsig_verifyb(rawsig, msg, namespace,
|
||||
&sign_key, &sig_details), 0);
|
||||
ASSERT_INT_EQ(sshkey_equal(k, sign_key), 1);
|
||||
sshkey_free(k);
|
||||
sshkey_free(sign_key);
|
||||
sshkey_sig_details_free(sig_details);
|
||||
sshbuf_free(sig);
|
||||
sshbuf_free(rawsig);
|
||||
}
|
||||
|
||||
void
|
||||
tests(void)
|
||||
{
|
||||
struct sshbuf *msg;
|
||||
char *namespace;
|
||||
|
||||
#if 0
|
||||
log_init("test_sshsig", SYSLOG_LEVEL_DEBUG3, SYSLOG_FACILITY_AUTH, 1);
|
||||
#endif
|
||||
|
||||
OpenSSL_add_all_algorithms();
|
||||
ERR_load_CRYPTO_strings();
|
||||
|
||||
TEST_START("load data");
|
||||
msg = load_file("namespace");
|
||||
namespace = sshbuf_dup_string(msg);
|
||||
ASSERT_PTR_NE(namespace, NULL);
|
||||
sshbuf_free(msg);
|
||||
msg = load_file("signed-data");
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("check RSA signature");
|
||||
check_sig("rsa", "rsa.sig", msg, namespace);
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("check DSA signature");
|
||||
check_sig("dsa", "dsa.sig", msg, namespace);
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("check ECDSA signature");
|
||||
check_sig("ecdsa", "ecdsa.sig", msg, namespace);
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("check ED25519 signature");
|
||||
check_sig("ed25519", "ed25519.sig", msg, namespace);
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("check ECDSA-SK signature");
|
||||
check_sig("ecdsa_sk", "ecdsa_sk.sig", msg, namespace);
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("check ED25519-SK signature");
|
||||
check_sig("ed25519_sk", "ed25519_sk.sig", msg, namespace);
|
||||
TEST_DONE();
|
||||
|
||||
sshbuf_free(msg);
|
||||
free(namespace);
|
||||
}
|
Loading…
Reference in New Issue
Block a user