Search
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (541 Bytes)
Feature #9830
» gost_sigining.rb
Test script: digital signature creating and verifying -
Envek (Andrey Novikov)
, 05/11/2014 08:27 PM
require
'openssl'
OpenSSL
::
Engine
.
load
gost_engine
=
OpenSSL
::
Engine
.
by_id
(
'gost'
)
gost_engine
.
set_default
(
0xFFFF
)
crt
=
OpenSSL
::
X509
::
Certificate
.
new
(
File
.
read
(
'gost_r_34_10_2001_certificate.pem'
))
privkey
=
OpenSSL
::
PKey
.
read
(
File
.
read
(
'gost_r_34_10_2001_private_key.pem'
))
data
=
'Some message'
dgst94
=
gost_engine
.
digest
(
'md_gost94'
)
signature
=
privkey
.
sign
(
dgst94
,
data
)
puts
crt
.
public_key
.
verify
(
dgst94
,
signature
,
data
)
# Should be true
puts
crt
.
public_key
.
verify
(
dgst94
,
signature
,
data
.
sub
(
'S'
,
'Not s'
))
# Should be false
« Previous
1
2
3
4
5
6
Next »
(4-4/6)
Loading...