Ruby  2.4.2p198(2017-09-14revision59899)
Macros | Functions | Variables
ossl_hmac.c File Reference
#include "ossl.h"
Include dependency graph for ossl_hmac.c:

Go to the source code of this file.

Macros

#define NewHMAC(klass)   TypedData_Wrap_Struct((klass), &ossl_hmac_type, 0)
 
#define GetHMAC(obj, ctx)
 
#define SafeGetHMAC(obj, ctx)
 

Functions

static void ossl_hmac_free (void *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 (void)
 

Variables

VALUE cHMAC
 
VALUE eHMACError
 
static const rb_data_type_t ossl_hmac_type
 

Macro Definition Documentation

◆ GetHMAC

#define GetHMAC (   obj,
  ctx 
)
Value:
do { \
TypedData_Get_Struct((obj), HMAC_CTX, &ossl_hmac_type, (ctx)); \
if (!(ctx)) { \
ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \
} \
} while (0)
VALUE rb_eRuntimeError
Definition: error.c:761
static const rb_data_type_t ossl_hmac_type
Definition: ossl_hmac.c:46

Definition at line 16 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().

◆ NewHMAC

#define NewHMAC (   klass)    TypedData_Wrap_Struct((klass), &ossl_hmac_type, 0)

Definition at line 14 of file ossl_hmac.c.

Referenced by ossl_hmac_alloc().

◆ SafeGetHMAC

#define SafeGetHMAC (   obj,
  ctx 
)
Value:
do { \
OSSL_Check_Kind((obj), cHMAC); \
GetHMAC((obj), (ctx)); \
} while (0)
VALUE cHMAC
Definition: ossl_hmac.c:30

Definition at line 22 of file ossl_hmac.c.

Referenced by ossl_hmac_copy().

Function Documentation

◆ hmac_final()

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

Definition at line 165 of file ossl_hmac.c.

References eHMACError, HMAC_CTX_copy, HMAC_CTX_free, HMAC_CTX_new, and ossl_raise().

Referenced by ossl_hmac_digest(), and ossl_hmac_hexdigest().

◆ Init_ossl_hmac()

void Init_ossl_hmac ( void  )

◆ ossl_hmac_alloc()

static VALUE ossl_hmac_alloc ( VALUE  klass)
static

Definition at line 55 of file ossl_hmac.c.

References eHMACError, HMAC_CTX_new, NewHMAC, NULL, ossl_raise(), and RTYPEDDATA_DATA.

Referenced by Init_ossl_hmac().

◆ ossl_hmac_copy()

static VALUE ossl_hmac_copy ( VALUE  self,
VALUE  other 
)
static

Definition at line 119 of file ossl_hmac.c.

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

Referenced by Init_ossl_hmac().

◆ ossl_hmac_digest()

static VALUE ossl_hmac_digest ( VALUE  self)
static

Definition at line 195 of file ossl_hmac.c.

References assert, GetHMAC, hmac_final(), NULL, rb_str_new(), rb_str_set_len(), and RSTRING_PTR.

Referenced by Init_ossl_hmac().

◆ ossl_hmac_free()

static void ossl_hmac_free ( void *  ctx)
static

Definition at line 41 of file ossl_hmac.c.

References HMAC_CTX_free.

◆ ossl_hmac_hexdigest()

static VALUE ossl_hmac_hexdigest ( VALUE  self)
static

Definition at line 218 of file ossl_hmac.c.

References buf, GetHMAC, hmac_final(), NULL, ossl_bin2hex(), rb_str_new(), and RSTRING_PTR.

Referenced by Init_ossl_hmac().

◆ ossl_hmac_initialize()

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

Definition at line 106 of file ossl_hmac.c.

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

Referenced by Init_ossl_hmac().

◆ ossl_hmac_reset()

static VALUE ossl_hmac_reset ( VALUE  self)
static

Definition at line 253 of file ossl_hmac.c.

References GetHMAC, and NULL.

Referenced by Init_ossl_hmac().

◆ ossl_hmac_s_digest()

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

Definition at line 281 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().

◆ ossl_hmac_s_hexdigest()

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

◆ ossl_hmac_update()

static VALUE ossl_hmac_update ( VALUE  self,
VALUE  data 
)
static

Definition at line 153 of file ossl_hmac.c.

References GetHMAC, RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_hmac().

Variable Documentation

◆ cHMAC

VALUE cHMAC

Definition at line 30 of file ossl_hmac.c.

Referenced by Init_ossl_hmac().

◆ eHMACError

VALUE eHMACError

◆ ossl_hmac_type

const rb_data_type_t ossl_hmac_type
static
Initial value:
= {
"OpenSSL/HMAC",
{
},
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static void ossl_hmac_free(void *ctx)
Definition: ossl_hmac.c:41

Definition at line 46 of file ossl_hmac.c.