2 lappend auto_path [file dirname [info script]]
3 package require ossltest
5 start_tests "Подгрузка engine без явно указанного dynamic_path"
8 regexp {\ndynamic_path\s*=\s*(\S[^\n]+)} $config => path
9 if [file exist [file join [file dirname $::OPENSSL_CONF] cryptocom.lic]] {
10 file copy -force [file join [file dirname $::OPENSSL_CONF] cryptocom.lic] cryptocom.lic
12 if {[info exists path]} {
13 set env(OPENSSL_ENGINES) [subst -nocommands -nobackslashes [regsub {\$ENV::(\w+)} [file dirname $path] {$env(\1)}]]
14 puts $env(OPENSSL_ENGINES)
15 makeFile nodp.conf [regsub {\ndynamic_path\s*=\s*([^\n]+)} $config {}]
16 set env(OPENSSL_CONF) "[pwd]/nodp.conf"
18 test -platformex {[info exists path]} -createsfiles dgst.dat "Вычисление дайджеста md_gost94" {
19 makeFile dgst.dat [string repeat "Test data to digest.\n" 100] binary
20 grep "md_gost94\\(" [openssl "dgst -md_gost94 dgst.dat"]
21 } 0 "md_gost94\(dgst.dat)= 42e462ce1c2b4bf72a4815b7b4877c601f05e5781a71eaa36f63f836c021865c\n"
23 set plain "Test data to encrypt"
24 test -platformex {[info exists path]} -createsfiles {enc.enc enc.dat} "Encrypting file in CFB mode" {
25 makeFile enc.dat $plain binary
26 openssl "enc -gost89 -out enc.enc -in enc.dat -k 1234567890 -p"
30 test -platformex {[info exists path]} -createsfiles {cnt.enc} "Encrypting file in CNT mode" {
31 makeFile enc.dat $plain binary
32 openssl "enc -gost89-cnt -out cnt.enc -in enc.dat -k 1234567890 -p"
36 test -platformex {[info exists path]} -skip {![file exists enc.enc]} "Ciphered text in CFB mode differs from clear text" {
37 set ciphered [getFile enc.enc binary]
38 string first $ciphered $plain
41 test -platformex {[info exists path]} -skip {![file exists cnt.enc]} "Ciphered text in CNT mode differs from clear text" {
42 set ciphered [getFile cnt.enc binary]
43 string first $ciphered $plain
46 test -platformex {[info exists path]} -skip {![file exists enc.enc]} -createsfiles enc.dec "Decrypting file, encrypted in CFB mode" {
47 openssl "enc -gost89 -d -in enc.enc -out enc.dec -k 1234567890 -p"
51 test -platformex {[info exists path]} -skip {![file exists cnt.enc]} -createsfiles cnt.dec "Decrypting file, encrypted in CNT mode" {
52 openssl "enc -gost89-cnt -d -in cnt.enc -out cnt.dec -k 1234567890 -p"
56 test -platformex {[info exists path]} "Вычисление MAC gost89" {
57 grep gost-mac [openssl "dgst -mac gost-mac -macopt key:12345678901234567890123456789012 dgst.dat"]
58 } 0 "GOST-MAC-gost-mac(dgst.dat)= 37f646d2\n"
60 test -platformex {[info exists path]} -createsfiles nodp2001.key "Создание секретного ключа gost2001" {
61 makeSecretKey nodp2001 gost2001:A
62 file exists nodp2001/seckey.pem
66 file delete cryptocom.lic