Ruby  3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
rmd160init.c
Go to the documentation of this file.
1 /* $RoughId: rmd160init.c,v 1.3 2001/07/13 20:00:43 knu Exp $ */
2 /* $Id$ */
3 
4 #include <ruby/ruby.h>
5 #include "../digest.h"
6 #include "rmd160.h"
7 
8 static const rb_digest_metadata_t rmd160 = {
12  sizeof(RMD160_CTX),
16 };
17 
18 /*
19  * Document-class: Digest::RMD160 < Digest::Base
20  * A class for calculating message digests using RIPEMD-160
21  * cryptographic hash function, designed by Hans Dobbertin, Antoon
22  * Bosselaers, and Bart Preneel.
23  *
24  * RMD160 calculates a digest of 160 bits (20 bytes).
25  *
26  * == Examples
27  * require 'digest'
28  *
29  * # Compute a complete digest
30  * Digest::RMD160.hexdigest 'abc' #=> "8eb208f7..."
31  *
32  * # Compute digest by chunks
33  * rmd160 = Digest::RMD160.new # =>#<Digest::RMD160>
34  * rmd160.update "ab"
35  * rmd160 << "c" # alias for #update
36  * rmd160.hexdigest # => "8eb208f7..."
37  *
38  * # Use the same object to compute another digest
39  * rmd160.reset
40  * rmd160 << "message"
41  * rmd160.hexdigest # => "1dddbe1b..."
42  */
43 void
45 {
46  VALUE mDigest, cDigest_Base, cDigest_RMD160;
47 
48 #if 0
49  mDigest = rb_define_module("Digest"); /* let rdoc know */
50 #endif
51  mDigest = rb_digest_namespace();
52  cDigest_Base = rb_path2class("Digest::Base");
53 
54  cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
55 
56  rb_iv_set(cDigest_RMD160, "metadata", rb_digest_make_metadata(&rmd160));
57 }
rb_digest_hash_finish_func_t
int(* rb_digest_hash_finish_func_t)(void *, unsigned char *)
Definition: digest.h:22
rb_define_module
VALUE rb_define_module(const char *name)
Definition: class.c:887
RMD160_DIGEST_LENGTH
#define RMD160_DIGEST_LENGTH
Definition: rmd160.h:53
ruby.h
rb_iv_set
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:3670
RUBY_DIGEST_API_VERSION
#define RUBY_DIGEST_API_VERSION
Definition: digest.h:18
rb_digest_metadata_t
Definition: digest.h:24
rmd160.h
RMD160_BLOCK_LENGTH
#define RMD160_BLOCK_LENGTH
Definition: rmd160.h:52
VALUE
unsigned long VALUE
Definition: value.h:38
Init_rmd160
void Init_rmd160(void)
Definition: rmd160init.c:44
RMD160_CTX
Definition: rmd160.h:31
RMD160_Init
int RMD160_Init(RMD160_CTX *context)
Definition: rmd160.c:128
RMD160_Finish
int RMD160_Finish(RMD160_CTX *context, uint8_t digest[20])
Definition: rmd160.c:417
rb_digest_hash_init_func_t
int(* rb_digest_hash_init_func_t)(void *)
Definition: digest.h:20
rb_path2class
VALUE rb_path2class(const char *)
Definition: variable.c:289
RMD160_Update
void RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
Definition: rmd160.c:353
rb_define_class_under
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:809
rb_digest_hash_update_func_t
void(* rb_digest_hash_update_func_t)(void *, unsigned char *, size_t)
Definition: digest.h:21