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