Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Defines | Functions | Variables

# ext/openssl/ossl_cipher.c File Reference

`#include "ossl.h"`
Include dependency graph for ossl_cipher.c:

Go to the source code of this file.

## Defines
#define | MakeCipher(obj, klass, ctx) obj = Data_Make_Struct(klass, EVP_CIPHER_CTX, 0, ossl_cipher_free, 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

## Define Documentation

#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)));  \
        }

Definition at line 482 of file ossl_cipher.c.

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

Value:

    do { \
        Data_Get_Struct(obj, EVP_CIPHER_CTX, ctx); \
        if (!ctx) { \
            ossl_raise(rb_eRuntimeError, "Cipher not inititalized!"); \
        } \
    } while (0)

Definition at line 15 of file ossl_cipher.c.

Referenced by ossl_cipher_copy(), ossl_cipher_final(), ossl_cipher_init(), ossl_cipher_initialize(), ossl_cipher_name(), ossl_cipher_new(), 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 MakeCipher | ( |  | obj,
|  |  | klass,
|  |  | ctx
| ) |  | obj = Data_Make_Struct(klass, EVP_CIPHER_CTX, 0, ossl_cipher_free, ctx)

Definition at line 13 of file ossl_cipher.c.

Referenced by ossl_cipher_alloc().

#define ossl_cipher_set_padding rb_f_notimplement

Definition at line 479 of file ossl_cipher.c.

Referenced by Init_ossl_cipher().

#define ossl_s_ciphers rb_f_notimplement

Definition at line 156 of file ossl_cipher.c.

Referenced by Init_ossl_cipher().

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

Value:

    do { \
        OSSL_Check_Kind(obj, cCipher); \
        GetCipher(obj, ctx); \
    } while (0)

Definition at line 21 of file ossl_cipher.c.

Referenced by GetCipherPtr(), and ossl_cipher_copy().

## Function Documentation

const EVP_CIPHER* GetCipherPtr | ( | VALUE | obj | ) |

Definition at line 38 of file ossl_cipher.c.

References SafeGetCipher.

Referenced by ossl_dsa_export(), ossl_pkcs7_s_encrypt(), ossl_pkcs7_set_cipher(), and ossl_rsa_export().

void Init_ossl_cipher | ( | void |  | ) |

Definition at line 519 of file ossl_cipher.c.

References cCipher, eCipherError, eOSSLError, mOSSL, ossl_cipher_alloc(), ossl_cipher_copy(), ossl_cipher_decrypt(), ossl_cipher_encrypt(), ossl_cipher_final(), ossl_cipher_initialize(), ossl_cipher_name(), ossl_cipher_pkcs5_keyivgen(), ossl_cipher_reset(), ossl_cipher_set_iv(), ossl_cipher_set_key(), ossl_cipher_set_key_length(), ossl_cipher_set_padding, ossl_cipher_update(), ossl_s_ciphers, rb_cObject, rb_define_alloc_func(), rb_define_class_under(), rb_define_copy_func, rb_define_method(), rb_define_module(), and rb_define_module_function().

Referenced by Init_openssl().

static VALUE ossl_cipher_alloc | ( | VALUE | klass | ) | `[static]`

Definition at line 75 of file ossl_cipher.c.

References MakeCipher.

Referenced by Init_ossl_cipher(), and ossl_cipher_new().

static VALUE ossl_cipher_copy | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 112 of file ossl_cipher.c.

References eCipherError, EVP_CIPHER_CTX_copy(), GetCipher, NULL, ossl_raise(), rb_check_frozen(), and SafeGetCipher.

Referenced by Init_ossl_cipher().

static VALUE ossl_cipher_decrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  | `[static]`

Definition at line 246 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 231 of file ossl_cipher.c.

References ossl_cipher_init().

Referenced by Init_ossl_cipher().

static VALUE ossl_cipher_final | ( | VALUE | self | ) | `[static]`

Definition at line 349 of file ossl_cipher.c.

References assert, eCipherError, EVP_CipherFinal_ex, GetCipher, NULL, ossl_raise(), rb_str_new(), rb_str_set_len, RSTRING_LEN, and RSTRING_PTR.

Referenced by Init_ossl_cipher().

static void ossl_cipher_free | ( | EVP_CIPHER_CTX * | ctx | ) | `[static]`

Definition at line 66 of file ossl_cipher.c.

References ruby_xfree().

static VALUE ossl_cipher_init | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self,
|  | int | mode
| ) |  | `[static]`

Definition at line 178 of file ossl_cipher.c.

References eCipherError, EVP_CipherInit_ex, GetCipher, NIL_P, NULL, ossl_raise(), rb_class2name(), rb_obj_class(), rb_scan_args(), rb_warn(), RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by ossl_cipher_decrypt(), and ossl_cipher_encrypt().

static VALUE ossl_cipher_initialize | ( | VALUE | self,
|  | VALUE | str
| ) |  | `[static]`

Definition at line 95 of file ossl_cipher.c.

References eCipherError, EVP_CipherInit_ex, GetCipher, name, NULL, ossl_raise(), rb_eRuntimeError, and StringValuePtr.

Referenced by Init_ossl_cipher().

static VALUE ossl_cipher_name | ( | VALUE | self | ) | `[static]`

Definition at line 372 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 | ) |

Definition at line 48 of file ossl_cipher.c.

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

static VALUE ossl_cipher_pkcs5_keyivgen | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  | `[static]`

Definition at line 270 of file ossl_cipher.c.

References eCipherError, EVP_CipherInit_ex, GetCipher, GetDigestPtr(), NIL_P, NULL, NUM2INT, OPENSSL_cleanse, ossl_raise(), Qnil, rb_raise(), rb_scan_args(), RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_cipher().

static VALUE ossl_cipher_reset | ( | VALUE | self | ) | `[static]`

Definition at line 166 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]`

Definition at line 415 of file ossl_cipher.c.

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

Referenced by Init_ossl_cipher().

static VALUE ossl_cipher_set_key | ( | VALUE | self,
|  | VALUE | key
| ) |  | `[static]`

Definition at line 390 of file ossl_cipher.c.

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

Referenced by Init_ossl_cipher().

static VALUE ossl_cipher_set_key_length | ( | VALUE | self,
|  | VALUE | key_length
| ) |  | `[static]`

Definition at line 444 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]`

Definition at line 309 of file ossl_cipher.c.

References assert, eCipherError, GetCipher, NIL_P, NULL, ossl_raise(), rb_eArgError, rb_raise(), rb_scan_args(), rb_str_new(), rb_str_resize(), rb_str_set_len, RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_cipher().

## Variable Documentation

VALUE cCipher

Definition at line 29 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), and ossl_cipher_new().

VALUE eCipherError

Definition at line 30 of file ossl_cipher.c.

Referenced by Init_ossl_cipher(), ossl_cipher_copy(), ossl_cipher_final(), ossl_cipher_init(), ossl_cipher_initialize(), ossl_cipher_new(), ossl_cipher_pkcs5_keyivgen(), ossl_cipher_reset(), ossl_cipher_set_iv(), ossl_cipher_set_key(), ossl_cipher_set_key_length(), and ossl_cipher_update().