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"); \
37ossl_hmac_free(
void *ctx)
117 HMAC_CTX *ctx1, *ctx2;
120 if (
self == other)
return self;
125 if (!HMAC_CTX_copy(ctx1, ctx2))
161hmac_final(HMAC_CTX *ctx,
unsigned char *
buf,
unsigned int *buf_len)
169 if (!HMAC_CTX_copy(
final, ctx)) {
174 HMAC_Final(
final,
buf, buf_len);
191ossl_hmac_digest(
VALUE self)
194 unsigned int buf_len;
199 hmac_final(ctx, (
unsigned char *)
RSTRING_PTR(ret), &buf_len);
200 assert(buf_len <= EVP_MAX_MD_SIZE);
214ossl_hmac_hexdigest(
VALUE self)
217 unsigned char buf[EVP_MAX_MD_SIZE];
218 unsigned int buf_len;
222 hmac_final(ctx,
buf, &buf_len);
249ossl_hmac_reset(
VALUE self)
280 unsigned int buf_len;
311 unsigned char buf[EVP_MAX_MD_SIZE];
312 unsigned int buf_len;
389# warning >>> OpenSSL is compiled without HMAC support <<<
393 rb_warning(
"HMAC is not available: OpenSSL is compiled without HMAC.");
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
VALUE rb_define_module(const char *)
void rb_define_alias(VALUE, const char *, const char *)
Defines an alias of a method.
VALUE rb_cObject
Object class.
unsigned char buf[MIME_BUF_SIZE]
void ossl_bin2hex(unsigned char *in, char *out, size_t inlen)
void ossl_raise(VALUE exc, const char *fmt,...)
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)
void Init_ossl_hmac(void)
#define GetHMAC(obj, ctx)