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

Go to the source code of this file.

Macros

#define NewCipher(klass)   TypedData_Wrap_Struct((klass), &ossl_cipher_type, 0)
 
#define AllocCipher(obj, ctx)
 
#define GetCipherInit(obj, ctx)
 
#define GetCipher(obj, ctx)
 
#define SafeGetCipher(obj, ctx)
 
#define ossl_cipher_set_auth_data   rb_f_notimplement
 
#define ossl_cipher_get_auth_tag   rb_f_notimplement
 
#define ossl_cipher_set_auth_tag   rb_f_notimplement
 
#define ossl_cipher_set_auth_tag_len   rb_f_notimplement
 
#define ossl_cipher_set_iv_length   rb_f_notimplement
 

Functions

static VALUE ossl_cipher_alloc (VALUE klass)
 
static void ossl_cipher_free (void *ptr)
 
const EVP_CIPHER * GetCipherPtr (VALUE obj)
 
VALUE ossl_cipher_new (const EVP_CIPHER *cipher)
 
static VALUE ossl_cipher_initialize (VALUE self, VALUE str)
 
static VALUE ossl_cipher_copy (VALUE self, VALUE other)
 
static void * add_cipher_name_to_ary (const OBJ_NAME *name, VALUE ary)
 
static VALUE ossl_s_ciphers (VALUE self)
 
static VALUE ossl_cipher_reset (VALUE self)
 
static VALUE ossl_cipher_init (int argc, VALUE *argv, VALUE self, int mode)
 
static VALUE ossl_cipher_encrypt (int argc, VALUE *argv, VALUE self)
 
static VALUE ossl_cipher_decrypt (int argc, VALUE *argv, VALUE self)
 
static VALUE ossl_cipher_pkcs5_keyivgen (int argc, VALUE *argv, VALUE self)
 
static int ossl_cipher_update_long (EVP_CIPHER_CTX *ctx, unsigned char *out, long *out_len_ptr, const unsigned char *in, long in_len)
 
static VALUE ossl_cipher_update (int argc, VALUE *argv, VALUE self)
 
static VALUE ossl_cipher_final (VALUE self)
 
static VALUE ossl_cipher_name (VALUE self)
 
static VALUE ossl_cipher_set_key (VALUE self, VALUE key)
 
static VALUE ossl_cipher_set_iv (VALUE self, VALUE iv)
 
static VALUE ossl_cipher_is_authenticated (VALUE self)
 
static VALUE ossl_cipher_set_key_length (VALUE self, VALUE key_length)
 
static VALUE ossl_cipher_set_padding (VALUE self, VALUE padding)
 
static VALUE ossl_cipher_key_length (VALUE self)
 
static VALUE ossl_cipher_iv_length (VALUE self)
 
static VALUE ossl_cipher_block_size (VALUE self)
 
void Init_ossl_cipher (void)
 

Variables

VALUE cCipher
 
VALUE eCipherError
 
static ID id_auth_tag_len
 
static ID id_key_set
 
static const rb_data_type_t ossl_cipher_type
 

Macro Definition Documentation

◆ AllocCipher

#define AllocCipher (   obj,
  ctx 
)
Value:
do { \
(ctx) = EVP_CIPHER_CTX_new(); \
if (!(ctx)) \
ossl_raise(rb_eRuntimeError, NULL); \
RTYPEDDATA_DATA(obj) = (ctx); \
} while (0)
VALUE rb_eRuntimeError
Definition: error.c:761
#define EVP_CIPHER_CTX_new
#define NULL
Definition: _sdbm.c:102

Definition at line 14 of file ossl_cipher.c.

Referenced by ossl_cipher_copy(), ossl_cipher_initialize(), and ossl_cipher_new().

◆ GetCipher

#define GetCipher (   obj,
  ctx 
)

◆ GetCipherInit

#define GetCipherInit (   obj,
  ctx 
)
Value:
do { \
TypedData_Get_Struct((obj), EVP_CIPHER_CTX, &ossl_cipher_type, (ctx)); \
} while (0)
static const rb_data_type_t ossl_cipher_type
Definition: ossl_cipher.c:44

Definition at line 20 of file ossl_cipher.c.

Referenced by ossl_cipher_copy(), and ossl_cipher_initialize().

◆ NewCipher

#define NewCipher (   klass)    TypedData_Wrap_Struct((klass), &ossl_cipher_type, 0)

Definition at line 12 of file ossl_cipher.c.

Referenced by ossl_cipher_alloc().

◆ ossl_cipher_get_auth_tag

#define ossl_cipher_get_auth_tag   rb_f_notimplement

Definition at line 727 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), and ossl_cipher_is_authenticated().

◆ ossl_cipher_set_auth_data

#define ossl_cipher_set_auth_data   rb_f_notimplement

Definition at line 726 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), and ossl_cipher_is_authenticated().

◆ ossl_cipher_set_auth_tag

#define ossl_cipher_set_auth_tag   rb_f_notimplement

Definition at line 728 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), and ossl_cipher_is_authenticated().

◆ ossl_cipher_set_auth_tag_len

#define ossl_cipher_set_auth_tag_len   rb_f_notimplement

Definition at line 729 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), and ossl_cipher_is_authenticated().

◆ ossl_cipher_set_iv_length

#define ossl_cipher_set_iv_length   rb_f_notimplement

Definition at line 730 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), and ossl_cipher_is_authenticated().

◆ SafeGetCipher

#define SafeGetCipher (   obj,
  ctx 
)
Value:
do { \
OSSL_Check_Kind((obj), cCipher); \
GetCipher((obj), (ctx)); \
} while (0)
VALUE cCipher
Definition: ossl_cipher.c:37

Definition at line 29 of file ossl_cipher.c.

Referenced by ossl_cipher_copy().

Function Documentation

◆ add_cipher_name_to_ary()

static void* add_cipher_name_to_ary ( const OBJ_NAME *  name,
VALUE  ary 
)
static

Definition at line 157 of file ossl_cipher.c.

References NULL, rb_ary_push(), and rb_str_new2.

Referenced by ossl_s_ciphers().

◆ GetCipherPtr()

const EVP_CIPHER* GetCipherPtr ( VALUE  obj)

◆ Init_ossl_cipher()

void Init_ossl_cipher ( void  )

◆ ossl_cipher_alloc()

static VALUE ossl_cipher_alloc ( VALUE  klass)
static

Definition at line 102 of file ossl_cipher.c.

References NewCipher.

Referenced by Init_ossl_cipher(), and ossl_cipher_new().

◆ ossl_cipher_block_size()

static VALUE ossl_cipher_block_size ( VALUE  self)
static

Definition at line 826 of file ossl_cipher.c.

References GetCipher, and INT2NUM.

Referenced by Init_ossl_cipher().

◆ ossl_cipher_copy()

static VALUE ossl_cipher_copy ( VALUE  self,
VALUE  other 
)
static

◆ ossl_cipher_decrypt()

static VALUE ossl_cipher_decrypt ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 281 of file ossl_cipher.c.

References ossl_cipher_init().

Referenced by Init_ossl_cipher().

◆ ossl_cipher_encrypt()

static VALUE ossl_cipher_encrypt ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 263 of file ossl_cipher.c.

References ossl_cipher_init().

Referenced by Init_ossl_cipher().

◆ ossl_cipher_final()

static VALUE ossl_cipher_final ( VALUE  self)
static

◆ ossl_cipher_free()

static void ossl_cipher_free ( void *  ptr)
static

Definition at line 96 of file ossl_cipher.c.

References EVP_CIPHER_CTX_free.

◆ ossl_cipher_init()

static VALUE ossl_cipher_init ( int  argc,
VALUE argv,
VALUE  self,
int  mode 
)
static

◆ ossl_cipher_initialize()

static VALUE ossl_cipher_initialize ( VALUE  self,
VALUE  str 
)
static

◆ ossl_cipher_is_authenticated()

static VALUE ossl_cipher_is_authenticated ( VALUE  self)
static

◆ ossl_cipher_iv_length()

static VALUE ossl_cipher_iv_length ( VALUE  self)
static

Definition at line 803 of file ossl_cipher.c.

References GetCipher, INT2NUM, and len.

Referenced by Init_ossl_cipher().

◆ ossl_cipher_key_length()

static VALUE ossl_cipher_key_length ( VALUE  self)
static

Definition at line 787 of file ossl_cipher.c.

References GetCipher, and INT2NUM.

Referenced by Init_ossl_cipher().

◆ ossl_cipher_name()

static VALUE ossl_cipher_name ( VALUE  self)
static

Definition at line 453 of file ossl_cipher.c.

References GetCipher, and rb_str_new2.

Referenced by Init_ossl_cipher().

◆ ossl_cipher_new()

VALUE ossl_cipher_new ( const EVP_CIPHER *  cipher)

Definition at line 79 of file ossl_cipher.c.

References AllocCipher, cCipher, eCipherError, NULL, ossl_cipher_alloc(), and ossl_raise().

Referenced by ossl_engine_get_cipher().

◆ ossl_cipher_pkcs5_keyivgen()

static VALUE ossl_cipher_pkcs5_keyivgen ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ ossl_cipher_reset()

static VALUE ossl_cipher_reset ( VALUE  self)
static

Definition at line 192 of file ossl_cipher.c.

References eCipherError, GetCipher, NULL, and ossl_raise().

Referenced by Init_ossl_cipher().

◆ ossl_cipher_set_iv()

static VALUE ossl_cipher_set_iv ( VALUE  self,
VALUE  iv 
)
static

Definition at line 507 of file ossl_cipher.c.

References eCipherError, GetCipher, NULL, ossl_raise(), rb_eArgError, RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_cipher().

◆ ossl_cipher_set_key()

static VALUE ossl_cipher_set_key ( VALUE  self,
VALUE  key 
)
static

◆ ossl_cipher_set_key_length()

static VALUE ossl_cipher_set_key_length ( VALUE  self,
VALUE  key_length 
)
static

Definition at line 746 of file ossl_cipher.c.

References eCipherError, GetCipher, len, NULL, NUM2INT, and ossl_raise().

Referenced by Init_ossl_cipher().

◆ ossl_cipher_set_padding()

static VALUE ossl_cipher_set_padding ( VALUE  self,
VALUE  padding 
)
static

Definition at line 769 of file ossl_cipher.c.

References eCipherError, GetCipher, NULL, NUM2INT, and ossl_raise().

Referenced by Init_ossl_cipher().

◆ ossl_cipher_update()

static VALUE ossl_cipher_update ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ ossl_cipher_update_long()

static int ossl_cipher_update_long ( EVP_CIPHER_CTX *  ctx,
unsigned char *  out,
long *  out_len_ptr,
const unsigned char *  in,
long  in_len 
)
static

Definition at line 339 of file ossl_cipher.c.

Referenced by ossl_cipher_is_authenticated(), and ossl_cipher_update().

◆ ossl_s_ciphers()

static VALUE ossl_s_ciphers ( VALUE  self)
static

Definition at line 170 of file ossl_cipher.c.

References add_cipher_name_to_ary(), and rb_ary_new().

Referenced by Init_ossl_cipher().

Variable Documentation

◆ cCipher

VALUE cCipher

Definition at line 37 of file ossl_cipher.c.

Referenced by GetCipherPtr(), Init_ossl_cipher(), and ossl_cipher_new().

◆ eCipherError

VALUE eCipherError

◆ id_auth_tag_len

ID id_auth_tag_len
static

Definition at line 39 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), and ossl_cipher_is_authenticated().

◆ id_key_set

ID id_key_set
static

◆ ossl_cipher_type

const rb_data_type_t ossl_cipher_type
static
Initial value:
= {
"OpenSSL/Cipher",
{
},
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static void ossl_cipher_free(void *ptr)
Definition: ossl_cipher.c:96

Definition at line 44 of file ossl_cipher.c.