Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

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 = {
13 RUBY_DIGEST_API_VERSION,
14 RMD160_DIGEST_LENGTH,
15 RMD160_BLOCK_LENGTH,
16 sizeof(RMD160_CTX),
17 (rb_digest_hash_init_func_t)RMD160_Init,
18 (rb_digest_hash_update_func_t)RMD160_Update,
19 (rb_digest_hash_finish_func_t)RMD160_Finish,
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
48 Init_rmd160(void)
49 {
50 VALUE mDigest, cDigest_Base, cDigest_RMD160;
51
52 #if 0
53 mDigest = rb_define_module("Digest"); /* let rdoc know */
54 #endif
55 mDigest = rb_digest_namespace();
56 cDigest_Base = rb_path2class("Digest::Base");
57
58 cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
59
60 #undef RUBY_UNTYPED_DATA_WARNING
61 #define RUBY_UNTYPED_DATA_WARNING 0
62 rb_iv_set(cDigest_RMD160, "metadata",
63 Data_Wrap_Struct(0, 0, 0, (void *)&rmd160));
64 }
rb_digest_hash_finish_func_t
int(* rb_digest_hash_finish_func_t)(void *, unsigned char *)
Definition: digest.h:22
VALUE
unsigned long VALUE
Definition: ruby.h:102
rb_define_module
VALUE rb_define_module(const char *name)
Definition: class.c:772
Data_Wrap_Struct
#define Data_Wrap_Struct(klass, mark, free, sval)
Definition: ruby.h:1211
RMD160_DIGEST_LENGTH
#define RMD160_DIGEST_LENGTH
Definition: rmd160.h:53
ruby.h
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
Init_rmd160
void Init_rmd160(void)
Definition: rmd160init.c:48
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:268
RMD160_CTX
#define RMD160_CTX
Definition: rmd160ossl.h:9
rmd160ossl.h
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:698
rb_digest_hash_update_func_t
void(* rb_digest_hash_update_func_t)(void *, unsigned char *, size_t)
Definition: digest.h:21
rb_iv_set
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:3307