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

Go to the source code of this file.

## Macros

#define | GetPKeyRSA(obj, pkey)
#define | RSA_HAS_PRIVATE(rsa) ((rsa)->p && (rsa)->q)
#define | RSA_PRIVATE(obj, rsa) (RSA_HAS_PRIVATE(rsa)||OSSL_PKEY_IS_PRIVATE(obj))
#define | ossl_rsa_buf_size(pkey) (RSA_size((pkey)->pkey.rsa)+16)
#define | DefRSAConst(x) rb_define_const(cRSA, #x,INT2FIX(RSA_##x))

## Functions

static VALUE | rsa_instance (VALUE klass, RSA *rsa)
VALUE | ossl_rsa_new (EVP_PKEY *pkey)
static RSA * | rsa_generate (int size, int exp)
static VALUE | ossl_rsa_s_generate (int argc, VALUE *argv, VALUE klass)
static VALUE | ossl_rsa_initialize (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_is_public (VALUE self)
static VALUE | ossl_rsa_is_private (VALUE self)
static VALUE | ossl_rsa_export (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_to_der (VALUE self)
static VALUE | ossl_rsa_public_encrypt (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_public_decrypt (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_private_encrypt (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_private_decrypt (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_get_params (VALUE self)
static VALUE | ossl_rsa_to_text (VALUE self)
static VALUE | ossl_rsa_to_public_key (VALUE self)
void | Init_ossl_rsa ()

## Variables

VALUE | cRSA
VALUE | eRSAError

## Macro Definition Documentation

#define DefRSAConst | ( |  | x | ) | rb_define_const(cRSA, #x,INT2FIX(RSA_##x))

Definition at line 557 of file ossl_pkey_rsa.c.

Referenced by Init_ossl_rsa().

#define GetPKeyRSA | ( |  | obj,
|  |  | pkey
| ) |  |

Value:
do { \
GetPKey((obj), (pkey)); \
if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_RSA) { /* PARANOIA? */ \
ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
} \
} while (0)

Definition at line 15 of file ossl_pkey_rsa.c.

Referenced by ossl_rsa_export(), ossl_rsa_get_params(), ossl_rsa_is_private(), ossl_rsa_is_public(), ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), ossl_rsa_public_encrypt(), ossl_rsa_to_der(), ossl_rsa_to_public_key(), and ossl_rsa_to_text().

#define ossl_rsa_buf_size | ( |  | pkey | ) | (RSA_size((pkey)->pkey.rsa)+16)

Definition at line 306 of file ossl_pkey_rsa.c.

Referenced by ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), and ossl_rsa_public_encrypt().

#define RSA_HAS_PRIVATE | ( |  | rsa | ) | ((rsa)->p && (rsa)->q)

Definition at line 22 of file ossl_pkey_rsa.c.

Referenced by ossl_rsa_export(), and ossl_rsa_to_der().

#define RSA_PRIVATE | ( |  | obj,
|  |  | rsa
| ) |  | (RSA_HAS_PRIVATE(rsa)||OSSL_PKEY_IS_PRIVATE(obj))

Definition at line 23 of file ossl_pkey_rsa.c.

Referenced by ossl_rsa_is_private(), ossl_rsa_private_decrypt(), and ossl_rsa_private_encrypt().

## Function Documentation

void Init_ossl_rsa | ( | void |  | ) |

Definition at line 560 of file ossl_pkey_rsa.c.

References cPKey, cRSA, DEF_OSSL_PKEY_BN, DefRSAConst, ePKeyError, eRSAError, mOSSL, mPKey, ossl_rsa_export(), ossl_rsa_get_params(), ossl_rsa_initialize(), ossl_rsa_is_private(), ossl_rsa_is_public(), ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), ossl_rsa_public_encrypt(), ossl_rsa_s_generate(), ossl_rsa_to_der(), ossl_rsa_to_public_key(), ossl_rsa_to_text(), p, rb_define_alias(), rb_define_class_under(), rb_define_method(), rb_define_module(), rb_define_module_under(), and rb_define_singleton_method().

Referenced by Init_ossl_pkey().

static VALUE ossl_rsa_export | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 237 of file ossl_pkey_rsa.c.

References eRSAError, GetCipherPtr(), GetPKeyRSA, NIL_P, NULL, ossl_membio2str(), ossl_pem_passwd_cb(), ossl_raise(), rb_scan_args(), RSA_HAS_PRIVATE, and StringValuePtr.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_get_params | ( | VALUE | self | ) |

static

Definition at line 442 of file ossl_pkey_rsa.c.

References GetPKeyRSA, hash(), ossl_bn_new(), rb_hash_aset(), rb_hash_new(), and rb_str_new2().

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_initialize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 138 of file ossl_pkey_rsa.c.

References arg, eRSAError, FIX2INT, FIXNUM_P, GetPKey, NIL_P, NULL, NUM2INT, OSSL_BIO_reset, ossl_obj2bio(), ossl_pem_passwd_cb(), ossl_raise(), ossl_to_der_if_possible(), rb_scan_args(), rsa_generate(), and StringValuePtr.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_is_private | ( | VALUE | self | ) |

static

Definition at line 218 of file ossl_pkey_rsa.c.

References GetPKeyRSA, Qfalse, Qtrue, and RSA_PRIVATE.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_is_public | ( | VALUE | self | ) |

static

Definition at line 200 of file ossl_pkey_rsa.c.

References GetPKeyRSA, and Qtrue.

Referenced by Init_ossl_rsa().

VALUE ossl_rsa_new | ( | EVP_PKEY * | pkey | ) |

Definition at line 56 of file ossl_pkey_rsa.c.

References cRSA, eRSAError, NULL, ossl_raise(), Qfalse, rb_eTypeError, rsa_instance(), and WrapPKey.

Referenced by ossl_pkey_new().

static VALUE ossl_rsa_private_decrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 407 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, NUM2INT, ossl_raise(), ossl_rsa_buf_size, rb_scan_args(), rb_str_new(), rb_str_set_len, RSA_PRIVATE, RSTRING_LENINT, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_private_encrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 375 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, NUM2INT, ossl_raise(), ossl_rsa_buf_size, rb_scan_args(), rb_str_new(), rb_str_set_len, RSA_PRIVATE, RSTRING_LENINT, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_public_decrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 346 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, NUM2INT, ossl_raise(), ossl_rsa_buf_size, rb_scan_args(), rb_str_new(), rb_str_set_len, RSTRING_LENINT, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_public_encrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |

static

Definition at line 317 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, NUM2INT, ossl_raise(), ossl_rsa_buf_size, rb_scan_args(), rb_str_new(), rb_str_set_len, RSTRING_LENINT, RSTRING_PTR, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_s_generate | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |

static

Definition at line 97 of file ossl_pkey_rsa.c.

References eRSAError, NIL_P, NULL, NUM2INT, ossl_raise(), Qfalse, rb_scan_args(), rsa_generate(), rsa_instance(), and size.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_der | ( | VALUE | self | ) |

static

Definition at line 282 of file ossl_pkey_rsa.c.

References _, eRSAError, GetPKeyRSA, len, NULL, ossl_raise(), ossl_str_adjust, p, rb_str_new(), RSA_HAS_PRIVATE, and RSTRING_PTR.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_public_key | ( | VALUE | self | ) |

static

Definition at line 500 of file ossl_pkey_rsa.c.

References CLASS_OF, eRSAError, GetPKeyRSA, NULL, ossl_raise(), Qfalse, and rsa_instance().

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_text | ( | VALUE | self | ) |

static

Definition at line 474 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, ossl_membio2str(), and ossl_raise().

Referenced by Init_ossl_rsa().

static RSA* rsa_generate | ( | int | size,
|  | int | exp
| ) |  |

static

Definition at line 80 of file ossl_pkey_rsa.c.

References NULL, ossl_generate_cb(), and rb_block_given_p().

Referenced by ossl_rsa_initialize(), and ossl_rsa_s_generate().

static VALUE rsa_instance | ( | VALUE | klass,
|  | RSA * | rsa
| ) |  |

static

Definition at line 35 of file ossl_pkey_rsa.c.

References Qfalse, and WrapPKey.

Referenced by ossl_rsa_new(), ossl_rsa_s_generate(), and ossl_rsa_to_public_key().

## Variable Documentation

VALUE cRSA

Definition at line 28 of file ossl_pkey_rsa.c.

Referenced by Init_ossl_rsa(), and ossl_rsa_new().

VALUE eRSAError

Definition at line 29 of file ossl_pkey_rsa.c.

Referenced by Init_ossl_rsa(), ossl_rsa_export(), ossl_rsa_initialize(), ossl_rsa_new(), ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), ossl_rsa_public_encrypt(), ossl_rsa_s_generate(), ossl_rsa_to_der(), ossl_rsa_to_public_key(), and ossl_rsa_to_text().