digest.c File Reference
`#include "digest.h"`

Go to the source code of this file.

## Functions

RUBY_EXTERN void | Init_digest_base (void)
static VALUE | hexencode_str_new (VALUE str_digest)
static VALUE | rb_digest_s_hexencode (VALUE klass, VALUE str)
| NORETURN (static void rb_digest_instance_method_unimpl(VALUE self, const char *method))
static void | rb_digest_instance_method_unimpl (VALUE self, const char *method)
static VALUE | rb_digest_instance_update (VALUE self, VALUE str)
static VALUE | rb_digest_instance_finish (VALUE self)
static VALUE | rb_digest_instance_reset (VALUE self)
static VALUE | rb_digest_instance_new (VALUE self)
static VALUE | rb_digest_instance_digest (int argc, VALUE *argv, VALUE self)
static VALUE | rb_digest_instance_digest_bang (VALUE self)
static VALUE | rb_digest_instance_hexdigest (int argc, VALUE *argv, VALUE self)
static VALUE | rb_digest_instance_hexdigest_bang (VALUE self)
static VALUE | rb_digest_instance_to_s (VALUE self)
static VALUE | rb_digest_instance_inspect (VALUE self)
static VALUE | rb_digest_instance_equal (VALUE self, VALUE other)
static VALUE | rb_digest_instance_digest_length (VALUE self)
static VALUE | rb_digest_instance_length (VALUE self)
static VALUE | rb_digest_instance_block_length (VALUE self)
static VALUE | rb_digest_class_s_digest (int argc, VALUE *argv, VALUE klass)
static VALUE | rb_digest_class_s_hexdigest (int argc, VALUE *argv, VALUE klass)
static VALUE | rb_digest_class_init (VALUE self)
static rb_digest_metadata_t * | get_digest_base_metadata (VALUE klass)
static VALUE | rb_digest_base_alloc (VALUE klass)
static VALUE | rb_digest_base_copy (VALUE copy, VALUE obj)
static VALUE | rb_digest_base_reset (VALUE self)
static VALUE | rb_digest_base_update (VALUE self, VALUE str)
static VALUE | rb_digest_base_finish (VALUE self)
static VALUE | rb_digest_base_digest_length (VALUE self)
static VALUE | rb_digest_base_block_length (VALUE self)
void | Init_digest (void)

## Variables

static VALUE | rb_mDigest
static VALUE | rb_mDigest_Instance
static VALUE | rb_cDigest_Class
static VALUE | rb_cDigest_Base
static ID | id_reset
static ID | id_update
static ID | id_finish
static ID | id_digest
static ID | id_hexdigest
static ID | id_digest_length
static ID | id_metadata

## Function Documentation

static rb_digest_metadata_t* get_digest_base_metadata | ( | VALUE | klass | ) |

static

Definition at line 480 of file digest.c.

References rb_digest_metadata_t::api_version, Data_Get_Struct, id_metadata, NIL_P, p, rb_class_superclass(), rb_eRuntimeError, rb_ivar_defined(), rb_ivar_get(), and rb_raise().

Referenced by rb_digest_base_alloc(), rb_digest_base_block_length(), rb_digest_base_copy(), rb_digest_base_digest_length(), rb_digest_base_finish(), rb_digest_base_reset(), and rb_digest_base_update().

static VALUE hexencode_str_new | ( | VALUE | str_digest | ) |

static

Definition at line 82 of file digest.c.

References i, LONG_MAX, p, rb_eRuntimeError, rb_raise(), rb_str_new(), RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by rb_digest_class_s_hexdigest(), rb_digest_instance_hexdigest(), rb_digest_instance_hexdigest_bang(), and rb_digest_s_hexencode().

void Init_digest | ( | void |  | ) |

Definition at line 631 of file digest.c.

References id_digest, id_digest_length, id_finish, id_hexdigest, id_metadata, id_reset, id_update, rb_cDigest_Base, rb_cDigest_Class, rb_cObject, rb_define_alloc_func(), rb_define_class_under(), rb_define_method(), rb_define_module(), rb_define_module_function(), rb_define_module_under(), rb_define_private_method(), rb_define_singleton_method(), rb_digest_base_alloc(), rb_digest_base_block_length(), rb_digest_base_copy(), rb_digest_base_digest_length(), rb_digest_base_finish(), rb_digest_base_reset(), rb_digest_base_update(), rb_digest_class_init(), rb_digest_class_s_digest(), rb_digest_class_s_hexdigest(), rb_digest_instance_block_length(), rb_digest_instance_digest(), rb_digest_instance_digest_bang(), rb_digest_instance_digest_length(), rb_digest_instance_equal(), rb_digest_instance_finish(), rb_digest_instance_hexdigest(), rb_digest_instance_hexdigest_bang(), rb_digest_instance_inspect(), rb_digest_instance_length(), rb_digest_instance_new(), rb_digest_instance_reset(), rb_digest_instance_to_s(), rb_digest_instance_update(), rb_digest_s_hexencode(), rb_include_module(), rb_intern, rb_mDigest, and rb_mDigest_Instance.

RUBY_EXTERN void Init_digest_base | ( | void |  | ) |

NORETURN | ( | static void | rb_digest_instance_method_unimplVALUE self, const char *method | ) |

static VALUE rb_digest_base_alloc | ( | VALUE | klass | ) |

static

Definition at line 514 of file digest.c.

References rb_digest_metadata_t::ctx_size, Data_Wrap_Struct, get_digest_base_metadata(), rb_digest_metadata_t::init_func, rb_cDigest_Base, rb_eNotImpError, rb_raise(), xfree(), and xmalloc.

Referenced by Init_digest().

static VALUE rb_digest_base_block_length | ( | VALUE | self | ) |

static

Definition at line 621 of file digest.c.

References rb_digest_metadata_t::block_len, get_digest_base_metadata(), INT2NUM(), and rb_obj_class().

Referenced by Init_digest().

static VALUE rb_digest_base_copy | ( | VALUE | copy,
|  | VALUE | obj
| ) |  |

static

Definition at line 536 of file digest.c.

References rb_digest_metadata_t::ctx_size, Data_Get_Struct, get_digest_base_metadata(), rb_check_frozen, and rb_obj_class().

Referenced by Init_digest().

static VALUE rb_digest_base_digest_length | ( | VALUE | self | ) |

static

Definition at line 610 of file digest.c.

References rb_digest_metadata_t::digest_len, get_digest_base_metadata(), INT2NUM(), and rb_obj_class().

Referenced by Init_digest().

static VALUE rb_digest_base_finish | ( | VALUE | self | ) |

static

Definition at line 589 of file digest.c.

References Data_Get_Struct, rb_digest_metadata_t::digest_len, rb_digest_metadata_t::finish_func, get_digest_base_metadata(), rb_digest_metadata_t::init_func, rb_obj_class(), rb_str_new(), and RSTRING_PTR.

Referenced by Init_digest().

static VALUE rb_digest_base_reset | ( | VALUE | self | ) |

static

Definition at line 556 of file digest.c.

References Data_Get_Struct, get_digest_base_metadata(), rb_digest_metadata_t::init_func, and rb_obj_class().

Referenced by Init_digest().

static VALUE rb_digest_base_update | ( | VALUE | self,
|  | VALUE | str
| ) |  |

static

Definition at line 572 of file digest.c.

References Data_Get_Struct, get_digest_base_metadata(), rb_obj_class(), RSTRING_LEN, RSTRING_PTR, StringValue, and rb_digest_metadata_t::update_func.

Referenced by Init_digest().

static VALUE rb_digest_class_init | ( | VALUE | self | ) |

static

Definition at line 467 of file digest.c.

Referenced by Init_digest().

static VALUE rb_digest_class_s_digest | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |

static

Definition at line 431 of file digest.c.

References id_digest, rb_eArgError, rb_funcall(), rb_obj_alloc(), rb_obj_call_init(), rb_raise(), and StringValue.

Referenced by Init_digest().

static VALUE rb_digest_class_s_hexdigest | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |

static

Definition at line 460 of file digest.c.

References hexencode_str_new(), id_digest, and rb_funcall2().

Referenced by Init_digest().

static VALUE rb_digest_instance_block_length | ( | VALUE | self | ) |

static

Definition at line 409 of file digest.c.

References rb_digest_instance_method_unimpl().

Referenced by Init_digest().

static VALUE rb_digest_instance_digest | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 219 of file digest.c.

References id_finish, id_reset, id_update, rb_funcall(), rb_obj_clone(), and rb_scan_args().

Referenced by Init_digest(), rb_digest_instance_digest_length(), and rb_digest_instance_equal().

static VALUE rb_digest_instance_digest_bang | ( | VALUE | self | ) |

static

Definition at line 243 of file digest.c.

References id_finish, id_reset, and rb_funcall().

Referenced by Init_digest().

static VALUE rb_digest_instance_digest_length | ( | VALUE | self | ) |

static

Definition at line 377 of file digest.c.

References INT2NUM(), rb_digest_instance_digest(), RSTRING_LEN, and StringValue.

Referenced by Init_digest().

static VALUE rb_digest_instance_equal | ( | VALUE | self,
|  | VALUE | other
| ) |  |

static

Definition at line 344 of file digest.c.

References Qfalse, Qtrue, rb_digest_instance_digest(), rb_digest_instance_to_s(), rb_mDigest_Instance, rb_obj_is_kind_of(), rb_str_cmp(), RSTRING_LEN, and StringValue.

Referenced by Init_digest().

static VALUE rb_digest_instance_finish | ( | VALUE | self | ) |

static

Definition at line 172 of file digest.c.

References rb_digest_instance_method_unimpl().

Referenced by Init_digest().

static VALUE rb_digest_instance_hexdigest | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 264 of file digest.c.

References hexencode_str_new(), id_finish, id_reset, id_update, rb_funcall(), rb_obj_clone(), and rb_scan_args().

Referenced by Init_digest(), and rb_digest_instance_inspect().

static VALUE rb_digest_instance_hexdigest_bang | ( | VALUE | self | ) |

static

Definition at line 288 of file digest.c.

References hexencode_str_new(), id_finish, id_reset, and rb_funcall().

Referenced by Init_digest().

static VALUE rb_digest_instance_inspect | ( | VALUE | self | ) |

static

Definition at line 315 of file digest.c.

References rb_digest_instance_hexdigest(), rb_obj_classname(), rb_str_buf_append(), rb_str_buf_cat2(), rb_str_buf_new(), and strlen().

Referenced by Init_digest().

static VALUE rb_digest_instance_length | ( | VALUE | self | ) |

static

Definition at line 395 of file digest.c.

References id_digest_length, and rb_funcall().

Referenced by Init_digest().

static void rb_digest_instance_method_unimpl | ( | VALUE | self,
|  | const char * | method
| ) |  |

static

Definition at line 136 of file digest.c.

References rb_eRuntimeError, rb_obj_classname(), and rb_raise().

Referenced by rb_digest_instance_block_length(), rb_digest_instance_finish(), rb_digest_instance_reset(), and rb_digest_instance_update().

static VALUE rb_digest_instance_new | ( | VALUE | self | ) |

static

Definition at line 199 of file digest.c.

References id_reset, rb_funcall(), and rb_obj_clone().

Referenced by Init_digest().

static VALUE rb_digest_instance_reset | ( | VALUE | self | ) |

static

Definition at line 186 of file digest.c.

References rb_digest_instance_method_unimpl().

Referenced by Init_digest().

static VALUE rb_digest_instance_to_s | ( | VALUE | self | ) |

static

Definition at line 303 of file digest.c.

References id_hexdigest, and rb_funcall().

Referenced by Init_digest(), and rb_digest_instance_equal().

static VALUE rb_digest_instance_update | ( | VALUE | self,
|  | VALUE | str
| ) |  |

static

Definition at line 154 of file digest.c.

References rb_digest_instance_method_unimpl().

Referenced by Init_digest().

static VALUE rb_digest_s_hexencode | ( | VALUE | klass,
|  | VALUE | str
| ) |  |

static

Definition at line 121 of file digest.c.

References hexencode_str_new().

Referenced by Init_digest().

## Variable Documentation

ID id_digest

static

Definition at line 23 of file digest.c.

Referenced by Init_digest(), rb_digest_class_s_digest(), and rb_digest_class_s_hexdigest().

ID id_digest_length

static

Definition at line 23 of file digest.c.

Referenced by Init_digest(), and rb_digest_instance_length().

ID id_finish

static

Definition at line 23 of file digest.c.

Referenced by Init_digest(), rb_digest_instance_digest(), rb_digest_instance_digest_bang(), rb_digest_instance_hexdigest(), and rb_digest_instance_hexdigest_bang().

ID id_hexdigest

static

Definition at line 23 of file digest.c.

Referenced by Init_digest(), and rb_digest_instance_to_s().

ID id_metadata

static

Definition at line 24 of file digest.c.

Referenced by get_digest_base_metadata(), Init_digest(), and Init_sha2().

ID id_reset

static

Definition at line 23 of file digest.c.

Referenced by Init_digest(), rb_digest_instance_digest(), rb_digest_instance_digest_bang(), rb_digest_instance_hexdigest(), rb_digest_instance_hexdigest_bang(), and rb_digest_instance_new().

ID id_update

static

Definition at line 23 of file digest.c.

Referenced by Init_digest(), rb_digest_instance_digest(), and rb_digest_instance_hexdigest().

VALUE rb_cDigest_Base

static

Definition at line 21 of file digest.c.

Referenced by Init_digest(), and rb_digest_base_alloc().

VALUE rb_cDigest_Class

static

Definition at line 20 of file digest.c.

Referenced by Init_digest().

VALUE rb_mDigest

static

Definition at line 18 of file digest.c.

Referenced by Init_digest().

VALUE rb_mDigest_Instance

static

Definition at line 19 of file digest.c.

Referenced by Init_digest(), and rb_digest_instance_equal().