]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - tcl_tests/nopath.try
c3664ae5f1fd764c8e2c955de2c13f03f47da3a5
[openssl-gost/engine.git] / tcl_tests / nopath.try
1 #!/usr/bin/tclsh
2 # -*- coding: cp1251 -*-
3 lappend auto_path [file dirname [info script]]
4 package require ossltest
5 cd $::test::dir
6 start_tests "Подгрузка engine без явно указанного dynamic_path"
7
8 set config [getConfig]
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
12 }
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"
18 }
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"
23
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"
28         file isfile enc.enc
29 } 0 1
30
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"
34         file isfile cnt.enc
35 } 0 1
36
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
40 } 0 -1
41
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
45 } 0 -1
46
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"
49         getFile enc.dec 
50 } 0 $plain
51
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"
54         getFile cnt.dec 
55 } 0 $plain
56
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"
60
61 test -platformex {[info exists path]} -createsfiles nodp2001.key "Создание секретного ключа gost2001" {
62         makeSecretKey nodp2001 gost2001:A
63         file exists nodp2001/seckey.pem
64 } 0 1   
65
66
67 file delete cryptocom.lic
68 end_tests