11 #if !defined(OPENSSL_NO_HMAC) 15 #define MakeHMAC(obj, klass, ctx) \ 16 (obj) = Data_Make_Struct((klass), HMAC_CTX, 0, ossl_hmac_free, (ctx)) 17 #define GetHMAC(obj, ctx) do { \ 18 Data_Get_Struct((obj), HMAC_CTX, (ctx)); \ 20 ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \ 23 #define SafeGetHMAC(obj, ctx) do { \ 24 OSSL_Check_Kind((obj), cHMAC); \ 25 GetHMAC((obj), (ctx)); \ 82 HMAC_CTX *ctx1, *ctx2;
85 if (
self == other)
return self;
117 if (!(*
buf = OPENSSL_malloc(HMAC_size(&
final)))) {
119 OSSL_Debug(
"Allocating %d mem", HMAC_size(&
final));
122 HMAC_Final(&
final, *
buf, buf_len);
136 unsigned int buf_len;
157 unsigned int buf_len;
197 unsigned int buf_len;
217 unsigned int buf_len;
264 # warning >>> OpenSSL is compiled without HMAC support <<< 268 rb_warning(
"HMAC will NOT be avaible: OpenSSL is compiled without HMAC.");
#define GetHMAC(obj, ctx)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static void ossl_hmac_free(HMAC_CTX *ctx)
static VALUE ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
#define MakeHMAC(obj, klass, ctx)
void HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
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)
#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)
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 HMAC_CTX_init(HMAC_CTX *ctx)
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)
VALUE ossl_buf2str(char *buf, int len)
void ossl_raise(VALUE exc, const char *fmt,...)
static VALUE ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
static void hmac_final(HMAC_CTX *ctx, unsigned char **buf, unsigned int *buf_len)
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)
void HMAC_CTX_cleanup(HMAC_CTX *ctx)
int string2hex(const unsigned char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
VALUE rb_str_new(const char *, long)