Ruby  2.5.0dev(2017-10-22revision60238)
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 #if defined(RMD160_USE_OPENSSL)
7 #include "rmd160ossl.h"
8 #else
9 #include "rmd160.h"
10 #endif
11 
12 static const rb_digest_metadata_t rmd160 = {
16  sizeof(RMD160_CTX),
20 };
21 
22 /*
23  * Document-class: Digest::RMD160 < Digest::Base
24  * A class for calculating message digests using RIPEMD-160
25  * cryptographic hash function, designed by Hans Dobbertin, Antoon
26  * Bosselaers, and Bart Preneel.
27  *
28  * RMD160 calculates a digest of 160 bits (20 bytes).
29  *
30  * == Examples
31  * require 'digest'
32  *
33  * # Compute a complete digest
34  * Digest::RMD160.hexdigest 'abc' #=> "8eb208f7..."
35  *
36  * # Compute digest by chunks
37  * rmd160 = Digest::RMD160.new # =>#<Digest::RMD160>
38  * rmd160.update "ab"
39  * rmd160 << "c" # alias for #update
40  * rmd160.hexdigest # => "8eb208f7..."
41  *
42  * # Use the same object to compute another digest
43  * rmd160.reset
44  * rmd160 << "message"
45  * rmd160.hexdigest # => "1dddbe1b..."
46  */
47 void
49 {
50  VALUE mDigest, cDigest_Base, cDigest_RMD160;
51 
52  rb_require("digest");
53 
54 #if 0
55  mDigest = rb_define_module("Digest"); /* let rdoc know */
56 #endif
57  mDigest = rb_path2class("Digest");
58  cDigest_Base = rb_path2class("Digest::Base");
59 
60  cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
61 
62 #undef RUBY_UNTYPED_DATA_WARNING
63 #define RUBY_UNTYPED_DATA_WARNING 0
64  rb_iv_set(cDigest_RMD160, "metadata",
65  Data_Wrap_Struct(0, 0, 0, (void *)&rmd160));
66 }
void Init_rmd160(void)
Definition: rmd160init.c:48
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:3095
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:693
VALUE rb_path2class(const char *)
Definition: variable.c:432
int(* rb_digest_hash_finish_func_t)(void *, unsigned char *)
Definition: digest.h:22
#define Data_Wrap_Struct(klass, mark, free, sval)
Definition: ruby.h:1142
VALUE rb_require(const char *)
Definition: load.c:1061
#define RMD160_DIGEST_LENGTH
Definition: rmd160.h:53
#define RUBY_DIGEST_API_VERSION
Definition: digest.h:18
#define RMD160_CTX
Definition: rmd160ossl.h:9
unsigned long VALUE
Definition: ruby.h:85
void RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
Definition: rmd160.c:353
void(* rb_digest_hash_update_func_t)(void *, unsigned char *, size_t)
Definition: digest.h:21
int RMD160_Finish(RMD160_CTX *context, uint8_t digest[20])
Definition: rmd160.c:417
int(* rb_digest_hash_init_func_t)(void *)
Definition: digest.h:20
VALUE rb_define_module(const char *name)
Definition: class.c:768
#define RMD160_BLOCK_LENGTH
Definition: rmd160.h:52
int RMD160_Init(RMD160_CTX *context)
Definition: rmd160.c:128