ossl_hmac.c File Reference
`#include "ossl.h"`

Go to the source code of this file.

## Macros

#define | MakeHMAC(obj, klass, ctx) (obj) = Data_Make_Struct((klass), HMAC_CTX, 0, ossl_hmac_free, (ctx))
#define | GetHMAC(obj, ctx)
#define | SafeGetHMAC(obj, ctx)

## Functions

static void | ossl_hmac_free (HMAC_CTX *ctx)
static VALUE | ossl_hmac_alloc (VALUE klass)
static VALUE | ossl_hmac_initialize (VALUE self, VALUE key, VALUE digest)
static VALUE | ossl_hmac_copy (VALUE self, VALUE other)
static VALUE | ossl_hmac_update (VALUE self, VALUE data)
static void | hmac_final (HMAC_CTX *ctx, unsigned char **buf, unsigned int *buf_len)
static VALUE | ossl_hmac_digest (VALUE self)
static VALUE | ossl_hmac_hexdigest (VALUE self)
static VALUE | ossl_hmac_reset (VALUE self)
static VALUE | ossl_hmac_s_digest (VALUE klass, VALUE digest, VALUE key, VALUE data)
static VALUE | ossl_hmac_s_hexdigest (VALUE klass, VALUE digest, VALUE key, VALUE data)
void | Init_ossl_hmac ()

## Variables

VALUE | cHMAC
VALUE | eHMACError

## Macro Definition Documentation

#define GetHMAC | ( |  | obj,
|  |  | ctx
| ) |  |

Value:
do { \
Data_Get_Struct((obj), HMAC_CTX, (ctx)); \
if (!(ctx)) { \
ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \
} \
} while (0)

Definition at line 17 of file ossl_hmac.c.

Referenced by ossl_hmac_copy(), ossl_hmac_digest(), ossl_hmac_hexdigest(), ossl_hmac_initialize(), ossl_hmac_reset(), and ossl_hmac_update().

#define MakeHMAC | ( |  | obj,
|  |  | klass,
|  |  | ctx
| ) |  | (obj) = Data_Make_Struct((klass), HMAC_CTX, 0, ossl_hmac_free, (ctx))

Definition at line 15 of file ossl_hmac.c.

Referenced by ossl_hmac_alloc().

#define SafeGetHMAC | ( |  | obj,
|  |  | ctx
| ) |  |

Value:
do { \
OSSL_Check_Kind((obj), cHMAC); \
GetHMAC((obj), (ctx)); \
} while (0)

Definition at line 23 of file ossl_hmac.c.

Referenced by ossl_hmac_copy().

## Function Documentation

static void hmac_final | ( | HMAC_CTX * | ctx,
|  | unsigned char ** | buf,
|  | unsigned int * | buf_len
| ) |  |

static

Definition at line 112 of file ossl_hmac.c.

References eHMACError, HMAC_CTX_cleanup(), HMAC_CTX_copy(), OSSL_Debug, and ossl_raise().

Referenced by ossl_hmac_digest(), and ossl_hmac_hexdigest().

void Init_ossl_hmac | ( | void |  | ) |

Definition at line 237 of file ossl_hmac.c.

References cHMAC, eHMACError, eOSSLError, mOSSL, ossl_hmac_alloc(), ossl_hmac_copy(), ossl_hmac_digest(), ossl_hmac_hexdigest(), ossl_hmac_initialize(), ossl_hmac_reset(), ossl_hmac_s_digest(), ossl_hmac_s_hexdigest(), ossl_hmac_update(), rb_cObject, rb_define_alias(), rb_define_alloc_func(), rb_define_class_under(), rb_define_copy_func, rb_define_method(), rb_define_module(), and rb_define_singleton_method().

Referenced by Init_openssl().

static VALUE ossl_hmac_alloc | ( | VALUE | klass | ) |

static

Definition at line 49 of file ossl_hmac.c.

References HMAC_CTX_init(), and MakeHMAC.

Referenced by Init_ossl_hmac().

static VALUE ossl_hmac_copy | ( | VALUE | self,
|  | VALUE | other
| ) |  |

static

Definition at line 80 of file ossl_hmac.c.

References GetHMAC, HMAC_CTX_copy(), rb_check_frozen, and SafeGetHMAC.

Referenced by Init_ossl_hmac().

static VALUE ossl_hmac_digest | ( | VALUE | self | ) |

static

Definition at line 132 of file ossl_hmac.c.

References buf, GetHMAC, hmac_final(), and ossl_buf2str().

Referenced by Init_ossl_hmac().

static void ossl_hmac_free | ( | HMAC_CTX * | ctx | ) |

static

Definition at line 42 of file ossl_hmac.c.

References HMAC_CTX_cleanup(), and ruby_xfree().

static VALUE ossl_hmac_hexdigest | ( | VALUE | self | ) |

static

Definition at line 152 of file ossl_hmac.c.

References buf, eHMACError, GetHMAC, hmac_final(), NULL, ossl_buf2str(), ossl_raise(), and string2hex().

Referenced by Init_ossl_hmac().

static VALUE ossl_hmac_initialize | ( | VALUE | self,
|  | VALUE | key,
|  | VALUE | digest
| ) |  |

static

Definition at line 67 of file ossl_hmac.c.

References GetDigestPtr(), GetHMAC, RSTRING_LENINT, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_hmac().

static VALUE ossl_hmac_reset | ( | VALUE | self | ) |

static

Definition at line 178 of file ossl_hmac.c.

References GetHMAC, and NULL.

Referenced by Init_ossl_hmac().

static VALUE ossl_hmac_s_digest | ( | VALUE | klass,
|  | VALUE | digest,
|  | VALUE | key,
|  | VALUE | data
| ) |  |

static

Definition at line 194 of file ossl_hmac.c.

References buf, GetDigestPtr(), NULL, rb_str_new(), RSTRING_LEN, RSTRING_LENINT, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_hmac().

static VALUE ossl_hmac_s_hexdigest | ( | VALUE | klass,
|  | VALUE | digest,
|  | VALUE | key,
|  | VALUE | data
| ) |  |

static

Definition at line 213 of file ossl_hmac.c.

References buf, eHMACError, GetDigestPtr(), NULL, ossl_buf2str(), ossl_raise(), RSTRING_LEN, RSTRING_LENINT, RSTRING_PTR, string2hex(), and StringValue.

Referenced by Init_ossl_hmac().

static VALUE ossl_hmac_update | ( | VALUE | self,
|  | VALUE | data
| ) |  |

static

Definition at line 100 of file ossl_hmac.c.

References GetHMAC, RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_hmac().

## Variable Documentation

VALUE cHMAC

Definition at line 31 of file ossl_hmac.c.

Referenced by Init_ossl_hmac().

VALUE eHMACError

Definition at line 32 of file ossl_hmac.c.

Referenced by hmac_final(), Init_ossl_hmac(), ossl_hmac_hexdigest(), and ossl_hmac_s_hexdigest().