diff options
author | William Ahern <william@25thandclement.com> | 2016-10-29 16:58:34 -0700 |
---|---|---|
committer | William Ahern <william@25thandclement.com> | 2016-10-29 16:58:34 -0700 |
commit | 38e4043d735f406c81173322f30e2a37d97101f5 (patch) | |
tree | 1c81611454c2756a8786bd22f528b12bbf3a49be /examples | |
parent | 8aa467e04b93b62fef6a1b225944d82f00ff2168 (diff) | |
download | luaossl-38e4043d735f406c81173322f30e2a37d97101f5.tar.gz luaossl-38e4043d735f406c81173322f30e2a37d97101f5.tar.bz2 luaossl-38e4043d735f406c81173322f30e2a37d97101f5.zip |
add and use pkey:getDefaultDigestName because the old digest type names used in examples/vrfy.sig are not accepted by OpenSSL 1.1
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/vrfy.sig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/examples/vrfy.sig b/examples/vrfy.sig index 258490a..f6cc927 100755 --- a/examples/vrfy.sig +++ b/examples/vrfy.sig | |||
@@ -13,16 +13,18 @@ local digest = require"openssl.digest" | |||
13 | local function genkey(type) | 13 | local function genkey(type) |
14 | type = string.upper(type or (not openssl.NO_EC and "EC") or "RSA") | 14 | type = string.upper(type or (not openssl.NO_EC and "EC") or "RSA") |
15 | 15 | ||
16 | local key | ||
16 | if type == "RSA" then | 17 | if type == "RSA" then |
17 | return pkey.new{ type = "RSA", bits = 1024 }, "sha256" | 18 | return pkey.new{ type = "RSA", bits = 1024 } |
18 | elseif type == "DSA" then | 19 | elseif type == "DSA" then |
19 | return pkey.new{ type = "DSA", bits = 1024 }, "dss1" | 20 | return pkey.new{ type = "DSA", bits = 1024 } |
20 | else | 21 | else |
21 | return pkey.new{ type = "EC", curve = "prime192v1" }, "ecdsa-with-SHA1" | 22 | return pkey.new{ type = "EC", curve = "prime192v1" } |
22 | end | 23 | end |
23 | end | 24 | end |
24 | 25 | ||
25 | local key, hash = genkey(keytype) | 26 | local key = genkey(keytype) |
27 | local hash = key:getDefaultDigestName() | ||
26 | 28 | ||
27 | -- digest our message using an appropriate digest ("ecdsa-with-SHA1" for EC; | 29 | -- digest our message using an appropriate digest ("ecdsa-with-SHA1" for EC; |
28 | -- "dss1" for DSA; and "sha1", "sha256", etc for RSA). | 30 | -- "dss1" for DSA; and "sha1", "sha256", etc for RSA). |
@@ -45,6 +47,7 @@ local function tohex(b) | |||
45 | return x | 47 | return x |
46 | end | 48 | end |
47 | 49 | ||
48 | print("okay", pub:verify(sig, data)) | 50 | print("verified", pub:verify(sig, data)) |
49 | print("type", pub:type()) | 51 | print("key-type", pub:type()) |
50 | print("sig", tohex(sig)) | 52 | print("hash-type", hash) |
53 | print("signature", tohex(sig)) | ||