00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "ossl.h"
00012
00013 #define WrapCipher(obj, klass, ctx) \
00014 (obj) = Data_Wrap_Struct((klass), 0, ossl_cipher_free, (ctx))
00015 #define MakeCipher(obj, klass, ctx) \
00016 (obj) = Data_Make_Struct((klass), EVP_CIPHER_CTX, 0, ossl_cipher_free, (ctx))
00017 #define AllocCipher(obj, ctx) \
00018 memset(DATA_PTR(obj) = (ctx) = ALLOC(EVP_CIPHER_CTX), 0, sizeof(EVP_CIPHER_CTX))
00019 #define GetCipherInit(obj, ctx) do { \
00020 Data_Get_Struct((obj), EVP_CIPHER_CTX, (ctx)); \
00021 } while (0)
00022 #define GetCipher(obj, ctx) do { \
00023 GetCipherInit((obj), (ctx)); \
00024 if (!(ctx)) { \
00025 ossl_raise(rb_eRuntimeError, "Cipher not inititalized!"); \
00026 } \
00027 } while (0)
00028 #define SafeGetCipher(obj, ctx) do { \
00029 OSSL_Check_Kind((obj), cCipher); \
00030 GetCipher((obj), (ctx)); \
00031 } while (0)
00032
00033
00034
00035
00036 VALUE cCipher;
00037 VALUE eCipherError;
00038
00039 static VALUE ossl_cipher_alloc(VALUE klass);
00040
00041
00042
00043
00044 const EVP_CIPHER *
00045 GetCipherPtr(VALUE obj)
00046 {
00047 EVP_CIPHER_CTX *ctx;
00048
00049 SafeGetCipher(obj, ctx);
00050
00051 return EVP_CIPHER_CTX_cipher(ctx);
00052 }
00053
00054 VALUE
00055 ossl_cipher_new(const EVP_CIPHER *cipher)
00056 {
00057 VALUE ret;
00058 EVP_CIPHER_CTX *ctx;
00059
00060 ret = ossl_cipher_alloc(cCipher);
00061 AllocCipher(ret, ctx);
00062 EVP_CIPHER_CTX_init(ctx);
00063 if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
00064 ossl_raise(eCipherError, NULL);
00065
00066 return ret;
00067 }
00068
00069
00070
00071
00072 static void
00073 ossl_cipher_free(EVP_CIPHER_CTX *ctx)
00074 {
00075 if (ctx) {
00076 EVP_CIPHER_CTX_cleanup(ctx);
00077 ruby_xfree(ctx);
00078 }
00079 }
00080
00081 static VALUE
00082 ossl_cipher_alloc(VALUE klass)
00083 {
00084 VALUE obj;
00085
00086 WrapCipher(obj, klass, 0);
00087
00088 return obj;
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 static VALUE
00100 ossl_cipher_initialize(VALUE self, VALUE str)
00101 {
00102 EVP_CIPHER_CTX *ctx;
00103 const EVP_CIPHER *cipher;
00104 char *name;
00105 unsigned char key[EVP_MAX_KEY_LENGTH];
00106
00107 name = StringValuePtr(str);
00108 GetCipherInit(self, ctx);
00109 if (ctx) {
00110 ossl_raise(rb_eRuntimeError, "Cipher already inititalized!");
00111 }
00112 AllocCipher(self, ctx);
00113 EVP_CIPHER_CTX_init(ctx);
00114 if (!(cipher = EVP_get_cipherbyname(name))) {
00115 ossl_raise(rb_eRuntimeError, "unsupported cipher algorithm (%s)", name);
00116 }
00117
00118
00119
00120
00121
00122
00123 memset(key, 0, EVP_MAX_KEY_LENGTH);
00124 if (EVP_CipherInit_ex(ctx, cipher, NULL, key, NULL, -1) != 1)
00125 ossl_raise(eCipherError, NULL);
00126
00127 return self;
00128 }
00129
00130 static VALUE
00131 ossl_cipher_copy(VALUE self, VALUE other)
00132 {
00133 EVP_CIPHER_CTX *ctx1, *ctx2;
00134
00135 rb_check_frozen(self);
00136 if (self == other) return self;
00137
00138 GetCipherInit(self, ctx1);
00139 if (!ctx1) {
00140 AllocCipher(self, ctx1);
00141 }
00142 SafeGetCipher(other, ctx2);
00143 if (EVP_CIPHER_CTX_copy(ctx1, ctx2) != 1)
00144 ossl_raise(eCipherError, NULL);
00145
00146 return self;
00147 }
00148
00149 #ifdef HAVE_OBJ_NAME_DO_ALL_SORTED
00150 static void*
00151 add_cipher_name_to_ary(const OBJ_NAME *name, VALUE ary)
00152 {
00153 rb_ary_push(ary, rb_str_new2(name->name));
00154 return NULL;
00155 }
00156 #endif
00157
00158 #ifdef HAVE_OBJ_NAME_DO_ALL_SORTED
00159
00160
00161
00162
00163
00164
00165 static VALUE
00166 ossl_s_ciphers(VALUE self)
00167 {
00168 VALUE ary;
00169
00170 ary = rb_ary_new();
00171 OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
00172 (void(*)(const OBJ_NAME*,void*))add_cipher_name_to_ary,
00173 (void*)ary);
00174
00175 return ary;
00176 }
00177 #else
00178 #define ossl_s_ciphers rb_f_notimplement
00179 #endif
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 static VALUE
00191 ossl_cipher_reset(VALUE self)
00192 {
00193 EVP_CIPHER_CTX *ctx;
00194
00195 GetCipher(self, ctx);
00196 if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1) != 1)
00197 ossl_raise(eCipherError, NULL);
00198
00199 return self;
00200 }
00201
00202 static VALUE
00203 ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
00204 {
00205 EVP_CIPHER_CTX *ctx;
00206 unsigned char key[EVP_MAX_KEY_LENGTH], *p_key = NULL;
00207 unsigned char iv[EVP_MAX_IV_LENGTH], *p_iv = NULL;
00208 VALUE pass, init_v;
00209
00210 if(rb_scan_args(argc, argv, "02", &pass, &init_v) > 0){
00211
00212
00213
00214
00215
00216 VALUE cname = rb_class_path(rb_obj_class(self));
00217 rb_warn("arguments for %"PRIsVALUE"#encrypt and %"PRIsVALUE"#decrypt were deprecated; "
00218 "use %"PRIsVALUE"#pkcs5_keyivgen to derive key and IV",
00219 cname, cname, cname);
00220 StringValue(pass);
00221 GetCipher(self, ctx);
00222 if (NIL_P(init_v)) memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv));
00223 else{
00224 StringValue(init_v);
00225 if (EVP_MAX_IV_LENGTH > RSTRING_LEN(init_v)) {
00226 memset(iv, 0, EVP_MAX_IV_LENGTH);
00227 memcpy(iv, RSTRING_PTR(init_v), RSTRING_LEN(init_v));
00228 }
00229 else memcpy(iv, RSTRING_PTR(init_v), sizeof(iv));
00230 }
00231 EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
00232 (unsigned char *)RSTRING_PTR(pass), RSTRING_LENINT(pass), 1, key, NULL);
00233 p_key = key;
00234 p_iv = iv;
00235 }
00236 else {
00237 GetCipher(self, ctx);
00238 }
00239 if (EVP_CipherInit_ex(ctx, NULL, NULL, p_key, p_iv, mode) != 1) {
00240 ossl_raise(eCipherError, NULL);
00241 }
00242
00243 return self;
00244 }
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 static VALUE
00259 ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self)
00260 {
00261 return ossl_cipher_init(argc, argv, self, 1);
00262 }
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276 static VALUE
00277 ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self)
00278 {
00279 return ossl_cipher_init(argc, argv, self, 0);
00280 }
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 static VALUE
00303 ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
00304 {
00305 EVP_CIPHER_CTX *ctx;
00306 const EVP_MD *digest;
00307 VALUE vpass, vsalt, viter, vdigest;
00308 unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH], *salt = NULL;
00309 int iter;
00310
00311 rb_scan_args(argc, argv, "13", &vpass, &vsalt, &viter, &vdigest);
00312 StringValue(vpass);
00313 if(!NIL_P(vsalt)){
00314 StringValue(vsalt);
00315 if(RSTRING_LEN(vsalt) != PKCS5_SALT_LEN)
00316 ossl_raise(eCipherError, "salt must be an 8-octet string");
00317 salt = (unsigned char *)RSTRING_PTR(vsalt);
00318 }
00319 iter = NIL_P(viter) ? 2048 : NUM2INT(viter);
00320 digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest);
00321 GetCipher(self, ctx);
00322 EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
00323 (unsigned char *)RSTRING_PTR(vpass), RSTRING_LENINT(vpass), iter, key, iv);
00324 if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
00325 ossl_raise(eCipherError, NULL);
00326 OPENSSL_cleanse(key, sizeof key);
00327 OPENSSL_cleanse(iv, sizeof iv);
00328
00329 return Qnil;
00330 }
00331
00332 static int
00333 ossl_cipher_update_long(EVP_CIPHER_CTX *ctx, unsigned char *out, long *out_len_ptr,
00334 const unsigned char *in, long in_len)
00335 {
00336 int out_part_len;
00337 long out_len = 0;
00338 #define UPDATE_LENGTH_LIMIT INT_MAX
00339
00340 #if SIZEOF_LONG > UPDATE_LENGTH_LIMIT
00341 if (in_len > UPDATE_LENGTH_LIMIT) {
00342 const int in_part_len = (UPDATE_LENGTH_LIMIT / 2 + 1) & ~1;
00343 do {
00344 if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0,
00345 &out_part_len, in, in_part_len))
00346 return 0;
00347 out_len += out_part_len;
00348 in += in_part_len;
00349 } while ((in_len -= in_part_len) > UPDATE_LENGTH_LIMIT);
00350 }
00351 #endif
00352 if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0,
00353 &out_part_len, in, (int)in_len))
00354 return 0;
00355 if (out_len_ptr) *out_len_ptr = out_len += out_part_len;
00356 return 1;
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372 static VALUE
00373 ossl_cipher_update(int argc, VALUE *argv, VALUE self)
00374 {
00375 EVP_CIPHER_CTX *ctx;
00376 unsigned char *in;
00377 long in_len, out_len;
00378 VALUE data, str;
00379
00380 rb_scan_args(argc, argv, "11", &data, &str);
00381
00382 StringValue(data);
00383 in = (unsigned char *)RSTRING_PTR(data);
00384 if ((in_len = RSTRING_LEN(data)) == 0)
00385 ossl_raise(rb_eArgError, "data must not be empty");
00386 GetCipher(self, ctx);
00387 out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
00388 if (out_len <= 0) {
00389 ossl_raise(rb_eRangeError,
00390 "data too big to make output buffer: %ld bytes", in_len);
00391 }
00392
00393 if (NIL_P(str)) {
00394 str = rb_str_new(0, out_len);
00395 } else {
00396 StringValue(str);
00397 rb_str_resize(str, out_len);
00398 }
00399
00400 if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len))
00401 ossl_raise(eCipherError, NULL);
00402 assert(out_len < RSTRING_LEN(str));
00403 rb_str_set_len(str, out_len);
00404
00405 return str;
00406 }
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 static VALUE
00423 ossl_cipher_final(VALUE self)
00424 {
00425 EVP_CIPHER_CTX *ctx;
00426 int out_len;
00427 VALUE str;
00428
00429 GetCipher(self, ctx);
00430 str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx));
00431 if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len))
00432 ossl_raise(eCipherError, NULL);
00433 assert(out_len <= RSTRING_LEN(str));
00434 rb_str_set_len(str, out_len);
00435
00436 return str;
00437 }
00438
00439
00440
00441
00442
00443
00444
00445
00446 static VALUE
00447 ossl_cipher_name(VALUE self)
00448 {
00449 EVP_CIPHER_CTX *ctx;
00450
00451 GetCipher(self, ctx);
00452
00453 return rb_str_new2(EVP_CIPHER_name(EVP_CIPHER_CTX_cipher(ctx)));
00454 }
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 static VALUE
00468 ossl_cipher_set_key(VALUE self, VALUE key)
00469 {
00470 EVP_CIPHER_CTX *ctx;
00471
00472 StringValue(key);
00473 GetCipher(self, ctx);
00474
00475 if (RSTRING_LEN(key) < EVP_CIPHER_CTX_key_length(ctx))
00476 ossl_raise(eCipherError, "key length too short");
00477
00478 if (EVP_CipherInit_ex(ctx, NULL, NULL, (unsigned char *)RSTRING_PTR(key), NULL, -1) != 1)
00479 ossl_raise(eCipherError, NULL);
00480
00481 return key;
00482 }
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499 static VALUE
00500 ossl_cipher_set_iv(VALUE self, VALUE iv)
00501 {
00502 EVP_CIPHER_CTX *ctx;
00503
00504 StringValue(iv);
00505 GetCipher(self, ctx);
00506
00507 if (RSTRING_LEN(iv) < EVP_CIPHER_CTX_iv_length(ctx))
00508 ossl_raise(eCipherError, "iv length too short");
00509
00510 if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, (unsigned char *)RSTRING_PTR(iv), -1) != 1)
00511 ossl_raise(eCipherError, NULL);
00512
00513 return iv;
00514 }
00515
00516 #ifdef HAVE_AUTHENTICATED_ENCRYPTION
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535 static VALUE
00536 ossl_cipher_set_auth_data(VALUE self, VALUE data)
00537 {
00538 EVP_CIPHER_CTX *ctx;
00539 unsigned char *in;
00540 long in_len, out_len;
00541
00542 StringValue(data);
00543
00544 in = (unsigned char *) RSTRING_PTR(data);
00545 in_len = RSTRING_LEN(data);
00546
00547 GetCipher(self, ctx);
00548
00549 if (!ossl_cipher_update_long(ctx, NULL, &out_len, in, in_len))
00550 ossl_raise(eCipherError, "couldn't set additional authenticated data");
00551
00552 return data;
00553 }
00554
00555 #define ossl_is_gcm(nid) (nid) == NID_aes_128_gcm || \
00556 (nid) == NID_aes_192_gcm || \
00557 (nid) == NID_aes_256_gcm
00558
00559 static VALUE
00560 ossl_get_gcm_auth_tag(EVP_CIPHER_CTX *ctx, int len)
00561 {
00562 unsigned char *tag;
00563 VALUE ret;
00564
00565 tag = ALLOC_N(unsigned char, len);
00566
00567 if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, len, tag))
00568 ossl_raise(eCipherError, "retrieving the authentication tag failed");
00569
00570 ret = rb_str_new((const char *) tag, len);
00571 xfree(tag);
00572 return ret;
00573 }
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 static VALUE
00590 ossl_cipher_get_auth_tag(int argc, VALUE *argv, VALUE self)
00591 {
00592 VALUE vtag_len;
00593 EVP_CIPHER_CTX *ctx;
00594 int nid, tag_len;
00595
00596 if (rb_scan_args(argc, argv, "01", &vtag_len) == 0) {
00597 tag_len = 16;
00598 } else {
00599 tag_len = NUM2INT(vtag_len);
00600 }
00601
00602 GetCipher(self, ctx);
00603 nid = EVP_CIPHER_CTX_nid(ctx);
00604
00605 if (ossl_is_gcm(nid)) {
00606 return ossl_get_gcm_auth_tag(ctx, tag_len);
00607 } else {
00608 ossl_raise(eCipherError, "authentication tag not supported by this cipher");
00609 return Qnil;
00610 }
00611 }
00612
00613 static inline void
00614 ossl_set_gcm_auth_tag(EVP_CIPHER_CTX *ctx, unsigned char *tag, int tag_len)
00615 {
00616 if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, tag_len, tag))
00617 ossl_raise(eCipherError, "unable to set GCM tag");
00618 }
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632 static VALUE
00633 ossl_cipher_set_auth_tag(VALUE self, VALUE vtag)
00634 {
00635 EVP_CIPHER_CTX *ctx;
00636 int nid;
00637 unsigned char *tag;
00638 int tag_len;
00639
00640 StringValue(vtag);
00641 tag = (unsigned char *) RSTRING_PTR(vtag);
00642 tag_len = RSTRING_LENINT(vtag);
00643
00644 GetCipher(self, ctx);
00645 nid = EVP_CIPHER_CTX_nid(ctx);
00646
00647 if (ossl_is_gcm(nid)) {
00648 ossl_set_gcm_auth_tag(ctx, tag, tag_len);
00649 } else {
00650 ossl_raise(eCipherError, "authentication tag not supported by this cipher");
00651 }
00652
00653 return vtag;
00654 }
00655
00656
00657
00658
00659
00660
00661
00662
00663 static VALUE
00664 ossl_cipher_is_authenticated(VALUE self)
00665 {
00666 EVP_CIPHER_CTX *ctx;
00667 int nid;
00668
00669 GetCipher(self, ctx);
00670 nid = EVP_CIPHER_CTX_nid(ctx);
00671
00672 if (ossl_is_gcm(nid)) {
00673 return Qtrue;
00674 } else {
00675 return Qfalse;
00676 }
00677 }
00678 #else
00679 #define ossl_cipher_set_auth_data rb_f_notimplement
00680 #define ossl_cipher_get_auth_tag rb_f_notimplement
00681 #define ossl_cipher_set_auth_tag rb_f_notimplement
00682 #define ossl_cipher_is_authenticated rb_f_notimplement
00683 #endif
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697 static VALUE
00698 ossl_cipher_set_key_length(VALUE self, VALUE key_length)
00699 {
00700 int len = NUM2INT(key_length);
00701 EVP_CIPHER_CTX *ctx;
00702
00703 GetCipher(self, ctx);
00704 if (EVP_CIPHER_CTX_set_key_length(ctx, len) != 1)
00705 ossl_raise(eCipherError, NULL);
00706
00707 return key_length;
00708 }
00709
00710 #if defined(HAVE_EVP_CIPHER_CTX_SET_PADDING)
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721 static VALUE
00722 ossl_cipher_set_padding(VALUE self, VALUE padding)
00723 {
00724 EVP_CIPHER_CTX *ctx;
00725 int pad = NUM2INT(padding);
00726
00727 GetCipher(self, ctx);
00728 if (EVP_CIPHER_CTX_set_padding(ctx, pad) != 1)
00729 ossl_raise(eCipherError, NULL);
00730 return padding;
00731 }
00732 #else
00733 #define ossl_cipher_set_padding rb_f_notimplement
00734 #endif
00735
00736 #define CIPHER_0ARG_INT(func) \
00737 static VALUE \
00738 ossl_cipher_##func(VALUE self) \
00739 { \
00740 EVP_CIPHER_CTX *ctx; \
00741 GetCipher(self, ctx); \
00742 return INT2NUM(EVP_CIPHER_##func(EVP_CIPHER_CTX_cipher(ctx))); \
00743 }
00744
00745
00746
00747
00748
00749
00750
00751 CIPHER_0ARG_INT(key_length)
00752
00753
00754
00755
00756
00757
00758 CIPHER_0ARG_INT(iv_length)
00759
00760
00761
00762
00763
00764
00765 CIPHER_0ARG_INT(block_size)
00766
00767
00768
00769
00770 void
00771 Init_ossl_cipher(void)
00772 {
00773 #if 0
00774 mOSSL = rb_define_module("OpenSSL");
00775 #endif
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974 cCipher = rb_define_class_under(mOSSL, "Cipher", rb_cObject);
00975 eCipherError = rb_define_class_under(cCipher, "CipherError", eOSSLError);
00976
00977 rb_define_alloc_func(cCipher, ossl_cipher_alloc);
00978 rb_define_copy_func(cCipher, ossl_cipher_copy);
00979 rb_define_module_function(cCipher, "ciphers", ossl_s_ciphers, 0);
00980 rb_define_method(cCipher, "initialize", ossl_cipher_initialize, 1);
00981 rb_define_method(cCipher, "reset", ossl_cipher_reset, 0);
00982 rb_define_method(cCipher, "encrypt", ossl_cipher_encrypt, -1);
00983 rb_define_method(cCipher, "decrypt", ossl_cipher_decrypt, -1);
00984 rb_define_method(cCipher, "pkcs5_keyivgen", ossl_cipher_pkcs5_keyivgen, -1);
00985 rb_define_method(cCipher, "update", ossl_cipher_update, -1);
00986 rb_define_method(cCipher, "final", ossl_cipher_final, 0);
00987 rb_define_method(cCipher, "name", ossl_cipher_name, 0);
00988 rb_define_method(cCipher, "key=", ossl_cipher_set_key, 1);
00989 rb_define_method(cCipher, "auth_data=", ossl_cipher_set_auth_data, 1);
00990 rb_define_method(cCipher, "auth_tag=", ossl_cipher_set_auth_tag, 1);
00991 rb_define_method(cCipher, "auth_tag", ossl_cipher_get_auth_tag, -1);
00992 rb_define_method(cCipher, "authenticated?", ossl_cipher_is_authenticated, 0);
00993 rb_define_method(cCipher, "key_len=", ossl_cipher_set_key_length, 1);
00994 rb_define_method(cCipher, "key_len", ossl_cipher_key_length, 0);
00995 rb_define_method(cCipher, "iv=", ossl_cipher_set_iv, 1);
00996 rb_define_method(cCipher, "iv_len", ossl_cipher_iv_length, 0);
00997 rb_define_method(cCipher, "block_size", ossl_cipher_block_size, 0);
00998 rb_define_method(cCipher, "padding=", ossl_cipher_set_padding, 1);
00999 }
01000
01001