Ruby
2.0.0p247(2013-06-27revision41674)
|
00001 /* $RoughId: md5init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */ 00002 /* $Id: md5init.c 34816 2012-02-25 20:37:12Z naruse $ */ 00003 00004 #include "digest.h" 00005 #if defined(HAVE_OPENSSL_MD5_H) 00006 #include "md5ossl.h" 00007 #else 00008 #include "md5.h" 00009 #endif 00010 00011 static const rb_digest_metadata_t md5 = { 00012 RUBY_DIGEST_API_VERSION, 00013 MD5_DIGEST_LENGTH, 00014 MD5_BLOCK_LENGTH, 00015 sizeof(MD5_CTX), 00016 (rb_digest_hash_init_func_t)MD5_Init, 00017 (rb_digest_hash_update_func_t)MD5_Update, 00018 (rb_digest_hash_finish_func_t)MD5_Finish, 00019 }; 00020 00021 /* 00022 * A class for calculating message digests using the MD5 00023 * Message-Digest Algorithm by RSA Data Security, Inc., described in 00024 * RFC1321. 00025 */ 00026 void 00027 Init_md5() 00028 { 00029 VALUE mDigest, cDigest_Base, cDigest_MD5; 00030 00031 rb_require("digest"); 00032 00033 #if 0 00034 mDigest = rb_define_module("Digest"); /* let rdoc know */ 00035 #endif 00036 mDigest = rb_path2class("Digest"); 00037 cDigest_Base = rb_path2class("Digest::Base"); 00038 00039 cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base); 00040 00041 rb_ivar_set(cDigest_MD5, rb_intern("metadata"), 00042 Data_Wrap_Struct(rb_cObject, 0, 0, (void *)&md5)); 00043 } 00044