Ruby  2.0.0p247(2013-06-27revision41674)
sha1init.c
Go to the documentation of this file.
1 /* $RoughId: sha1init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
2 /* $Id: sha1init.c 34816 2012-02-25 20:37:12Z naruse $ */
3 
4 #include "digest.h"
5 #if defined(HAVE_OPENSSL_SHA_H)
6 #include "sha1ossl.h"
7 #else
8 #include "sha1.h"
9 #endif
10 
11 static const rb_digest_metadata_t sha1 = {
15  sizeof(SHA1_CTX),
19 };
20 
21 /*
22  * A class for calculating message digests using the SHA-1 Secure Hash
23  * Algorithm by NIST (the US' National Institute of Standards and
24  * Technology), described in FIPS PUB 180-1.
25  */
26 void
28 {
29  VALUE mDigest, cDigest_Base, cDigest_SHA1;
30 
31  rb_require("digest");
32 
33 #if 0
34  mDigest = rb_define_module("Digest"); /* let rdoc know */
35 #endif
36  mDigest = rb_path2class("Digest");
37  cDigest_Base = rb_path2class("Digest::Base");
38 
39  cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
40 
41  rb_ivar_set(cDigest_SHA1, rb_intern("metadata"),
42  Data_Wrap_Struct(rb_cObject, 0, 0, (void *)&sha1));
43 }
#define SHA1_DIGEST_LENGTH
Definition: sha1.h:36
VALUE rb_require(const char *)
Definition: load.c:997
#define SHA1_CTX
Definition: sha1ossl.h:9
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:545
VALUE rb_path2class(const char *)
Definition: variable.c:366
void SHA1_Init(SHA1_CTX *context)
Definition: sha1.c:202
#define SHA1_BLOCK_LENGTH
Definition: sha1.h:35
return Data_Wrap_Struct(CLASS_OF(interp), 0, ip_free, slave)
#define RUBY_DIGEST_API_VERSION
Definition: digest.h:18
void(* rb_digest_hash_finish_func_t)(void *, unsigned char *)
Definition: digest.h:22
void Init_sha1()
Definition: sha1init.c:27
void(* rb_digest_hash_update_func_t)(void *, unsigned char *, size_t)
Definition: digest.h:21
void SHA1_Finish(SHA1_CTX *context, uint8_t digest[20])
Definition: sha1.c:247
VALUE rb_ivar_set(VALUE, ID, VALUE)
Definition: variable.c:1123
void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
Definition: sha1.c:220
RUBY_EXTERN VALUE rb_cObject
Definition: ripper.y:1426
unsigned long VALUE
Definition: ripper.y:104
void(* rb_digest_hash_init_func_t)(void *)
Definition: digest.h:20
VALUE rb_define_module(const char *name)
Definition: class.c:617
#define rb_intern(str)
static const rb_digest_metadata_t sha1
Definition: sha1init.c:11