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);
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)) {
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)) {
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))
char str[HTML_ESCAPE_MAX_LEN+1]
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
VALUE rb_define_module_under(VALUE, const char *)
void rb_define_alias(VALUE, const char *, const char *)
Defines an alias of a method.
int rb_block_given_p(void)
Determines if the current method is given a block.
VALUE rb_cObject
Object class.
void rb_jump_tag(int tag)
Continues the exception caught by rb_protect() and rb_eval_string_protect().
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
#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)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)