diff options
author | William Ahern <william@server.local> | 2013-03-11 23:03:07 -0700 |
---|---|---|
committer | William Ahern <william@server.local> | 2013-03-11 23:03:07 -0700 |
commit | 50414ab3f72bc06b0d2ea3781f20a7aa00a118ab (patch) | |
tree | 6fa7c969c47167b5899d31f08a61cb66e13e7d03 | |
parent | 0890dea992af3ec0b65f4940b2954d27b9336c0d (diff) | |
download | luaossl-50414ab3f72bc06b0d2ea3781f20a7aa00a118ab.tar.gz luaossl-50414ab3f72bc06b0d2ea3781f20a7aa00a118ab.tar.bz2 luaossl-50414ab3f72bc06b0d2ea3781f20a7aa00a118ab.zip |
-n
use correct indices in cipher_init, and fix method name mixup
-rw-r--r-- | openssl.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -3567,13 +3567,13 @@ static int cipher_init(lua_State *L, _Bool encrypt) { | |||
3567 | const void *key, *iv; | 3567 | const void *key, *iv; |
3568 | size_t n, m; | 3568 | size_t n, m; |
3569 | 3569 | ||
3570 | key = luaL_checklstring(L, 1, &n); | 3570 | key = luaL_checklstring(L, 2, &n); |
3571 | m = (size_t)EVP_CIPHER_CTX_key_length(ctx); | 3571 | m = (size_t)EVP_CIPHER_CTX_key_length(ctx); |
3572 | luaL_argcheck(L, 1, n == m, lua_pushfstring(L, "%u: invalid key length (should be %u)", (unsigned)n, (unsigned)m)); | 3572 | luaL_argcheck(L, 2, n == m, lua_pushfstring(L, "%u: invalid key length (should be %u)", (unsigned)n, (unsigned)m)); |
3573 | 3573 | ||
3574 | iv = luaL_checklstring(L, 2, &n); | 3574 | iv = luaL_checklstring(L, 3, &n); |
3575 | m = (size_t)EVP_CIPHER_CTX_iv_length(ctx); | 3575 | m = (size_t)EVP_CIPHER_CTX_iv_length(ctx); |
3576 | luaL_argcheck(L, 2, n == m, lua_pushfstring(L, "%u: invalid IV length (should be %u)", (unsigned)n, (unsigned)m)); | 3576 | luaL_argcheck(L, 3, n == m, lua_pushfstring(L, "%u: invalid IV length (should be %u)", (unsigned)n, (unsigned)m)); |
3577 | 3577 | ||
3578 | if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, encrypt)) | 3578 | if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, encrypt)) |
3579 | return throwssl(L, (encrypt)? "cipher:encrypt" : "cipher:decrypt"); | 3579 | return throwssl(L, (encrypt)? "cipher:encrypt" : "cipher:decrypt"); |
@@ -3661,8 +3661,8 @@ static int cipher__gc(lua_State *L) { | |||
3661 | 3661 | ||
3662 | 3662 | ||
3663 | static const luaL_Reg cipher_methods[] = { | 3663 | static const luaL_Reg cipher_methods[] = { |
3664 | { "encrypt", &cipher_update }, | 3664 | { "encrypt", &cipher_encrypt }, |
3665 | { "decrypt", &cipher_final }, | 3665 | { "decrypt", &cipher_decrypt }, |
3666 | { "update", &cipher_update }, | 3666 | { "update", &cipher_update }, |
3667 | { "final", &cipher_final }, | 3667 | { "final", &cipher_final }, |
3668 | { NULL, NULL }, | 3668 | { NULL, NULL }, |