2 lappend auto_path [file dirname [info script]]
3 package require ossltest
5 set testname [file rootname [file tail $::argv0]]
7 start_tests "Тесты на совместимость cms и smime -encrypt"
9 return [string map {":" "_"} $alg]
15 lappend result [subst $str]
20 if {![info exist env(NO_RSA)]} {
22 test -createsfiles io_cms_decrypt.rsa "RSA User 2 (with cert) can decrypt message for RSA user 2" {
23 set expected [getFile encrypt.dat]
24 openssl "smime -decrypt -in cms_enc_rsa.msg -recip U_cms_enc_rsa_2/cert.pem -inkey U_cms_enc_rsa_2/seckey.pem -out io_cms_decrypt.rsa"
25 set result [getFile io_cms_decrypt.rsa]
26 string eq $expected $result
29 test -createsfiles io_cms_decrypt_nocert.rsa "RSA User 2 (without cert) can decrypt message for RSA user 2" {
30 set expected [getFile encrypt.dat]
31 openssl "smime -decrypt -in cms_enc_rsa.msg -inkey U_cms_enc_rsa_2/seckey.pem -out io_cms_decrypt_nocert.rsa"
32 set result [getFile io_cms_decrypt_nocert.rsa]
33 string eq $expected $result
38 if {[info exist env(ENC_LIST)]} {
39 set enc_list $env(ENC_LIST)
41 switch -exact [engine_name] {
42 "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:}}
43 "open" {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:}}
47 foreach enc_tuple $enc_list {
48 if {![regexp {^([^:]*:[^:]*):(.*)$} $enc_tuple -> alg crypt_param]} {
52 set alg_fn [make_fn $enc_tuple]
53 set username U_cms_enc_$alg_fn
55 gost2012* {set ::test::ca ${testname}CA-2012}
56 * {set ::test::ca ${testname}CA}
59 test -createsfiles io_cms_decrypt.$alg_fn "Decrypting file encrypted for $username" {
60 set expected [getFile encrypt.dat]
61 openssl "smime -decrypt -in cms_enc_$alg_fn.msg -recip U_cms_enc_$alg_fn/cert.pem -inkey U_cms_enc_$alg_fn/seckey.pem -out io_cms_decrypt.$alg_fn"
62 set result [getFile io_cms_decrypt.$alg_fn]
63 string eq $expected $result
66 test -createsfiles io_cms_decrypt_t.$alg_fn "Decrypting file text-encrypted for $username" {
67 set expected [getFile encrypt.dat]
68 openssl "smime -decrypt -text -in cms_enc_t_$alg_fn.msg -recip U_cms_enc_$alg_fn/cert.pem -inkey U_cms_enc_$alg_fn/seckey.pem -out io_cms_decrypt_t.$alg_fn"
69 set result [getFile io_cms_decrypt_t.$alg_fn]
70 string eq $expected $result
73 test -createsfiles io_cms_decrypt_t_nocert.$alg_fn "Decrypting file text-encrypted for $username without cert" {
74 set expected [getFile encrypt.dat]
75 openssl "smime -decrypt -text -in cms_enc_t_$alg_fn.msg -inkey U_cms_enc_$alg_fn/seckey.pem -out io_cms_decrypt_t_nocert.$alg_fn"
76 set result [getFile io_cms_decrypt_t_nocert.$alg_fn]
77 string eq $expected $result
83 foreach enc_tuple $enc_list {
84 if {![regexp {^([^:]*:[^:]*):(.*)$} $enc_tuple -> alg crypt_param]} {
88 set alg_fn [make_fn $enc_tuple]
89 set username U_cms_enc_$alg_fn
91 test -skip {![file exists cms_enc_4all.msg]} -createsfiles io_cms_decrypt_4all.$alg_fn "Decrypting gost-encrypted file, recipient $alg_fn" {
92 set expected [getFile encrypt.dat]
93 openssl "smime -decrypt -in cms_enc_4all.msg -recip $username/cert.pem -inkey $username/seckey.pem -out io_cms_decrypt_4all.$alg_fn"
94 set result [getFile io_cms_decrypt_4all.$alg_fn]
95 string eq $expected $result
98 test -skip {![file exists cms_enc_4all.msg]} -createsfiles io_cms_decrypt_4all_nocert.$alg_fn "Decrypting gost-encrypted file without cert, recipient $alg_fn" {
99 set expected [getFile encrypt.dat]
100 openssl "smime -decrypt -in cms_enc_4all.msg -inkey $username/seckey.pem -out io_cms_decrypt_4all_nocert.$alg_fn"
101 set result [getFile io_cms_decrypt_4all_nocert.$alg_fn]
102 string eq $expected $result