Ruby
2.0.0p247(2013-06-27revision41674)
|
00001 /* $RoughId: sha1init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */ 00002 /* $Id: sha1init.c 34816 2012-02-25 20:37:12Z naruse $ */ 00003 00004 #include "digest.h" 00005 #if defined(HAVE_OPENSSL_SHA_H) 00006 #include "sha1ossl.h" 00007 #else 00008 #include "sha1.h" 00009 #endif 00010 00011 static const rb_digest_metadata_t sha1 = { 00012 RUBY_DIGEST_API_VERSION, 00013 SHA1_DIGEST_LENGTH, 00014 SHA1_BLOCK_LENGTH, 00015 sizeof(SHA1_CTX), 00016 (rb_digest_hash_init_func_t)SHA1_Init, 00017 (rb_digest_hash_update_func_t)SHA1_Update, 00018 (rb_digest_hash_finish_func_t)SHA1_Finish, 00019 }; 00020 00021 /* 00022 * A class for calculating message digests using the SHA-1 Secure Hash 00023 * Algorithm by NIST (the US' National Institute of Standards and 00024 * Technology), described in FIPS PUB 180-1. 00025 */ 00026 void 00027 Init_sha1() 00028 { 00029 VALUE mDigest, cDigest_Base, cDigest_SHA1; 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_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base); 00040 00041 rb_ivar_set(cDigest_SHA1, rb_intern("metadata"), 00042 Data_Wrap_Struct(rb_cObject, 0, 0, (void *)&sha1)); 00043 } 00044