Ruby  1.9.3p547(2014-05-14revision45962)
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 WrapCipher(obj, klass, ctx)   (obj) = Data_Wrap_Struct((klass), 0, ossl_cipher_free, (ctx))
 
#define MakeCipher(obj, klass, ctx)   (obj) = Data_Make_Struct((klass), EVP_CIPHER_CTX, 0, ossl_cipher_free, (ctx))
 
#define AllocCipher(obj, ctx)   memset(DATA_PTR(obj) = (ctx) = ALLOC(EVP_CIPHER_CTX), 0, sizeof(EVP_CIPHER_CTX))
 
#define GetCipherInit(obj, ctx)
 
#define GetCipher(obj, ctx)
 
#define SafeGetCipher(obj, ctx)
 
#define ossl_s_ciphers   rb_f_notimplement
 
#define ossl_cipher_set_padding   rb_f_notimplement
 
#define CIPHER_0ARG_INT(func)
 

Functions

static VALUE ossl_cipher_alloc (VALUE klass)
 
const EVP_CIPHER * GetCipherPtr (VALUE obj)
 
VALUE ossl_cipher_new (const EVP_CIPHER *cipher)
 
static void ossl_cipher_free (EVP_CIPHER_CTX *ctx)
 
static VALUE ossl_cipher_initialize (VALUE self, VALUE str)
 
static VALUE ossl_cipher_copy (VALUE self, VALUE other)
 
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 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_set_key_length (VALUE self, VALUE key_length)
 
void Init_ossl_cipher (void)
 

Variables

VALUE cCipher
 
VALUE eCipherError
 

Macro Definition Documentation

#define AllocCipher (   obj,
  ctx 
)    memset(DATA_PTR(obj) = (ctx) = ALLOC(EVP_CIPHER_CTX), 0, sizeof(EVP_CIPHER_CTX))

Definition at line 17 of file ossl_cipher.c.

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

#define CIPHER_0ARG_INT (   func)
Value:
static VALUE \
ossl_cipher_##func(VALUE self) \
{ \
EVP_CIPHER_CTX *ctx; \
GetCipher(self, ctx); \
return INT2NUM(EVP_CIPHER_##func(EVP_CIPHER_CTX_cipher(ctx))); \
}
static VALUE INT2NUM(int v)
Definition: ruby.h:981
#define GetCipher(obj, ctx)
Definition: ossl_cipher.c:22
SSL_METHOD *(* func)(void)
Definition: ossl_ssl.c:104
unsigned long VALUE
Definition: ruby.h:88
return
Definition: name2ctype.h:23857

Definition at line 533 of file ossl_cipher.c.

#define GetCipher (   obj,
  ctx 
)
Value:
do { \
GetCipherInit((obj), (ctx)); \
if (!(ctx)) { \
ossl_raise(rb_eRuntimeError, "Cipher not inititalized!"); \
} \
} while (0)
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
Definition: name2ctype.h:23841
VALUE rb_eRuntimeError
Definition: error.c:466
#define GetCipherInit(obj, ctx)
Definition: ossl_cipher.c:19
void ossl_raise(VALUE exc, const char *fmt,...)
Definition: ossl.c:324

Definition at line 22 of file ossl_cipher.c.

Referenced by ossl_cipher_final(), ossl_cipher_init(), ossl_cipher_name(), ossl_cipher_pkcs5_keyivgen(), ossl_cipher_reset(), ossl_cipher_set_iv(), ossl_cipher_set_key(), ossl_cipher_set_key_length(), and ossl_cipher_update().

#define GetCipherInit (   obj,
  ctx 
)
Value:
do { \
Data_Get_Struct((obj), EVP_CIPHER_CTX, (ctx)); \
} while (0)
#define Data_Get_Struct(obj, type, sval)
Definition: ruby.h:835

Definition at line 19 of file ossl_cipher.c.

Referenced by ossl_cipher_copy(), and ossl_cipher_initialize().

#define MakeCipher (   obj,
  klass,
  ctx 
)    (obj) = Data_Make_Struct((klass), EVP_CIPHER_CTX, 0, ossl_cipher_free, (ctx))

Definition at line 15 of file ossl_cipher.c.

#define ossl_cipher_set_padding   rb_f_notimplement

Definition at line 530 of file ossl_cipher.c.

Referenced by Init_ossl_cipher().

#define ossl_s_ciphers   rb_f_notimplement

Definition at line 178 of file ossl_cipher.c.

Referenced by Init_ossl_cipher().

#define SafeGetCipher (   obj,
  ctx 
)
Value:
do { \
GetCipher((obj), (ctx)); \
} while (0)
#define GetCipher(obj, ctx)
Definition: ossl_cipher.c:22
#define OSSL_Check_Kind(obj, klass)
Definition: ossl.h:90
VALUE cCipher
Definition: ossl_cipher.c:36

Definition at line 28 of file ossl_cipher.c.

Referenced by GetCipherPtr(), and ossl_cipher_copy().

#define WrapCipher (   obj,
  klass,
  ctx 
)    (obj) = Data_Wrap_Struct((klass), 0, ossl_cipher_free, (ctx))

Definition at line 13 of file ossl_cipher.c.

Referenced by ossl_cipher_alloc().

Function Documentation

const EVP_CIPHER* GetCipherPtr ( VALUE  obj)
void Init_ossl_cipher ( void  )
static VALUE ossl_cipher_alloc ( VALUE  klass)
static

Definition at line 82 of file ossl_cipher.c.

References WrapCipher.

Referenced by Init_ossl_cipher(), and ossl_cipher_new().

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

Definition at line 277 of file ossl_cipher.c.

References ossl_cipher_init().

Referenced by Init_ossl_cipher().

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

Definition at line 259 of file ossl_cipher.c.

References ossl_cipher_init().

Referenced by Init_ossl_cipher().

static VALUE ossl_cipher_final ( VALUE  self)
static
static void ossl_cipher_free ( EVP_CIPHER_CTX *  ctx)
static

Definition at line 73 of file ossl_cipher.c.

References ruby_xfree().

static VALUE ossl_cipher_init ( int  argc,
VALUE argv,
VALUE  self,
int  mode 
)
static
static VALUE ossl_cipher_initialize ( VALUE  self,
VALUE  str 
)
static
static VALUE ossl_cipher_name ( VALUE  self)
static

Definition at line 412 of file ossl_cipher.c.

References EVP_CIPHER_name, GetCipher, and rb_str_new2().

Referenced by Init_ossl_cipher().

VALUE ossl_cipher_new ( const EVP_CIPHER *  cipher)
static VALUE ossl_cipher_pkcs5_keyivgen ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE ossl_cipher_reset ( VALUE  self)
static

Definition at line 191 of file ossl_cipher.c.

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

Referenced by Init_ossl_cipher().

static VALUE ossl_cipher_set_iv ( VALUE  self,
VALUE  iv 
)
static
static VALUE ossl_cipher_set_key ( VALUE  self,
VALUE  key 
)
static
static VALUE ossl_cipher_set_key_length ( VALUE  self,
VALUE  key_length 
)
static

Definition at line 495 of file ossl_cipher.c.

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

Referenced by Init_ossl_cipher().

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

Variable Documentation

VALUE cCipher

Definition at line 36 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), and ossl_cipher_new().

VALUE eCipherError