DEFINITIONS
This source file includes following functions.
- Init_sha1
1
2
3
4 #include "digest.h"
5 #include "sha1.h"
6
7 static algo_t sha1 = {
8 SHA1_DIGEST_LENGTH,
9 sizeof(SHA1_CTX),
10 (hash_init_func_t)SHA1_Init,
11 (hash_update_func_t)SHA1_Update,
12 (hash_end_func_t)SHA1_End,
13 (hash_final_func_t)SHA1_Final,
14 (hash_equal_func_t)SHA1_Equal,
15 };
16
17 void
18 Init_sha1()
19 {
20 VALUE mDigest, cDigest_Base, cDigest_SHA1;
21 ID id_metadata;
22
23 rb_require("digest.so");
24
25 mDigest = rb_path2class("Digest");
26 cDigest_Base = rb_path2class("Digest::Base");
27
28 cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
29
30 id_metadata = rb_intern("metadata");
31
32 rb_cvar_set(cDigest_SHA1, id_metadata,
33 Data_Wrap_Struct(rb_cObject, 0, 0, &sha1), Qtrue);
34 }