Ruby
3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
|
Go to the documentation of this file.
12 #define NewHMAC(klass) \
13 TypedData_Wrap_Struct((klass), &ossl_hmac_type, 0)
14 #define GetHMAC(obj, ctx) do { \
15 TypedData_Get_Struct((obj), EVP_MD_CTX, &ossl_hmac_type, (ctx)); \
17 ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \
35 ossl_hmac_free(
void *ctx)
49 ossl_hmac_alloc(
VALUE klass)
100 pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC,
NULL,
102 RSTRING_LENINT(
key));
119 EVP_MD_CTX *ctx1, *ctx2;
122 if (
self == other)
return self;
126 if (EVP_MD_CTX_copy(ctx1, ctx2) != 1)
175 ossl_hmac_digest(
VALUE self)
199 ossl_hmac_hexdigest(
VALUE self)
202 unsigned char buf[EVP_MAX_MD_SIZE];
207 if (EVP_DigestSignFinal(ctx,
buf, &buf_len) != 1)
235 ossl_hmac_reset(
VALUE self)
242 if (EVP_DigestSignInit(ctx,
NULL, EVP_MD_CTX_md(ctx),
NULL, pkey) != 1)
void Init_ossl_hmac(void)
VALUE rb_define_module(const char *name)
void rb_str_set_len(VALUE, long)
#define RSTRING_LEN(string)
#define EVP_MD_CTX_pkey_ctx(x)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
#define rb_str_new(str, len)
@ RUBY_TYPED_FREE_IMMEDIATELY
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_cObject
Object class.
#define GetHMAC(obj, ctx)
void ossl_raise(VALUE exc, const char *fmt,...)
void ossl_bin2hex(unsigned char *in, char *out, size_t inlen)
#define RTYPEDDATA_DATA(v)
unsigned char buf[MIME_BUF_SIZE]
#define RSTRING_PTR(string)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)