From 50414ab3f72bc06b0d2ea3781f20a7aa00a118ab Mon Sep 17 00:00:00 2001 From: William Ahern Date: Mon, 11 Mar 2013 23:03:07 -0700 Subject: -n use correct indices in cipher_init, and fix method name mixup --- openssl.c | 12 ++++++------ 1 file 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 }, -- cgit v1.2.3-59-g8ed1b