10 #if !defined(OPENSSL_NO_HMAC) 14 #define NewHMAC(klass) \ 15 TypedData_Wrap_Struct((klass), &ossl_hmac_type, 0) 16 #define GetHMAC(obj, ctx) do { \ 17 TypedData_Get_Struct((obj), HMAC_CTX, &ossl_hmac_type, (ctx)); \ 19 ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \ 22 #define SafeGetHMAC(obj, ctx) do { \ 23 OSSL_Check_Kind((obj), cHMAC); \ 24 GetHMAC((obj), (ctx)); \ 121 HMAC_CTX *ctx1, *ctx2;
124 if (
self == other)
return self;
178 HMAC_Final(
final, buf, buf_len);
198 unsigned int buf_len;
204 assert(buf_len <= EVP_MAX_MD_SIZE);
221 unsigned char buf[EVP_MAX_MD_SIZE];
222 unsigned int buf_len;
284 unsigned int buf_len;
291 return rb_str_new((
const char *)buf, buf_len);
314 unsigned char buf[EVP_MAX_MD_SIZE];
315 unsigned int buf_len;
392 # warning >>> OpenSSL is compiled without HMAC support <<< 396 rb_warning(
"HMAC is not available: OpenSSL is compiled without HMAC.");
#define GetHMAC(obj, ctx)
#define RUBY_TYPED_FREE_IMMEDIATELY
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static VALUE ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
void rb_str_set_len(VALUE, long)
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)
static void ossl_hmac_free(void *ctx)
#define rb_define_copy_func(klass, func)
static VALUE ossl_hmac_digest(VALUE self)
RUBY_EXTERN VALUE rb_cObject
const EVP_MD * GetDigestPtr(VALUE obj)
void Init_ossl_hmac(void)
static VALUE ossl_hmac_alloc(VALUE klass)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
#define SafeGetHMAC(obj, ctx)
unsigned char buf[MIME_BUF_SIZE]
static VALUE ossl_hmac_hexdigest(VALUE self)
void ossl_bin2hex(unsigned char *in, char *out, size_t inlen)
static VALUE ossl_hmac_update(VALUE self, VALUE data)
static VALUE ossl_hmac_copy(VALUE self, VALUE other)
static VALUE ossl_hmac_reset(VALUE self)
static void hmac_final(HMAC_CTX *ctx, unsigned char *buf, unsigned int *buf_len)
void ossl_raise(VALUE exc, const char *fmt,...)
static VALUE ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
#define RTYPEDDATA_DATA(v)
void rb_warning(const char *fmt,...)
#define RSTRING_LENINT(str)
#define rb_check_frozen(obj)
VALUE rb_define_module(const char *name)
static VALUE ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
static const rb_data_type_t ossl_hmac_type
VALUE rb_str_new(const char *, long)