comparison spec/util_crypto_spec.lua @ 12737:924bc1c8d0d9

util.crypto: Fix tests Found this number in a hat. Sleepy time. Good night.
author Kim Alvefur <zash@zash.se>
date Fri, 30 Sep 2022 00:27:10 +0200
parents 5bda8598a2af
children d3ae47d8a7a7
comparison
equal deleted inserted replaced
12736:ad4ab01f9b11 12737:924bc1c8d0d9
115 304402203e936e7b0bc62887e0e9d675afd08531a930384cfcf301 115 304402203e936e7b0bc62887e0e9d675afd08531a930384cfcf301
116 f25d13053a2ebf141d02205a5a7c7b7ac5878d004cb79b17b39346 116 f25d13053a2ebf141d02205a5a7c7b7ac5878d004cb79b17b39346
117 6b0cd1043718ffc31c153b971d213a8e 117 6b0cd1043718ffc31c153b971d213a8e
118 ]]):gsub("%s+", ""))); 118 ]]):gsub("%s+", "")));
119 it("can be parsed", function () 119 it("can be parsed", function ()
120 local r, s = crypto.parse_ecdsa_signature(sig); 120 local r, s = crypto.parse_ecdsa_signature(sig, 32);
121 assert.is_string(r); 121 assert.is_string(r);
122 assert.is_string(s); 122 assert.is_string(s);
123 assert.equal(32, #r); 123 assert.equal(32, #r);
124 assert.equal(32, #s); 124 assert.equal(32, #s);
125 end); 125 end);
132 string.rep("\000", 256); 132 string.rep("\000", 256);
133 string.rep("\255", 72); 133 string.rep("\255", 72);
134 string.rep("\255", 3); 134 string.rep("\255", 3);
135 }; 135 };
136 for _, invalid_sig in ipairs(invalid_sigs) do 136 for _, invalid_sig in ipairs(invalid_sigs) do
137 local r, s = crypto.parse_ecdsa_signature(invalid_sig); 137 local r, s = crypto.parse_ecdsa_signature(invalid_sig, 32);
138 assert.is_nil(r); 138 assert.is_nil(r);
139 assert.is_nil(s); 139 assert.is_nil(s);
140 end 140 end
141 end); 141 end);
142 it("can be built", function () 142 it("can be built", function ()
143 local r, s = crypto.parse_ecdsa_signature(sig); 143 local r, s = crypto.parse_ecdsa_signature(sig, 32);
144 local rebuilt_sig = crypto.build_ecdsa_signature(r, s); 144 local rebuilt_sig = crypto.build_ecdsa_signature(r, s);
145 assert.equal(sig, rebuilt_sig); 145 assert.equal(sig, rebuilt_sig);
146 end); 146 end);
147 end); 147 end);
148 148