aboutsummaryrefslogtreecommitdiffstats
path: root/openssl.c
diff options
context:
space:
mode:
authorLibravatarLibravatar William Ahern <william@server.local> 2013-03-11 23:03:07 -0700
committerLibravatarLibravatar William Ahern <william@server.local> 2013-03-11 23:03:07 -0700
commit50414ab3f72bc06b0d2ea3781f20a7aa00a118ab (patch)
tree6fa7c969c47167b5899d31f08a61cb66e13e7d03 /openssl.c
parent0890dea992af3ec0b65f4940b2954d27b9336c0d (diff)
downloadluaossl-50414ab3f72bc06b0d2ea3781f20a7aa00a118ab.tar.gz
luaossl-50414ab3f72bc06b0d2ea3781f20a7aa00a118ab.tar.bz2
luaossl-50414ab3f72bc06b0d2ea3781f20a7aa00a118ab.zip
-n
use correct indices in cipher_init, and fix method name mixup
Diffstat (limited to 'openssl.c')
-rw-r--r--openssl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/openssl.c b/openssl.c
index ddfb3df..df2f744 100644
--- a/openssl.c
+++ b/openssl.c
@@ -3567,13 +3567,13 @@ static int cipher_init(lua_State *L, _Bool encrypt) {
const void *key, *iv;
size_t n, m;
- key = luaL_checklstring(L, 1, &n);
+ key = luaL_checklstring(L, 2, &n);
m = (size_t)EVP_CIPHER_CTX_key_length(ctx);
- luaL_argcheck(L, 1, n == m, lua_pushfstring(L, "%u: invalid key length (should be %u)", (unsigned)n, (unsigned)m));
+ luaL_argcheck(L, 2, n == m, lua_pushfstring(L, "%u: invalid key length (should be %u)", (unsigned)n, (unsigned)m));
- iv = luaL_checklstring(L, 2, &n);
+ iv = luaL_checklstring(L, 3, &n);
m = (size_t)EVP_CIPHER_CTX_iv_length(ctx);
- luaL_argcheck(L, 2, n == m, lua_pushfstring(L, "%u: invalid IV length (should be %u)", (unsigned)n, (unsigned)m));
+ luaL_argcheck(L, 3, n == m, lua_pushfstring(L, "%u: invalid IV length (should be %u)", (unsigned)n, (unsigned)m));
if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, encrypt))
return throwssl(L, (encrypt)? "cipher:encrypt" : "cipher:decrypt");
@@ -3661,8 +3661,8 @@ static int cipher__gc(lua_State *L) {
static const luaL_Reg cipher_methods[] = {
- { "encrypt", &cipher_update },
- { "decrypt", &cipher_final },
+ { "encrypt", &cipher_encrypt },
+ { "decrypt", &cipher_decrypt },
{ "update", &cipher_update },
{ "final", &cipher_final },
{ NULL, NULL },