12 #define GetDigest(obj, ctx) do { \ 13 TypedData_Get_Struct((obj), EVP_MD_CTX, &ossl_digest_type, (ctx)); \ 15 ossl_raise(rb_eRuntimeError, "Digest CTX wasn't initialized!"); \ 28 ossl_digest_free(
void *ctx)
30 EVP_MD_CTX_destroy(ctx);
48 ASN1_OBJECT *oid =
NULL;
53 md = EVP_get_digestbyname(name);
55 oid = OBJ_txt2obj(name, 0);
56 md = EVP_get_digestbyobj(oid);
57 ASN1_OBJECT_free(oid);
66 md = EVP_MD_CTX_md(ctx);
78 ret = ossl_digest_alloc(
cDigest);
84 if (!EVP_DigestInit_ex(ctx, md,
NULL))
94 ossl_digest_alloc(
VALUE klass)
136 if (!EVP_DigestInit_ex(ctx, md,
NULL))
146 EVP_MD_CTX *ctx1, *ctx2;
149 if (
self == other)
return self;
159 if (!EVP_MD_CTX_copy(ctx1, ctx2)) {
174 ossl_digest_reset(
VALUE self)
179 if (EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx),
NULL) != 1) {
229 out_len = EVP_MD_CTX_size(ctx);
256 ossl_digest_name(
VALUE self)
262 return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx)));
278 ossl_digest_size(
VALUE self)
284 return INT2NUM(EVP_MD_CTX_size(ctx));
301 ossl_digest_block_length(
VALUE self)
307 return INT2NUM(EVP_MD_CTX_block_size(ctx));
#define RUBY_TYPED_FREE_IMMEDIATELY
#define TypedData_Wrap_Struct(klass, data_type, sval)
#define TypedData_Get_Struct(obj, type, data_type, sval)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_path2class(const char *)
#define RB_TYPE_P(obj, type)
VALUE rb_require(const char *)
VALUE ossl_digest_new(const EVP_MD *md)
VALUE rb_str_resize(VALUE, long)
void Init_ossl_digest(void)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
#define StringValueCStr(v)
void ossl_raise(VALUE exc, const char *fmt,...)
#define RTYPEDDATA_DATA(v)
#define rb_check_frozen(obj)
#define GetDigest(obj, ctx)
VALUE rb_define_module(const char *name)
VALUE ossl_digest_update(VALUE, VALUE)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_new(const char *, long)