]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - tcl_tests/nopath.try
tcl_tests: ca.try: Ignore openssl crl exit status for 'corrupted CRL' test
[openssl-gost/engine.git] / tcl_tests / nopath.try
1 #!/usr/bin/tclsh
2 lappend auto_path [file dirname [info script]]
3 package require ossltest
4 cd $::test::dir
5 start_tests "Подгрузка engine без явно указанного dynamic_path"
6
7 set config [getConfig]
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
11 }
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"
17 }
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"
22
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"
27         file isfile enc.enc
28 } 0 1
29
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"
33         file isfile cnt.enc
34 } 0 1
35
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
39 } 0 -1
40
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
44 } 0 -1
45
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"
48         getFile enc.dec 
49 } 0 $plain
50
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"
53         getFile cnt.dec 
54 } 0 $plain
55
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"
59
60 test -platformex {[info exists path]} -createsfiles nodp2001.key "Создание секретного ключа gost2001" {
61         makeSecretKey nodp2001 gost2001:A
62         file exists nodp2001/seckey.pem
63 } 0 1   
64
65
66 file delete cryptocom.lic
67 end_tests