ext/digest/sha1/sha1init.c

Go to the documentation of this file.
00001 /* $RoughId: sha1init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
00002 /* $Id: sha1init.c 28341 2010-06-16 09:38:14Z knu $ */
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     mDigest = rb_path2class("Digest");
00034     cDigest_Base = rb_path2class("Digest::Base");
00035 
00036     cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
00037 
00038     rb_ivar_set(cDigest_SHA1, rb_intern("metadata"),
00039       Data_Wrap_Struct(rb_cObject, 0, 0, (void *)&sha1));
00040 }
00041 

Generated on Wed Aug 10 09:16:56 2011 for Ruby by  doxygen 1.4.7