12#if !defined(OPENSSL_NO_DSA)
14#define GetPKeyDSA(obj, pkey) do { \
15 GetPKey((obj), (pkey)); \
16 if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DSA) { \
17 ossl_raise(rb_eRuntimeError, "THIS IS NOT A DSA!"); \
20#define GetDSA(obj, dsa) do { \
22 GetPKeyDSA((obj), _pkey); \
23 (dsa) = EVP_PKEY_get0_DSA(_pkey); \
27DSA_HAS_PRIVATE(DSA *dsa)
30 DSA_get0_key(dsa,
NULL, &bn);
35DSA_PRIVATE(
VALUE obj, DSA *dsa)
50dsa_instance(
VALUE klass, DSA *dsa)
59 if (!(pkey = EVP_PKEY_new())) {
62 if (!EVP_PKEY_assign_DSA(pkey, dsa)) {
77 obj = dsa_instance(
cDSA, DSA_new());
80 if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DSA) {
105dsa_blocking_gen(
void *arg)
114dsa_generate(
int size)
118 DSA *
dsa = DSA_new();
137 if (cb_arg.
yield == 1) {
139 dsa_blocking_gen(&gen_arg);
146 if (!gen_arg.result) {
159 if (!DSA_generate_key(
dsa)) {
182 VALUE obj = dsa_instance(klass,
dsa);
248#define PEM_read_bio_DSAPublicKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
249 (d2i_of_void *)d2i_DSAPublicKey, PEM_STRING_DSA_PUBLIC, (bp), (void **)(x), (cb), (u))
251#undef PEM_read_bio_DSAPublicKey
259 if (!EVP_PKEY_assign_DSA(pkey,
dsa)) {
268ossl_dsa_initialize_copy(
VALUE self,
VALUE other)
274 if (EVP_PKEY_base_id(pkey) != EVP_PKEY_NONE)
278 dsa_new = ASN1_dup((i2d_of_void *)i2d_DSAPrivateKey, (d2i_of_void *)d2i_DSAPrivateKey, (
char *)
dsa);
282 EVP_PKEY_assign_DSA(pkey, dsa_new);
295ossl_dsa_is_public(
VALUE self)
314ossl_dsa_is_private(
VALUE self)
345 const EVP_CIPHER *ciph =
NULL;
350 if (!
NIL_P(cipher)) {
354 if (!(
out = BIO_new(BIO_s_mem()))) {
357 if (DSA_HAS_PRIVATE(
dsa)) {
358 if (!PEM_write_bio_DSAPrivateKey(
out,
dsa, ciph,
NULL, 0,
364 if (!PEM_write_bio_DSA_PUBKEY(
out,
dsa)) {
382ossl_dsa_to_der(
VALUE self)
385 int (*i2d_func)(DSA *,
unsigned char **);
391 if(DSA_HAS_PRIVATE(
dsa))
392 i2d_func = (
int (*)(DSA *,
unsigned char **))i2d_DSAPrivateKey;
394 i2d_func = i2d_DSA_PUBKEY;
399 if(i2d_func(
dsa, &p) < 0)
416ossl_dsa_get_params(
VALUE self)
423 DSA_get0_pqg(
dsa, &p, &q, &
g);
445ossl_dsa_to_text(
VALUE self)
452 if (!(
out = BIO_new(BIO_s_mem()))) {
455 if (!DSA_print(
out,
dsa, 0)) {
482ossl_dsa_to_public_key(
VALUE self)
490#define DSAPublicKey_dup(dsa) (DSA *)ASN1_dup( \
491 (i2d_of_void *)i2d_DSAPublicKey, (d2i_of_void *)d2i_DSAPublicKey, (char *)(dsa))
493#undef DSAPublicKey_dup
526 unsigned int buf_len;
533 if (!DSA_PRIVATE(self,
dsa))
537 if (!DSA_sign(0, (
unsigned char *)
RSTRING_PTR(data), RSTRING_LENINT(data),
576 ret = DSA_verify(0, (
unsigned char *)
RSTRING_PTR(digest), RSTRING_LENINT(digest),
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
#define rb_define_singleton_method(klass, mid, func, arity)
Defines klass.mid.
char str[HTML_ESCAPE_MAX_LEN+1]
#define RSTRING_PTR(string)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
VALUE rb_define_module_under(VALUE outer, const char *name)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
int rb_block_given_p(void)
Determines if the current method is given a block.
void rb_jump_tag(int tag)
Continues the exception caught by rb_protect() and rb_eval_string_protect().
VALUE rb_cObject
Object class.
VALUE rb_obj_class(VALUE)
unsigned in(void *in_desc, z_const unsigned char **buf)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
#define rb_str_new(str, len)
void rb_str_set_len(VALUE, long)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
#define BN_GENCB_free(cb)
int ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd_)
VALUE ossl_pem_passwd_value(VALUE pass)
VALUE ossl_to_der_if_possible(VALUE obj)
void ossl_raise(VALUE exc, const char *fmt,...)
void ossl_clear_error(void)
#define ossl_str_adjust(str, p)
#define OSSL_BIO_reset(bio)
BIO * ossl_obj2bio(volatile VALUE *pobj)
VALUE ossl_membio2str(BIO *bio)
VALUE ossl_bn_new(const BIGNUM *bn)
const EVP_CIPHER * ossl_evp_get_cipherbyname(VALUE obj)
int ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
void ossl_generate_cb_stop(void *ptr)
#define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3)
#define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2)
#define GetPKey(obj, pkey)
#define SetPKey(obj, pkey)
#define DEF_OSSL_PKEY_BN(class, keytype, name)
#define OSSL_PKEY_IS_PRIVATE(obj)
#define PEM_read_bio_DSAPublicKey(bp, x, cb, u)
VALUE ossl_dsa_new(EVP_PKEY *pkey)
#define DSAPublicKey_dup(dsa)
#define GetPKeyDSA(obj, pkey)
#define RB_INTEGER_TYPE_P(obj)