Ruby: ext/digest/rmd160/rmd160init.c Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

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
8static const rb_digest_metadata_t rmd160 = {
9 RUBY_DIGEST_API_VERSION,
10 RMD160_DIGEST_LENGTH,
11 RMD160_BLOCK_LENGTH,
12 sizeof(RMD160_CTX),
13 (rb_digest_hash_init_func_t)RMD160_Init,
14 (rb_digest_hash_update_func_t)RMD160_Update,
15 (rb_digest_hash_finish_func_t)RMD160_Finish,
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 */
43void
44Init_rmd160(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}
RUBY_DIGEST_API_VERSION
#define RUBY_DIGEST_API_VERSION
Definition: digest.h:18
rb_digest_hash_update_func_t
void(* rb_digest_hash_update_func_t)(void *, unsigned char *, size_t)
Definition: digest.h:21
rb_digest_hash_init_func_t
int(* rb_digest_hash_init_func_t)(void *)
Definition: digest.h:20
rb_digest_hash_finish_func_t
int(* rb_digest_hash_finish_func_t)(void *, unsigned char *)
Definition: digest.h:22
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:797
rb_define_module
VALUE rb_define_module(const char *name)
Definition: class.c:871
rb_path2class
VALUE rb_path2class(const char *)
Definition: variable.c:287
rb_iv_set
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:3580
rmd160.h
RMD160_Update
#define RMD160_Update
Definition: rmd160.h:41
RMD160_DIGEST_LENGTH
#define RMD160_DIGEST_LENGTH
Definition: rmd160.h:53
RMD160_BLOCK_LENGTH
#define RMD160_BLOCK_LENGTH
Definition: rmd160.h:52
RMD160_Finish
#define RMD160_Finish
Definition: rmd160.h:42
RMD160_Init
#define RMD160_Init
Definition: rmd160.h:39
Init_rmd160
void Init_rmd160(void)
Definition: rmd160init.c:44
ruby.h
RMD160_CTX
Definition: rmd160.h:31
rb_digest_metadata_t
Definition: digest.h:24
VALUE
unsigned long VALUE
Definition: value.h:38