2 lappend auto_path [file dirname [info script]]
3 package require ossltest
5 set testname [file rootname [file tail $::argv0]]
7 start_tests "Тесты на совместимость smime и cms -encrypt"
9 return [string map {":" "_"} $alg]
15 lappend result [subst $str]
20 if {![info exist env(NO_RSA)]} {
22 test -createsfiles io_decrypt.rsa "RSA User 2 (with cert) can decrypt message for RSA user 2" {
23 set expected [getFile encrypt.dat]
24 openssl "cms -decrypt -in enc_rsa.msg -recip U_enc_rsa_2/cert.pem -inkey U_enc_rsa_2/seckey.pem -out io_decrypt.rsa"
25 set result [getFile io_decrypt.rsa]
26 string eq $expected $result
29 test -createsfiles io_decrypt_nocert.rsa "RSA User 2 (without cert) can decrypt message for RSA user 2" {
30 set expected [getFile encrypt.dat]
31 openssl "cms -decrypt -in enc_rsa.msg -inkey U_enc_rsa_2/seckey.pem -out io_decrypt_nocert.rsa"
32 set result [getFile io_decrypt_nocert.rsa]
33 string eq $expected $result
37 if {[info exist env(ENC_LIST)]} {
38 set enc_list $env(ENC_LIST)
40 switch -exact [engine_name] {
41 "ccore" {set enc_list {gost2001:XA:1.2.643.2.2.31.3 gost2001:XB:1.2.643.2.2.31.4 gost2001:XA: gost2012_256:XA:1.2.643.2.2.31.1 gost2012_256:XB:1.2.643.7.1.2.5.1.1 gost2012_256:XA: gost2012_512:A:1.2.643.2.2.31.3 gost2012_512:B:1.2.643.7.1.2.5.1.1 gost2012_512:A:}}
42 "open" {set enc_list {gost2001:XA:1.2.643.2.2.31.3 gost2001:XB:1.2.643.2.2.31.4 gost2012_256:XA:1.2.643.2.2.31.1 gost2012_256:XB:1.2.643.7.1.2.5.1.1 gost2012_512:A:1.2.643.2.2.31.3 gost2012_512:B:1.2.643.7.1.2.5.1.1}}
46 foreach enc_tuple $enc_list {
47 if {![regexp {^([^:]*:[^:]*):(.*)$} $enc_tuple -> alg crypt_param]} {
51 set alg_fn [make_fn $enc_tuple]
52 set username U_enc_$alg_fn
54 gost2012* {set ::test::ca ${testname}CA-2012}
55 * {set ::test::ca ${testname}CA}
58 test -createsfiles io_decrypt.$alg_fn "Decrypting file encrypted for $username" {
59 set expected [getFile encrypt.dat]
60 openssl "cms -decrypt -in enc_$alg_fn.msg -recip U_enc_$alg_fn/cert.pem -inkey U_enc_$alg_fn/seckey.pem -out io_decrypt.$alg_fn"
61 set result [getFile io_decrypt.$alg_fn]
62 string eq $expected $result
65 test -createsfiles io_decrypt_t.$alg_fn "Decrypting file text-encrypted for $username" {
66 set expected [getFile encrypt.dat]
67 openssl "cms -decrypt -text -in enc_t_$alg_fn.msg -recip U_enc_$alg_fn/cert.pem -inkey U_enc_$alg_fn/seckey.pem -out io_decrypt_t.$alg_fn"
68 set result [getFile io_decrypt_t.$alg_fn]
69 string eq $expected $result
72 test -createsfiles io_decrypt_t_nocert.$alg_fn "Decrypting file text-encrypted for $username without cert" {
73 set expected [getFile encrypt.dat]
74 openssl "cms -decrypt -text -in enc_t_$alg_fn.msg -inkey U_enc_$alg_fn/seckey.pem -out io_decrypt_t_nocert.$alg_fn"
75 set result [getFile io_decrypt_t_nocert.$alg_fn]
76 string eq $expected $result
80 foreach enc_tuple $enc_list {
81 if {![regexp {^([^:]*:[^:]*):(.*)$} $enc_tuple -> alg crypt_param]} {
85 set alg_fn [make_fn $enc_tuple]
86 set username U_enc_$alg_fn
88 test -skip {![file exists enc_4all.msg]} -createsfiles io_decrypt_4all.$alg_fn "Decrypting gost-encrypted file, recipient $alg_fn" {
89 set expected [getFile encrypt.dat]
90 openssl "cms -decrypt -in enc_4all.msg -recip $username/cert.pem -inkey $username/seckey.pem -out io_decrypt_4all.$alg_fn"
91 set result [getFile io_decrypt_4all.$alg_fn]
92 string eq $expected $result
95 test -skip {![file exists enc_4all.msg]} -createsfiles io_decrypt_4all_nocert.$alg_fn "Decrypting gost-encrypted file without cert, recipient $alg_fn" {
96 set expected [getFile encrypt.dat]
97 openssl "cms -decrypt -in enc_4all.msg -inkey $username/seckey.pem -out io_decrypt_4all_nocert.$alg_fn"
98 set result [getFile io_decrypt_4all_nocert.$alg_fn]
99 string eq $expected $result