raise error when DH param is 0

This commit is contained in:
Cloud Wu
2015-09-18 14:13:16 +08:00
parent 00dbf6e996
commit 008351573a

View File

@@ -725,10 +725,8 @@ ldhsecret(lua_State *L) {
read64(L, x, y);
uint64_t xx = (uint64_t)x[0] | (uint64_t)x[1]<<32;
uint64_t yy = (uint64_t)y[0] | (uint64_t)y[1]<<32;
if (xx == 0)
xx = 1;
if (yy == 0)
yy = 1;
if (xx == 0 || yy == 0)
return luaL_error(L, "Can't be 0");
uint64_t r = powmodp(xx, yy);
push64(L, r);
@@ -751,7 +749,7 @@ ldhexchange(lua_State *L) {
uint64_t x64 = (uint64_t)xx[0] | (uint64_t)xx[1]<<32;
if (x64 == 0)
x64 = 1;
return luaL_error(L, "Can't be 0");
uint64_t r = powmodp(5, x64);
push64(L, r);