aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTechnorama team <oss-ruby@technorama.net>2004-06-14 17:01:42 +0000
committerTechnorama team <oss-ruby@technorama.net>2004-06-14 17:01:42 +0000
commit7dc2d3d9323c7812a11ad23ab386022c4dd2a96c (patch)
tree33d77fb5c99184661ad0d4f29308fd3a09b48052
parentb9716d5150017b92dfe9c2d3af4c21f900ce1b4e (diff)
downloadruby-openssl-history-7dc2d3d9323c7812a11ad23ab386022c4dd2a96c.tar.gz
add key_len=
-rw-r--r--ossl_cipher.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/ossl_cipher.c b/ossl_cipher.c
index 43a8a00..2054c1c 100644
--- a/ossl_cipher.c
+++ b/ossl_cipher.c
@@ -369,6 +369,19 @@ CIPHER_0ARG_INT(key_length)
CIPHER_0ARG_INT(iv_length)
CIPHER_0ARG_INT(block_size)
+static VALUE
+ossl_cipher_set_key_length(VALUE self, VALUE key_length)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ GetCipher(self, ctx);
+
+ if (EVP_CIPHER_CTX_set_key_length(ctx, NUM2INT(key_length)) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return key_length;
+}
+
/*
* INIT
*/
@@ -399,10 +412,7 @@ Init_ossl_cipher(void)
rb_define_method(cCipher, "key=", ossl_cipher_set_key, 1);
rb_define_method(cCipher, "key_len", ossl_cipher_key_length, 0);
-/*
- * TODO
- * int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
- */
+ rb_define_method(cCipher, "key_len=", ossl_cipher_set_key_length, 1);
rb_define_method(cCipher, "iv=", ossl_cipher_set_iv, 1);
rb_define_method(cCipher, "iv_len", ossl_cipher_iv_length, 0);