Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar AndroidTha an t-àm ann sealltainn mar a tha stòr-obrach criptografach stèidhichte air prìomh inbhean poblach cryptoarmpkcs ag obair air aon de na h-àrd-chabhsairean gluasadach, is e sin Android.

Is e am bun-bheachd a chaidh a chuir sìos nuair a bha e a’ leasachadh goireas cryptoarmpkcs gum bu chòir don neach-cleachdaidh eòlas fhaighinn air a ’char as lugha de mhì-ghoireas nuair a bhios e a’ cruthachadh agus a ’dearbhadh ainm-sgrìobhte dealanach. Sin as coireach gu bheil sinn a 'moladh a bhith a' cleachdadh tokens cryptographic mar phrìomh neach-giùlain airson teisteanas pearsanta PKCS#11 agus/no soithichean tèarainte PKCS#12. Feumar a ràdh gu bheil cleachdadh PKCS #12 ann an iomadh cùis a’ tionndadh a-mach gur e cha mhòr an aon rud a tha comasach, mar eisimpleir, nuair nach eil taic aig na h-aon tokens PKCS #11 airson àrd-ùrlaran sònraichte. Mar sin chuir sinn romhainn tòiseachadh air a’ ghoireas cryptoarmpkcs a ghluasad chun àrd-ùrlar Android le taic airson soithichean dìonta PKCS #12.

Bheir sinn fa-near sa bhad, bho chaidh am pròiseact a dhèanamh air an àrd-ùrlar C agus Tcl / Tk, nach do dh’ adhbhraich am portadh duilgheadasan bunaiteach sam bith. Chaidh seo a dhèanamh comasach le taing do theicneòlas Anndra. Le foillseachadh agus suidheachadh na h-àrainneachd Cha robh duilgheadasan ann (is e an àrainneachd obrach agam Linux - Mageia-7.0). Cha toir mi ach aon sgriobt airson a bhith a’ cleachdadh Innealan Loidhne-àithne Android (sdk-tools-linux-xxxx.zip):

#!/bin/sh
if [ $# -ne 1   ]
    then 
	echo "./InstallAndroidSDK.sh <sdk-tools-linux-xxxxxxxx.zip>"
	echo "Не указан архив или число параметров больше 1"
	exit 1
fi
if [ ! -f $1 ]
    then 
	echo "./InstallAndroidSDK.sh <sdk-tools-linux-xxxxxxxx.zip>"
	echo "архив $1 отсутствует"
	exit 1
fi
#Распаковываем SDK-TOOLS в папку tools
#unzip sdk-tools-linux-4333796.zip
unzip $1
#Создаем папку android-sdk-linux
mkdir android-sdk-linux
#Перемещвем папку tools в android-sdk-linux
mv tools android-sdk-linux
cd android-sdk-linux/tools/bin
./sdkmanager "platform-tools" "platforms;android-29"  

Is e an rud as iongantaiche gu bheil àrainneachd Androwish a’ toirt a-steach dà eadar-theangair, undrowish-xxx agus vanillawish-xxx, a tha gu tur co-ionann ann an sgrìobhadh ris na “balalaikas” (pasganan) a tha air an toirt a-steach do Androwish fhèin. Is e an eadar-dhealachadh eadar undrowish agus vanillawish gu bheil backend stèidhichte air SDL / AGG / freetype aig vanillawish:

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

Leigidh làthaireachd an dà ghoireas seo dhut tagradh a leasachadh gun a bhith a’ cleachdadh Android fhèin agus an emuladair aige leis an tuairmse as motha air inneal fìor. An toiseach, is e seo, gu dearbh, undroidwish-xxx.

Tha am pasgan gnàthaichte fìor airson Android air a thogail ann an àrainneachd AWSDK. Bu chòir do chraobh pròiseict a ghluasad chun phasgan ~/AWSDK/assets/app. Anns a 'chùis seo, feumaidh prìomh mhodal a' phròiseict agad a bhith air ath-ainmeachadh gu main.tcl. Ma chleachdas tu balalaikas a bharrachd le leabharlannan fiùghantach, feumaidh na leabharlannan a bhith air an cur anns na pasganan ~/AWSDK/libs/x86 airson an emuladair agus ~/AWSDK/libs/armeabi airson an fhìor inneal.

Às deidh seo, dìreach ruith an àithne:

$wish ~/AWSDK/tools/bones

agus lean an stiùireadh aice:

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

Bidh am pasgan apk cruinnichte suidhichte anns a’ phasgan ~/AWSDK/build/outputs/apk.

Ma tha fìor inneal no emuladair agad ceangailte, faodar am pasgan a chuir a-steach sa bhad.
Anns a 'chùis seo, feumaidh an inneal fìor a bhith ann am modh deasbaid.

Ach leig sinn air ais chun tagradh fhèin. Dè dh'fheumadh a bhith air atharrachadh ann?

Gu nàdarra, tha na h-atharrachaidhean gu sònraichte co-cheangailte ri meud an sgrion. B’ fheudar dhomh am prìomh (uinneag tòiseachaidh) ath-dhealbhadh. Mar thoradh air an sin, an àite aon uinneag air coimpiutair àbhaisteach:

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

Nochd trì uinneagan air Android:

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

Tha a’ chiad uinneag fiosrachaidh. Gu traidiseanta, tha e air a roinn ann an grunn phàirtean. Anns a 'chiad phàirt, a tha suidhichte aig a' mhullach, tha ainm a 'ghoireis agus an suaicheantas aige.

An ath rud thig suaicheantas an neach-dèanamh, duilleag fiosrachaidh agus trì putanan a’ lìonadh na duilleige.
Tha an duilleag air a sgrìobhadh a’ cleachdadh a’ cho-phàirt canabhas. Bidh an duilleag a 'cleachdadh dà sheòrsa phutan: aon ann an cruth ceart-cheàrnach gluasaid (meadhan), agus an dà eile ann an cruth ceart-cheàrnach le oiseanan cruinn. Chaidh balalaika a chleachdadh gus putanan a chruthachadh le oiseanan cruinn tk slighe. Gu pearsanta, thug am balalaika seo deagh bheachd orm. Gu nàdarra, nuair a bhios tu ag obair le canabhas, bidh geoimeatraidh a 'gabhail a-steach roinn an leòmhann den chòd. Gu h-ìosal tha an sgriobt create_titul_page.tcl gus a’ chiad duilleag den tagradh a chruthachadh. Faodaidh duine sam bith a dheasachadh a rèir an lèirsinn fhèin.

Sgriobt create_titul_page.tcl

package require Tk
package require tkpath 0.3.0
global mydir
set mydir [file dirname [info script]]
#Грузим картинки
#Логотип продукта
image create photo logo_product -file [file join $mydir "imageme" "validcertkey_51x24.png"] 
#Логотип производителя
image create photo logo_orel -file [file join $mydir "imageme" "я_орел_425x200.png"] -format "png -alpha 1.0"
#Андроида с tcl/tk
image create photo logo_and -file [file join $mydir "imageme" "AndTk_inv_147x173.png"] -format "png -alpha 1.0"
#Свиток опечатанный
image create photo svitok -file [file join $mydir "imageme" "blue_svitok.png"] -format "png -alpha 1.0"
#Плитка
image create photo tileand -file [file join $mydir "imageme" "tile_green_and_32x32.png"] -format "png -alpha 1.0"
#Увеличить/уменьшить (отрицательное значение - уменьшение)
proc scaleImage {im xfactor {yfactor 0}} {
set mode -subsample
if {$xfactor>=0 && $yfactor>=0} {
set mode -zoom
} else {
set xfactor [expr $xfactor * -1]
}
if {$yfactor == 0} {set yfactor $xfactor}
set t [image create photo]
$t copy $im
$im blank
$im copy $t -shrink $mode $xfactor $yfactor
image delete $t
}
proc createtile {w  backg} {
image create photo tiled
tiled copy $backg -to 0 0 $::scrwidth $::scrheight -shrink
$backg copy tiled
image delete tiled
# Мостим холст
$w create image 0 0  
-image $backg  
-anchor nw
}
proc create_rectangle  {canv img x1 y1 x2 y2 color alfa {wbd 0} {colorline black} } {
image create photo $img -format "default -colorformat  rgb"
set rgb1 [winfo rgb $canv $color]
set cr  [lindex $rgb1 0]
set cg  [lindex $rgb1 1]
set cb  [lindex $rgb1 2]
set fill [format "#%04x%04x%04x" $cr $cg $cb ]
#Создаем цветной праямоугольник
$img put $fill -to 0 0 [expr {$x2 - $x1}] [expr {$y2 -$y1}]
#Сохраняем картинку
set dimg [$img data -format png]
#Создаем image с учетом alpha канала
image create photo $img -data $dimg -format "png -alpha $alfa"
#    $img put [list $rgb1] -to 0 0 [expr {$x2 - $x1}] [expr {$y2 -$y1}]
#Отображаем цветной прямоугольник
set imgr [$canv create image $x1 $y1 -image $img -anchor nw] 
set cc [subst {butImg $img}]
$canv bind $imgr <ButtonPress-1> $cc
#Оконтовка вокруг цветного прямоугольника
if {$wbd > 0 } {
set item [$canv create rect $x1 $y1 $x2 $y2 -outline $colorline -width $wbd ]
$canv bind $item <ButtonPress-1> $cc
}
return $imgr
}
proc butImg {img} {
tk_messageBox -title "Кнопка" -icon info -message "Нажали кнопку=$img" -detail "::screenwidth=$::scrwidthn::screenheight=$::scrheight" -parent .
if {$img == "exit"} {
set answer [tk_dialog .dialog2 "Конец работы" "Вы действительноnхотите выйти?" question 0 "Да" "Нет" ]
if {$answer == 0} {
exit
}	
}
}
proc page_titul {fr  logo_manufacturer} {
global mydir
#Создаем холст на весь экран
tkp::canvas $fr.can -borderwidth 0 -height [winfo screenheight .] -width [winfo screenwidth .] -relief flat
#Мостим холст плиткой 
createtile "$fr.can"  "tileand"
pack $fr.can  -anchor center -expand 1 -fill both -side top  -padx 0 -pady 0
#Вычисляем координаты для логотипа производителя
#update чтобы обновилась информация в БД об окнах
update
#    set aa [winfo height $fr.labtitul]
set aa $::padly
#Центрируем логотип разработчика
set ha [image width $logo_manufacturer]
set xman [expr {($::scrwidth - $ha) / 2 }]
$fr.can create image $xman $aa -image $logo_manufacturer -anchor nw -tag tag_logo
set blogo [$fr.can bbox tag_logo]
set wexit [lindex $blogo 3]
if {$::typetlf } {
set dlx [expr {$::padlx / 1}]
$fr.can create text [expr $dlx + 6] [expr {$wexit + $::padly + 6}] -anchor nw -text "Электронная подпись" -fill black -font {{Roboto Condensed Medium} 15 }
$fr.can create text $dlx [expr {$wexit + $::padly}] -anchor nw -text "Электронная подпись" -fill white -font {{Roboto Condensed Medium} 15 } -tag id_text0
update
set blogo [$fr.can bbox id_text0]
set wexit [lindex $blogo 3]
$fr.can create text [expr $dlx + 4] [expr {$wexit + $::padly + 4 - 80}] -anchor nw -text "для платформы Android" -fill black -font {{Roboto Condensed Medium} 13}
$fr.can create text $dlx [expr {$wexit + $::padly - 80}] -anchor nw -text "для платформы Android" -fill white -font {{Roboto Condensed Medium} 13} -tag id_text1
set blogo [$fr.can bbox id_text1]
set wexit [lindex $blogo 3]
$fr.can create text [expr $dlx + 3] [expr {$wexit + $::padly + 3 - 50}] -anchor nw -text "№ 63 ФЗ "Об электроннойnподписи от 6 апреля 2011 года"" -fill black -font {{Roboto} 10}
$fr.can create text $dlx [expr {$wexit + $::padly - 50}] -anchor nw -text "№ 63 ФЗ "Об электроннойnподписи от 6 апреля 2011 года"" -fill white -font {{Roboto} 10} -tag id_text2
set blogo [$fr.can bbox id_text2]
set wexit [lindex $blogo 3]
$fr.can create text [expr $dlx + 2] [expr {$wexit + $::padly + 2 - 40}] -text "Авторы: В.Н. Орловnhttp://soft.lissi.ru, http://www.lissi.run+7(495)589-99-53ne-mail: [email protected]" 
-anchor nw -fill black  -font {{Roboto} 9}
$fr.can create text $dlx [expr {$wexit + $::padly - 40}] -text "Авторы: В.Н. Орловnhttp://soft.lissi.ru, http://www.lissi.run+7(495)589-99-53ne-mail: [email protected]" 
-anchor nw -fill white -tag id_text3  -font {{Roboto} 9}
} else {
$fr.can create text [expr $::padlx + 2] [expr {$wexit + $::padly + 2}] -anchor nw -text "Электронная подпись" -fill black -font {{Nimbus Sans Narrow} 20}
$fr.can create text $::padlx [expr {$wexit + $::padly}] -anchor nw -text "Электронная подпись" -fill white -font {{Nimbus Sans Narrow} 20} -tag id_text0
set blogo [$fr.can bbox id_text0]
set wexit [lindex $blogo 3]
$fr.can create text [expr $::padlx + 2] [expr {$wexit + $::padly + 2 - 20}] -anchor nw -text "для платформы Android" -fill black -font {{Nimbus Sans Narrow} 18}
$fr.can create text $::padlx [expr {$wexit + $::padly - 20}] -anchor nw -text "для платформы Android" -fill white -font {{Nimbus Sans Narrow} 18} -tag id_text1
set blogo [$fr.can bbox id_text1]
set wexit [lindex $blogo 3]
$fr.can create text [expr $::padlx + 2] [expr {$wexit + $::padly + 2}] -anchor nw -text "№ 63 ФЗ "Об электроннойnподписи от 6 апреля 2011 года"" -fill black -font {{Nimbus Sans Narrow} 14}
$fr.can create text $::padlx [expr {$wexit + $::padly}] -anchor nw -text "№ 63 ФЗ "Об электроннойnподписи от 6 апреля 2011 года"" -fill white -font {{Nimbus Sans Narrow} 14} -tag id_text2
set blogo [$fr.can bbox id_text2]
set wexit [lindex $blogo 3]
$fr.can create text [expr $::padlx + 1] [expr {$wexit + $::padly + 1}] -text "Авторы: В.Н. Орловnhttp://soft.lissi.ru, http://www.lissi.run+7(495)589-99-53ne-mail: [email protected]" 
-anchor nw -fill black  -font {{Nimbus Sans Narrow} 12}
$fr.can create text $::padlx [expr {$wexit + $::padly}] -text "Авторы: В.Н. Орловnhttp://soft.lissi.ru, http://www.lissi.run+7(495)589-99-53ne-mail: [email protected]" 
-anchor nw -fill white -tag id_text3  -font {{Nimbus Sans Narrow} 12} -tag id_text3
set blogo [$fr.can bbox id_text2]
}
set blogo [$fr.can bbox id_text3]
set wland [lindex $blogo 3]
$fr.can create image $::padlx $wland -image logo_and -anchor nw -tag tag_land
set ha [image height logo_and]
set wa [image width logo_and]
set ha1 [expr {$ha - ($ha / 2 ) }]
$fr.can create image [expr {$wa - 80 }] [expr {$wland + $ha1}] -image svitok -anchor nw -tag tag_land
if {$::typetlf} {
set x1 [expr {$::padlx / 2}]
set y1 [expr {$wland + 120}]
set x2 [expr {$::::scrwidth - $x1}]
set y2 [expr {$y1 + 120}]
set wd 8
set rr 18
} else {
set x1 [expr {$::padlx / 2}]
set y1 [expr {$wland + 40}]
set x2 [expr {$::::scrwidth - $x1}]
set y2 [expr {$y1 + 40}]
set wd 4
set rr 6
}
set g5 [$fr.can gradient create linear -stops {{0 lightgreen} {1 green}}] 
set S3 [$fr.can style create -stroke "skyblue" -fill  $g5 -strokewidth $wd  -fillopacity 0.6]
set im1 [$fr.can create prect $x1 $y1 $x2 $y2 -rx $rr -style $S3]
$fr.can bind $im1 <ButtonPress-1> {butImg "img1"}
#Печатаем техт
set blogo [$fr.can bbox $im1]
set by2 [lindex $blogo 3]
set by1 [lindex $blogo 1]
set bb [expr {($by2 - $by1) / 2}]
set bx2 [lindex $blogo 2]
set bx1 [lindex $blogo 0]
set bbx [expr {($bx2 - $bx1) / 2}]
set txt1 [$fr.can create text [expr {$x1 + $::padlx * 2}] [expr {$y1 + 1 }] -anchor nw -text "Сайт разработчика" -fill black -font {{Arial} 10 normal}] 
#Центрируем техт
set btxt1 [$fr.can bbox $txt1]
#Смещение по оси Y
set ty2 [lindex $btxt1 3]
set ty1 [lindex $btxt1 1]
set tt [expr {$ty2 - $ty1}]
set tt [expr {$tt / 2}]
set offsy [expr {($by1 + $bb) - ($ty1 + $tt)}]
#Смещение по оси X
set tx2 [lindex $btxt1 2]
set tx1 [lindex $btxt1 0]
set ttx [expr {$tx2 - $tx1}]
set ttx [expr {$ttx / 2}]
set offsx [expr {($bx1 + $bbx) - ($tx1 + $ttx)}]
$fr.can move $txt1 $offsx $offsy
$fr.can bind $txt1 <ButtonPress-1> {butImg "img1"}
if {$::typetlf} {
set y1 [expr $y2 + 40]
set x2 [expr {$::::scrwidth - $x1}]
set y2 [expr {$y1 + 120}]
} else {
set y1 [expr {$y1 + 60}]
set x2 [expr {$::::scrwidth - $x1}]
set y2 [expr {$y1 + 40}]
}
set im1 [create_rectangle $fr.can "but2" $x1 $y1 $x2 $y2 "#2b972d" 0.6 $wd "skyblue"]
#Печатаем техт
set blogo [$fr.can bbox $im1]
set by2 [lindex $blogo 3]
set by1 [lindex $blogo 1]
set bb [expr {($by2 - $by1) / 2}]
set bx2 [lindex $blogo 2]
set bx1 [lindex $blogo 0]
set bbx [expr {($bx2 - $bx1) / 2}]
set txt1 [$fr.can create text [expr {$x1 + $::padlx * 2}] [expr {$y1 + 1 }] -anchor nw -text "Переход в основное меню" -fill black -font {{Roboto Condensed Medium} 12}] 
#Центрируем текст
set btxt1 [$fr.can bbox $txt1]
#Смещение по оси Y
set ty2 [lindex $btxt1 3]
set ty1 [lindex $btxt1 1]
set tt [expr {$ty2 - $ty1}]
set tt [expr {$tt / 2}]
set offsy [expr {($by1 + $bb) - ($ty1 + $tt)}]
#Смещение по оси X
set tx2 [lindex $btxt1 2]
set tx1 [lindex $btxt1 0]
set ttx [expr {$tx2 - $tx1}]
set ttx [expr {$ttx / 2}]
set offsx [expr {($bx1 + $bbx) - ($tx1 + $ttx)}]
$fr.can move $txt1 $offsx $offsy
$fr.can bind $txt1 <ButtonPress-1> {butImg "but2"}
if {$::typetlf} {
set x1 [expr {$::padlx / 2}]
set y1 [expr $y2 + 40]
set x2 [expr {$::::scrwidth - $x1}]
set y2 [expr {$y1 + 120}]
} else {
set x1 [expr {$::padlx / 2}]
set y1 [expr {$y1 + 60}]
set x2 [expr {$::::scrwidth - $x1}]
set y2 [expr {$y1 + 40}]
}
set S3 [$fr.can style create -stroke skyblue -fill  $g5 -strokewidth $wd  -fillopacity 0.6]
set im1 [$fr.can create prect $x1 $y1 $x2 $y2 -rx $rr -style $S3]
set blogo [$fr.can bbox $im1]
$fr.can bind $im1 <ButtonPress-1> {butImg "exit"}
set by2 [lindex $blogo 3]
set by1 [lindex $blogo 1]
set bb [expr {($by2 - $by1) / 2}]
set bx2 [lindex $blogo 2]
set bx1 [lindex $blogo 0]
set bbx [expr {($bx2 - $bx1) / 2}]
set txt1 [$fr.can create text [expr {$x1 + $::padlx * 2}] [expr {$y1 + 1 }] -anchor nw -text "Конец работы" -fill black  -font {Arial 10 normal}]
$fr.can bind $txt1 <ButtonPress-1> {butImg "exit"}
set btxt1 [$fr.can bbox $txt1]
#Смещение по оси Y
set ty2 [lindex $btxt1 3]
set ty1 [lindex $btxt1 1]
set tt [expr {$ty2 - $ty1}]
set tt [expr {$tt / 2}]
set offsy [expr {($by1 + $bb) - ($ty1 + $tt)}]
#Смещение по оси X
set tx2 [lindex $btxt1 2]
set tx1 [lindex $btxt1 0]
set ttx [expr {$tx2 - $tx1}]
set ttx [expr {$ttx / 2}]
set offsx [expr {($bx1 + $bbx) - ($tx1 + $ttx)}]
$fr.can move $txt1 $offsx $offsy
}
#Собственно скрипт
#Считываем размеры экрана
set ::scrwidth [winfo screenwidth .]
set ::scrheight [winfo screenheight .]
set ::typetlf 0
#Проверяем, что это телефон
if {$::scrwidth < $::scrheight} {
set ::typetlf 1
}
set ::padls 20
set ::padlx 15
set ::padly 15
if {$::typetlf} {
wm attributes . -fullscreen 1
scaleImage icon_openfile_18x16 3
scaleImage ::img::view_18x16 3
#Логотип производителя
scaleImage logo_orel 2
#Логотип продуктв
scaleImage logo_product 2
#Андроида tcl/tk
scaleImage logo_and 3
#Свиток опечатанный
scaleImage svitok 4
set ::padls 50
set ::padlx 75
set ::padly 50
} else {
#Конфигурирование виджета под смартфон
scaleImage logo_orel -2
set ::scrwidth 370
set ::scrheight 700
wm minsize . $::scrwidth $::scrheight
set geometr $::scrwidth
append geometr "x"
append geometr $::scrheight
append geometr "+0+0"
wm geometry . $geometr
}
#Создаем название продукта
set name_product "CryptoArmPKCS-A" 
label .labtitul -image logo_product -compound left -fg snow -text $name_product -font {Arial 10 bold} -anchor w  -width [winfo screenwidth .] -pady $::padls -padx 10 -bg #222222 
pack .labtitul -anchor nw -expand 0 -fill x -side top  -padx 1 -pady 0
#Создаем стартовую страницу
set i 0
ttk::frame .fr$i -pad 0 -padding 0
page_titul ".fr$i"  "logo_orel"
pack .fr$i -side top -anchor center -expand 1 -fill both -side top  -padx 0 -pady 0 
update

Gus an sgriobt seo a chuir an gnìomh, cleachd aon de na goireasan undroidwish no vanillawish:

$ /usr/local/bin64/undroidwish-e5dc71ed9d-linux64   create_titul_page.tcl 

no

$/usr/local/bin64/vanillawish-e5dc71ed9d-linux64  create_titul_page.tcl 

Tha an toradh ri fhaicinn anns a’ chiad dealbh-sgrìn.

Tha an dàrna duilleag a’ liostadh na gnìomhan a tha a’ faighinn taic bhon ghoireas cryptoarmpkcs-A. Is e putan a th’ anns gach loidhne, nuair a bhriogas tu air, thèid duilleag gnìomh a thaisbeanadh. Tha geoimeatraidh suidheachadh a’ phutan air an duilleag seo air a dhearbhadh leis a’ chruth-clò a thathar a’ cleachdadh. Gu h-ìosal tha an sgriobt create_page_functions.tcl gus an dàrna duilleag / duilleag gnìomh den tagradh a chruthachadh. Faodaidh duine sam bith cuideachd a dheasachadh gus freagairt air na gnìomhan aca.

Sgriobt create_page_functions.tcl

package require Tk
package require tkpath 0.3.0
global mydir
set mydir [file dirname [info script]]
#Увеличить/уменьшить (отрицательное значение - уменьшение)
proc scaleImage {im xfactor {yfactor 0}} {
set mode -subsample
if {$xfactor>=0 && $yfactor>=0} {
set mode -zoom
} else {
set xfactor [expr $xfactor * -1]
}
if {$yfactor == 0} {set yfactor $xfactor}
set t [image create photo]
$t copy $im
$im blank
$im copy $t -shrink $mode $xfactor $yfactor
image delete $t
}
proc createtile {w  backg} {
image create photo tiled
tiled copy $backg -to 0 0 $::scrwidth $::scrheight -shrink
$backg copy tiled
image delete tiled
# Мостим холст
$w create image 0 0  
-image $backg  
-anchor nw
}
proc butCliked {num fr} {
pack forget  .fr1
set ::tekFrfunc $fr
pack $fr -side top -anchor center -expand 1 -fill both -side top  -padx 0 -pady 0 
tk_dialog .dialog1 "Dear user:" "Button $num was clickednFr=$fr" info 0 OK 
}
proc butImg {img} {
tk_messageBox -title "Кнопка" -icon info -message "Нажали кнопку=$img" -detail "::screenwidth=$::scrwidthn::screenheight=$::scrheight" -parent .
if {$img == "exit"} {
set answer [tk_dialog .dialog2 "Конец работы" "Вы действительноnхотите выйти?" question 0 "Да" "Нет" ]
if {$answer == 0} {
exit
}	
}
}
proc butReturn {} {
pack forget  $::tekFrfunc
pack .fr1 -side top -anchor center -expand 1 -fill both -side top  -padx 0 -pady 0 
#    tk_dialog .dialog1 "Dear user:" "Button $num was clickednFr=$fr" info 0 OK 
}
proc page_func {fr tile titul functions} {
#Кнопки  меню
upvar $functions but
#Создаем шрифт для кнопок
if {$::typetlf} {
set feFONT_button "-family {Roboto} -size 9 -weight bold -slant roman"
set widl 10
} else {
set feFONT_button "-family {Arial} -size 12 -weight bold -slant roman"
set widl 5
}
catch {font delete fontTEMP_drawer}
eval font create fontTEMP_drawer  $feFONT_button
#Вычисляем максимальныю длину текста
set drawerCNT 0
set strMaxWidthPx 15
set Ndrawers [expr {[array size but] - 1}]
while { $drawerCNT <= $Ndrawers } {
set strWidthPx [font measure fontTEMP_drawer "$but($drawerCNT)"]
if { $strWidthPx > $strMaxWidthPx } {
set strMaxWidthPx $strWidthPx
}
incr drawerCNT
}
set drawerWidthPx [expr $strMaxWidthPx + 10]
set xxx [expr {($::::scrwidth - $drawerWidthPx) / 2}]
if {$fr != ".fr1"} {
set hret [expr $::scrheight / 4]
} else {
set hret $::scrheight
}
set hret [expr $::scrheight / 4]
tkp::canvas $fr.can -borderwidth 0 -height $hret -width $::scrwidth -relief flat
#Мостим холст плиткой 
createtile "$fr.can"  $tile
pack $fr.can  -anchor center -expand 1 -fill both -side top  -padx 0 -pady 0
if {$titul != "" } {
set allfunc $titul
catch {font delete fontTEMP_titul}
set font_titul "-family {Roboto Condensed Medium} -size 15"
eval font create fontTEMP_titul  $font_titul
set funcWidthPx [font measure fontTEMP_titul "$allfunc"]
set dlx [expr {($::::scrwidth - $funcWidthPx) / 2}]
$fr.can create text [expr $dlx + 6] [expr {6 + 6}] -anchor nw -text "$allfunc" -fill black -font fontTEMP_titul
$fr.can create text $dlx 6 -anchor nw -text "$allfunc" -fill white -font fontTEMP_titul -tag id_text0
set blogo [$fr.can bbox id_text0]
set boxbut [expr ([lindex $blogo 3] + 6 + 6)]
} else {
set boxbut [expr 6 + 6]
}
#Вычисляем самый широкий текст у кнопок
#См. выше
#Размещаем кнопки
set BDwidth_canvas 0
set maxTextHeightPx [font metrics fontTEMP_drawer -linespace] 
set maxTextHeightPx [expr {$maxTextHeightPx + ( $maxTextHeightPx / 2)}]
set drawerHeightPx $maxTextHeightPx
set xLocTextPx [expr {($::::scrwidth - $drawerWidthPx) / 2}]
set yLocTextPx [expr $BDwidth_canvas + ($drawerHeightPx / 2) + $boxbut]
set canvasHeightPx [expr $Ndrawers * $drawerHeightPx]
set drawerCNT 0
set Ndrawers [expr {[array size but] - 1}]
while { $drawerCNT <= $Ndrawers } {
set yLineLocPx [ expr (( $drawerCNT ) * $drawerHeightPx + $boxbut)]
#Линия перед текстом
$fr.can create line 
$xLocTextPx $yLineLocPx 
[expr $drawerWidthPx + $xLocTextPx] $yLineLocPx 
-fill "#a0a0a0" -width $widl
$fr.can create text [expr $xLocTextPx + 5] $yLocTextPx 
-anchor w 
-font fontTEMP_drawer 
-text "$but($drawerCNT)" 
-tag textlineTag($drawerCNT)
if {$drawerCNT == 0} {
if {$fr == ".fr1"} {
$fr.can bind textlineTag($drawerCNT)  <ButtonRelease-1>   {butImg "but1"}
} else {
$fr.can bind textlineTag($drawerCNT)  <ButtonRelease-1>   {butReturn}
}
} else {
frame .fn$drawerCNT -background white -relief flat -pady 0 -padx 0
set titul $but($drawerCNT)
set cmd "$fr.can bind textlineTag($drawerCNT)  <ButtonRelease-1>   {butCliked $drawerCNT .fn$drawerCNT}"
set cmd [subst "$cmd"]
eval $cmd 
set but1(0) "Возврат в основное меню"
page_func ".fn$drawerCNT" voda "$titul" "but1"
}
incr drawerCNT
set yLocTextPx [ expr $yLocTextPx + $drawerHeightPx]
#Завершаюшая линия
if { $drawerCNT > $Ndrawers } {
set yLineLocPx [ expr (( $drawerCNT ) * $drawerHeightPx + $boxbut)]
$fr.can create line $xLocTextPx $yLineLocPx 
[expr $drawerWidthPx + $xLocTextPx] $yLineLocPx 
-fill "#a0a0a0" -width $widl
}
}
}
#Собственно скрипт
#Считываем размеры экрана
set ::scrwidth [winfo screenwidth .]
set ::scrheight [winfo screenheight .]
set ::typetlf 0
#Проверяем, что это телефон
if {$::scrwidth < $::scrheight} {
set ::typetlf 1
}
set ::padls 20
set ::padlx 15
set ::padly 15
if {$::typetlf} {
wm attributes . -fullscreen 1
#Логотип продуктв
scaleImage logo_product 2
set ::padls 50
set ::padlx 75
set ::padly 50
} else {
#Конфигурирование виджета под смартфон
set ::scrwidth 370
set ::scrheight 700
wm minsize . $::scrwidth $::scrheight
set geometr $::scrwidth
append geometr "x"
append geometr $::scrheight
append geometr "+0+0"
wm geometry . $geometr
}
#Грузим картинки
image create photo voda -file [file join $mydir "imageme" "voda_400x800.png"]
#Логотип продукта
image create photo logo_product -file [file join $mydir "imageme" "validcertkey_51x24.png"] 
#Создаем название продукта
set name_product "CryptoArmPKCS-A" 
label .labtitul -image logo_product -compound left -fg snow -text $name_product -font {Arial 10 bold} -anchor w  -width [winfo screenwidth .] -pady $::padls -padx 10 -bg #222222 
pack .labtitul -anchor nw -expand 0 -fill x -side top  -padx 1 -pady 0
#Создаем страницы с функционалом
set i 1
ttk::frame .fr$i -pad 0 -padding 0
#Кнопки основного меню
set but(0) "Стартовая страница" 
set but(1) "Подписать документ"
set but(2) "Работаем с ЭП (PKCS7)" 
set but(3) "Запрос на сертификат" 
set but(4) "Просмотр запроса/сертификата" 
set but(5) "Список криптомеханизмов"
set but(6) "Просмотр ASN1-структуры" 
set but(7) "Объекты токена" 
set but(8) "Работаем с PKCS12/PFX" 
set but(9) "Самоподписанный сертификат"
set but(10) "Об Утилите/Дистрибутивы" 
set but(11) "Создать Токены"
set but(12) "Конфигурировние токена"
if {$::typetlf} {
scaleImage voda 3 2
}
#Создаем страницу с функционалом
page_func ".fr$i" voda "Функционал" "but"
#Отображаем страницу с функционалом
pack .fr$i -side top -anchor center -expand 1 -fill both -side top  -padx 0 -pady 0 

Bidh an sgriobt seo cuideachd ag ullachadh beàrnan airson gach putan gnìomh:

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

Tha na beàrnan air an lìonadh le widgets clasaigeach agus cuspaireil (labelframe, putan, msaa). Chithear aon de na beàrnan lìonta sin anns a’ chiad dealbh-sgrìn air an taobh cheart. Leis gun do chuir sinn fòcas aig a’ chiad ìre air a bhith ag obair leis a’ ghobhar PKCS #12, chaidh an còd a chleachdadh cha mhòr gun atharrachadh airson cryptoarmpkcs-A. Aig an ìre seo tha na gnìomhan a leanas air an cur an gnìomh:

  • cuir d’ ainm ris an sgrìobhainn (Cades-BES, CAdes-T, CAdes-XLT1);
  • Bidh sinn ag obair le ainm-sgrìobhte eileagtronaigeach (PKCS7), a’ gabhail a-steach ainm-sgrìobhte a chur ris;
  • Thoir sùil air teisteanasan / iarrtasan teisteanais:

    Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

  • Bidh sinn ag obair le PKCS12/PFX;
  • mun ghoireas/sgaoileadh:

    Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

Tha na gnìomhan a tha air fhàgail nas co-cheangailte ri comharran PKCS#11. Tha an giùlan aca air a chuir dheth chun na Bliadhn’ Ùire. Thathas an dùil tòcan bathar-bog a cheangal agus ceangal a dhèanamh ris sgòth tòcan.

Bho shealladh gnìomh, tha cha mhòr a h-uile dad coltach ris a ’ghoireas cryptoarmpkcs. Ach tha beagan eadar-dhealachaidhean ann. Mar eisimpleir, às deidh dha sgrìobhainn a shoidhnigeadh, bidh an goireas a’ faighneachd an tèid an ainm-sgrìobhte a dhearbhadh air làrach-lìn Seirbheisean na Stàite:

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android
Nuair a phutas tu air a’ phutan “Tha”, luchdaichidh am brobhsair le duilleag airson ainm-sgrìobhte sgrìobhainnean is theisteanasan a dhearbhadh. Canaidh sinn sa bhad nach eil an duilleag seo air a dhealbhadh dha-rìribh airson scrion fòn cliste. Bidh seo follaiseach nuair a thaghas tu ainm-sgrìobhte agus, ma tha an t-ainm-sgrìobhte air a sgaradh, am faidhle leis an sgrìobhainn. Ach ma tha a h-uile dad gu math, gheibh sinn toradh adhartach:

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android

Bu chòir cuimhneachadh nach eil a bhith a’ sgrùdadh gach cuid an ainm-sgrìobhte agus an teisteanas air làrach-lìn Seirbheisean na Stàite a’ dèanamh ciall ach ma chaidh an teisteanas fhaighinn aig ionad teisteanais barrantaichte (УЦ). Mur eil, bidh an t-ainm-sgrìobhte an-còmhnaidh neo-dhligheach.

Gus am brabhsair a ghairm, bha agam ri loidhne no dhà a chur ris a’ mhodh openUrl:

proc openURL {url} {
global typesys
global macos
#  global windowsOS
#проверка, что утилита выполняется на смартфоне Android
if {$::typetlf} {
#Запуск браузера
borg activity android.intent.action.VIEW $url text/html
return
}
. . .
}

Canar am brabhsair air Android mar a leanas:

borg activity android.intent.action.VIEW <URL> text/html

Tha rud beag sònraichte ann nuair a chuireas tu neach-soidhnidh ùr ri sgrìobhainn a chaidh a shoidhnigeadh roimhe. Feumar teisteanas an neach-soidhnidh ùr (no an àite, eadhon soitheach PKCS #12 le teisteanas agus iuchair phrìobhaideach) a thaghadh ro làimh air an duilleag “Sign a document” no “Ag obair le PKCS12/PFX”, a chuireas an goireas nad chuimhne :

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android
Rè obrachaidhean fad-ùine, leanaidh an gleoc a’ strìochag:

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar Android
Chan eil air fhàgail ach a ràdh càite an luchdaich thu sìos na sgaoilidhean agus meal-a-naidheachd ort air a’ Bhliadhn’ Ùr a tha ri thighinn agus a’ guidhe gach soirbheachas don h-uile duine ann an 2020!

Ionad-obrach criptografach stèidhichte air prìomh inbhean poblach airson àrd-ùrlar AndroidMar sin, sgaoilidhean airson Linux, OS X, Windows agus Android:

Source: www.habr.com

Cuir beachd ann