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); \ 30 DSA_get0_key(dsa,
NULL, &bn);
59 if (!(pkey = EVP_PKEY_new())) {
62 if (!EVP_PKEY_assign_DSA(pkey, dsa)) {
118 DSA *
dsa = DSA_new();
137 if (cb_arg.
yield == 1) {
159 if (!DSA_generate_key(dsa)) {
240 dsa = d2i_DSAPrivateKey_bio(in,
NULL);
244 dsa = d2i_DSA_PUBKEY_bio(in,
NULL);
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)) {
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);
301 DSA_get0_key(dsa, &bn,
NULL);
345 const EVP_CIPHER *ciph =
NULL;
346 VALUE cipher, pass, str;
350 if (!
NIL_P(cipher)) {
354 if (!(out = BIO_new(BIO_s_mem()))) {
358 if (!PEM_write_bio_DSAPrivateKey(out, dsa, ciph,
NULL, 0,
364 if (!PEM_write_bio_DSA_PUBKEY(out, dsa)) {
385 int (*i2d_func)(DSA *,
unsigned char **);
392 i2d_func = (int (*)(DSA *,
unsigned char **))i2d_DSAPrivateKey;
394 i2d_func = i2d_DSA_PUBKEY;
395 if((len = i2d_func(dsa,
NULL)) <= 0)
399 if(i2d_func(dsa, &p) < 0)
423 DSA_get0_pqg(dsa, &p, &q, &g);
424 DSA_get0_key(dsa, &pub_key, &priv_key);
452 if (!(out = BIO_new(BIO_s_mem()))) {
455 if (!DSA_print(out, dsa, 0)) {
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;
530 DSA_get0_pqg(dsa,
NULL, &dsa_q,
NULL);
#define DSAPublicKey_dup(dsa)
static VALUE ossl_dsa_initialize_copy(VALUE self, VALUE other)
#define GetPKeyDSA(obj, pkey)
static unsigned int hash(str, len) register const char *str
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static VALUE ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
static void * dsa_blocking_gen(void *arg)
#define SetPKey(obj, pkey)
#define ossl_str_adjust(str, p)
static DSA * dsa_generate(int size)
static int DSA_HAS_PRIVATE(DSA *dsa)
static VALUE ossl_dsa_is_public(VALUE self)
BIO * ossl_obj2bio(volatile VALUE *pobj)
void rb_str_set_len(VALUE, long)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
#define GetPKey(obj, pkey)
#define OSSL_PKEY_IS_PRIVATE(obj)
VALUE ossl_membio2str(BIO *bio)
static VALUE dsa_instance(VALUE klass, DSA *dsa)
#define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2)
static VALUE ossl_dsa_to_text(VALUE self)
#define rb_define_copy_func(klass, func)
VALUE ossl_to_der_if_possible(VALUE obj)
void ossl_generate_cb_stop(void *ptr)
#define PEM_read_bio_DSAPublicKey(bp, x, cb, u)
void ossl_clear_error(void)
static VALUE ossl_dsa_s_generate(VALUE klass, VALUE size)
int rb_block_given_p(void)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
RUBY_EXTERN VALUE rb_cObject
static VALUE ossl_dsa_to_der(VALUE self)
#define OSSL_BIO_reset(bio)
static VALUE ossl_dsa_to_public_key(VALUE self)
#define DEF_OSSL_PKEY_BN(class, keytype, name)
const EVP_CIPHER * GetCipherPtr(VALUE obj)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
int ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd_)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
int ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
#define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static int DSA_PRIVATE(VALUE obj, DSA *dsa)
static VALUE ossl_dsa_get_params(VALUE self)
VALUE ossl_pem_passwd_value(VALUE pass)
void rb_jump_tag(int tag)
register unsigned int len
VALUE rb_define_module_under(VALUE outer, const char *name)
static VALUE ossl_dsa_sign(VALUE self, VALUE data)
VALUE ossl_dsa_new(EVP_PKEY *pkey)
static VALUE ossl_dsa_is_private(VALUE self)
void ossl_raise(VALUE exc, const char *fmt,...)
#define BN_GENCB_free(cb)
static VALUE ossl_dsa_export(int argc, VALUE *argv, VALUE self)
VALUE ossl_bn_new(const BIGNUM *bn)
static VALUE ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
#define EVP_PKEY_base_id(pkey)
#define RSTRING_LENINT(str)
#define RB_INTEGER_TYPE_P(obj)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_obj_class(VALUE)
VALUE rb_str_new(const char *, long)