summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorWilliam Ahern <william@25thandclement.com>2016-10-29 16:58:34 -0700
committerWilliam Ahern <william@25thandclement.com>2016-10-29 16:58:34 -0700
commit38e4043d735f406c81173322f30e2a37d97101f5 (patch)
tree1c81611454c2756a8786bd22f528b12bbf3a49be /examples
parent8aa467e04b93b62fef6a1b225944d82f00ff2168 (diff)
downloadluaossl-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-xexamples/vrfy.sig17
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"
13local function genkey(type) 13local 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
23end 24end
24 25
25local key, hash = genkey(keytype) 26local key = genkey(keytype)
27local 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
46end 48end
47 49
48print("okay", pub:verify(sig, data)) 50print("verified", pub:verify(sig, data))
49print("type", pub:type()) 51print("key-type", pub:type())
50print("sig", tohex(sig)) 52print("hash-type", hash)
53print("signature", tohex(sig))