2 lappend auto_path [file dirname [info script]]
3 package require ossltest
5 set testname [file rootname [file tail $::argv0]]
7 start_tests "Тесты на OCSP-запросы и ответы"
9 if {[info exists env(ALG_LIST)]} {
10 set alg_list $env(ALG_LIST)
12 switch -exact [engine_name] {
13 "ccore" {set alg_list {gost2001:A gost2012_256:A gost2012_512:B}}
14 "open" {set alg_list {gost2001:A gost2012_256:A gost2012_512:B}}
18 foreach alg $alg_list {
19 set alg_fn [string map {":" "_"} $alg]
20 set username U_smime_$alg_fn
23 makeCA ${testname}CA-$alg_fn $alg
28 set server_args "-index $::test::ca/index.txt -rsigner $::test::ca/cacert.pem -rkey $::test::ca/private/cakey.pem -CA $::test::ca/cacert.pem -noverify"
29 set client_args "-issuer $::test::ca/cacert.pem -CAfile $::test::ca/cacert.pem"
31 test "Создаем юзера" {
32 makeRegisteredUser U_ocsp_$alg_fn $alg
33 makeRegisteredUser U_ocsp2_$alg_fn $alg
34 file exists U_ocsp_$alg_fn/cert.pem
39 test -createsfiles {request1.der} "Создаеем неподписанный запрос SHA1 хэш по сертификату" {
40 openssl "ocsp $client_args -cert U_ocsp_$alg_fn/cert.pem -reqout request1.der"
41 file exists request1.der
44 test -skip {![file exists request1.der]} "Анализируем OID-ы в запросе" {
45 extract_oids request1.der DER
49 test -skip {![file exists request1.der]} -createsfiles {response1.der} "Формируем ГОСТ-подписанный ответ" {
50 openssl "ocsp $server_args -reqin request1.der -respout response1.der"
53 test -skip {![file exists request1.der]} "Анализируем OID-ы в ответе" {
54 extract_oids response1.der DER 30
55 } 0 " OBJECT :sha1\n[mkObjList [hash_with_sign_long_name $alg] [hash_with_sign_long_name $alg] [alg_long_name $alg] [pubkey_long_name $alg] [param_hash_long_name [param_hash $alg]] [hash_with_sign_long_name $alg]]"
58 test -skip {![file exists response1.der]} "Проверяем ГОСТ-подписанный ответ" {
59 openssl "ocsp $client_args -respin response1.der"
61 } 0 "STDERR CONTENTS:\nResponse verify OK"
63 test -skip {![file exists response1.der]} "Проверяем статус сертификата" {
64 grep "Cert Status" [openssl "ocsp -respin response1.der -text -CAfile $::test::ca/cacert.pem"]
65 } 0 " Cert Status: good\n"
67 test -createsfiles request2.der "Формируем ГОСТ-подписанный запрос с хэшом SHA1 по сертификату" {
68 openssl "ocsp $client_args -cert U_ocsp_$alg_fn/cert.pem -signer U_ocsp_$alg_fn/cert.pem -signkey U_ocsp_$alg_fn/seckey.pem -reqout request2.der"
72 test -skip {![file exists request2.der]} "Анализируем OID-ы в запросе" {
73 extract_oids request2.der DER
74 } 0 " OBJECT :sha1\n[mkObjList [hash_with_sign_long_name $alg] [hash_with_sign_long_name $alg] [alg_long_name $alg] [pubkey_long_name $alg] [param_hash_long_name [param_hash $alg]] [hash_with_sign_long_name $alg]]"
77 test -createsfiles response2.der -skip {![file exists request2.der]} "Формируем ответ на подписанный запрос" {
78 openssl "ocsp $server_args -reqin request2.der -respout response2.der"
79 file exists response2.der
82 test -skip {![file exists response2.der]} "Проверяем ответ на запрос 2" {
83 grep "Response .erif" [openssl "ocsp $client_args -respin response2.der"]
84 } 0 "Response verify OK\n"
86 test -createsfiles request3.der "Формируем запрос с ГОСТ-овским хэшом по сертификату" {
87 openssl "ocsp $client_args -[hash_short_name [alg_hash $alg]] -cert U_ocsp_$alg_fn/cert.pem -reqout request3.der"
88 file exists request3.der
91 test -skip {![file exists request3.der]} "Анализируем OID-ы в запросе" {
92 extract_oids request3.der DER
93 } 0 [mkObjList [hash_long_name $alg]]
95 test -skip {![file exists request3.der]} -createsfiles response3.der "Формируем ответ на запрос с ГОСТ-овским хэшом" {
96 openssl "ocsp $server_args -reqin request3.der -respout response3.der"
97 file exists response3.der
100 test -skip {![file exists response3.der] } "Проверяем ответ на запрос 3" {
101 grep "Response .erif" [openssl "ocsp $client_args -respin response3.der"]
102 } 0 "Response verify OK\n"
105 test -skip {![file exists response3.der]} "Проверяем статус сертификата" {
106 grep "Cert Status" [openssl "ocsp -respin response3.der -text -CAfile $::test::ca/cacert.pem"]
107 } 0 " Cert Status: good\n"
109 test -createsfiles request4.der "Формируем запрос с ГОСТ-овским хэшом по serial" {
110 openssl "ocsp $client_args -[hash_short_name [alg_hash $alg]] -serial 0x11E -reqout request4.der"
113 test -skip {![file exists request4.der]} "Проверяем OID-ы в запросе 4" {
114 extract_oids request4.der DER
115 } 0 [mkObjList [hash_long_name $alg]]
118 test -skip {![file exists request4.der]} -createsfiles response4.der "Формируем ответ на запрос с ГОСТ-овским хэшом" {
119 openssl "ocsp $server_args -reqin request4.der -respout response4.der"
120 file exists response4.der
123 test -skip {![file exists response4.der] } "Проверяем ответ на запрос 4" {
124 grep "Response .erif" [openssl "ocsp $client_args -respin response4.der"]
125 } 0 "Response verify OK\n"
127 test -createsfiles request5.der "Формируем запрос с двумя сертификатами и разными хэшами" {
128 openssl "ocsp $client_args -[hash_short_name [alg_hash $alg]] -cert U_ocsp_$alg_fn/cert.pem -sha1 -cert U_ocsp2_$alg_fn/cert.pem -reqout request5.der"
131 test -skip {![file exists request5.der]} "Проверяем OID-ы в запросе 5" {
132 extract_oids request5.der DER
133 } 0 "[mkObjList [hash_long_name $alg]] OBJECT :sha1\n"
136 test -skip {![file exists request5.der]} -createsfiles response5.der "Формируем ответ на запрос с двумя хэшами" {
137 openssl "ocsp $server_args -reqin request5.der -respout response5.der"
138 file exists response5.der
141 test -skip {![file exists response5.der] } "Проверяем ответ на запрос 5" {
142 grep "Response .erif" [openssl "ocsp $client_args -respin response5.der"]
143 } 0 "Response verify OK\n"
145 test -skip {![file exists response5.der]} "Проверяем статус сертификатoв" {
146 grep "Cert Status" [openssl "ocsp -respin response5.der -text -CAfile $::test::ca/cacert.pem"]
147 } 0 " Cert Status: good\n Cert Status: good\n"