Ruby  2.1.10p492(2016-04-01revision54464)
ossl_pkey_dsa.c
Go to the documentation of this file.
1 /*
2  * $Id: ossl_pkey_dsa.c 40316 2013-04-16 02:24:09Z zzak $
3  * 'OpenSSL for Ruby' project
4  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5  * All rights reserved.
6  */
7 /*
8  * This program is licenced under the same licence as Ruby.
9  * (See the file 'LICENCE'.)
10  */
11 #if !defined(OPENSSL_NO_DSA)
12 
13 #include "ossl.h"
14 
15 #define GetPKeyDSA(obj, pkey) do { \
16  GetPKey((obj), (pkey)); \
17  if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_DSA) { /* PARANOIA? */ \
18  ossl_raise(rb_eRuntimeError, "THIS IS NOT A DSA!"); \
19  } \
20 } while (0)
21 
22 #define DSA_HAS_PRIVATE(dsa) ((dsa)->priv_key)
23 #define DSA_PRIVATE(obj,dsa) (DSA_HAS_PRIVATE(dsa)||OSSL_PKEY_IS_PRIVATE(obj))
24 
25 /*
26  * Classes
27  */
30 
31 /*
32  * Public
33  */
34 static VALUE
35 dsa_instance(VALUE klass, DSA *dsa)
36 {
37  EVP_PKEY *pkey;
38  VALUE obj;
39 
40  if (!dsa) {
41  return Qfalse;
42  }
43  if (!(pkey = EVP_PKEY_new())) {
44  return Qfalse;
45  }
46  if (!EVP_PKEY_assign_DSA(pkey, dsa)) {
47  EVP_PKEY_free(pkey);
48  return Qfalse;
49  }
50  WrapPKey(klass, obj, pkey);
51 
52  return obj;
53 }
54 
55 VALUE
56 ossl_dsa_new(EVP_PKEY *pkey)
57 {
58  VALUE obj;
59 
60  if (!pkey) {
61  obj = dsa_instance(cDSA, DSA_new());
62  } else {
63  if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DSA) {
64  ossl_raise(rb_eTypeError, "Not a DSA key!");
65  }
66  WrapPKey(cDSA, obj, pkey);
67  }
68  if (obj == Qfalse) {
70  }
71 
72  return obj;
73 }
74 
75 /*
76  * Private
77  */
78 #if defined(HAVE_DSA_GENERATE_PARAMETERS_EX) && HAVE_BN_GENCB
79 struct dsa_blocking_gen_arg {
80  DSA *dsa;
81  int size;
82  unsigned char* seed;
83  int seed_len;
84  int *counter;
85  unsigned long *h;
86  BN_GENCB *cb;
87  int result;
88 };
89 
90 static void *
91 dsa_blocking_gen(void *arg)
92 {
93  struct dsa_blocking_gen_arg *gen = (struct dsa_blocking_gen_arg *)arg;
94  gen->result = DSA_generate_parameters_ex(gen->dsa, gen->size, gen->seed, gen->seed_len, gen->counter, gen->h, gen->cb);
95  return 0;
96 }
97 #endif
98 
99 static DSA *
101 {
102 #if defined(HAVE_DSA_GENERATE_PARAMETERS_EX) && HAVE_BN_GENCB
103  BN_GENCB cb;
104  struct ossl_generate_cb_arg cb_arg;
105  struct dsa_blocking_gen_arg gen_arg;
106  DSA *dsa = DSA_new();
107  unsigned char seed[20];
108  int seed_len = 20, counter;
109  unsigned long h;
110 
111  if (!dsa) return 0;
112  if (!RAND_bytes(seed, seed_len)) {
113  DSA_free(dsa);
114  return 0;
115  }
116 
117  memset(&cb_arg, 0, sizeof(struct ossl_generate_cb_arg));
118  if (rb_block_given_p())
119  cb_arg.yield = 1;
120  BN_GENCB_set(&cb, ossl_generate_cb_2, &cb_arg);
121  gen_arg.dsa = dsa;
122  gen_arg.size = size;
123  gen_arg.seed = seed;
124  gen_arg.seed_len = seed_len;
125  gen_arg.counter = &counter;
126  gen_arg.h = &h;
127  gen_arg.cb = &cb;
128  if (cb_arg.yield == 1) {
129  /* we cannot release GVL when callback proc is supplied */
130  dsa_blocking_gen(&gen_arg);
131  } else {
132  /* there's a chance to unblock */
133  rb_thread_call_without_gvl(dsa_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
134  }
135  if (!gen_arg.result) {
136  DSA_free(dsa);
137  if (cb_arg.state) rb_jump_tag(cb_arg.state);
138  return 0;
139  }
140 #else
141  DSA *dsa;
142  unsigned char seed[20];
143  int seed_len = 20, counter;
144  unsigned long h;
145 
146  if (!RAND_bytes(seed, seed_len)) {
147  return 0;
148  }
149  dsa = DSA_generate_parameters(size, seed, seed_len, &counter, &h,
151  if(!dsa) return 0;
152 #endif
153 
154  if (!DSA_generate_key(dsa)) {
155  DSA_free(dsa);
156  return 0;
157  }
158 
159  return dsa;
160 }
161 
162 /*
163  * call-seq:
164  * DSA.generate(size) -> dsa
165  *
166  * Creates a new DSA instance by generating a private/public key pair
167  * from scratch.
168  *
169  * === Parameters
170  * * +size+ is an integer representing the desired key size.
171  *
172  */
173 static VALUE
175 {
176  DSA *dsa = dsa_generate(NUM2INT(size)); /* err handled by dsa_instance */
177  VALUE obj = dsa_instance(klass, dsa);
178 
179  if (obj == Qfalse) {
180  DSA_free(dsa);
182  }
183 
184  return obj;
185 }
186 
187 /*
188  * call-seq:
189  * DSA.new([size | string [, pass]) -> dsa
190  *
191  * Creates a new DSA instance by reading an existing key from +string+.
192  *
193  * === Parameters
194  * * +size+ is an integer representing the desired key size.
195  * * +string+ contains a DER or PEM encoded key.
196  * * +pass+ is a string that contains an optional password.
197  *
198  * === Examples
199  * DSA.new -> dsa
200  * DSA.new(1024) -> dsa
201  * DSA.new(File.read('dsa.pem')) -> dsa
202  * DSA.new(File.read('dsa.pem'), 'mypassword') -> dsa
203  *
204  */
205 static VALUE
207 {
208  EVP_PKEY *pkey;
209  DSA *dsa;
210  BIO *in;
211  char *passwd = NULL;
212  VALUE arg, pass;
213 
214  GetPKey(self, pkey);
215  if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) {
216  dsa = DSA_new();
217  }
218  else if (FIXNUM_P(arg)) {
219  if (!(dsa = dsa_generate(FIX2INT(arg)))) {
221  }
222  }
223  else {
224  if (!NIL_P(pass)) passwd = StringValuePtr(pass);
225  arg = ossl_to_der_if_possible(arg);
226  in = ossl_obj2bio(arg);
227  dsa = PEM_read_bio_DSAPrivateKey(in, NULL, ossl_pem_passwd_cb, passwd);
228  if (!dsa) {
229  OSSL_BIO_reset(in);
230  dsa = PEM_read_bio_DSA_PUBKEY(in, NULL, NULL, NULL);
231  }
232  if (!dsa) {
233  OSSL_BIO_reset(in);
234  dsa = d2i_DSAPrivateKey_bio(in, NULL);
235  }
236  if (!dsa) {
237  OSSL_BIO_reset(in);
238  dsa = d2i_DSA_PUBKEY_bio(in, NULL);
239  }
240  if (!dsa) {
241  OSSL_BIO_reset(in);
243  }
244  BIO_free(in);
245  if (!dsa) {
246  ERR_clear_error();
247  ossl_raise(eDSAError, "Neither PUB key nor PRIV key");
248  }
249  }
250  if (!EVP_PKEY_assign_DSA(pkey, dsa)) {
251  DSA_free(dsa);
253  }
254 
255  return self;
256 }
257 
258 /*
259  * call-seq:
260  * dsa.public? -> true | false
261  *
262  * Indicates whether this DSA instance has a public key associated with it or
263  * not. The public key may be retrieved with DSA#public_key.
264  */
265 static VALUE
267 {
268  EVP_PKEY *pkey;
269 
270  GetPKeyDSA(self, pkey);
271 
272  return (pkey->pkey.dsa->pub_key) ? Qtrue : Qfalse;
273 }
274 
275 /*
276  * call-seq:
277  * dsa.private? -> true | false
278  *
279  * Indicates whether this DSA instance has a private key associated with it or
280  * not. The private key may be retrieved with DSA#private_key.
281  */
282 static VALUE
284 {
285  EVP_PKEY *pkey;
286 
287  GetPKeyDSA(self, pkey);
288 
289  return (DSA_PRIVATE(self, pkey->pkey.dsa)) ? Qtrue : Qfalse;
290 }
291 
292 /*
293  * call-seq:
294  * dsa.export([cipher, password]) -> aString
295  * dsa.to_pem([cipher, password]) -> aString
296  * dsa.to_s([cipher, password]) -> aString
297  *
298  * Encodes this DSA to its PEM encoding.
299  *
300  * === Parameters
301  * * +cipher+ is an OpenSSL::Cipher.
302  * * +password+ is a string containing your password.
303  *
304  * === Examples
305  * DSA.to_pem -> aString
306  * DSA.to_pem(cipher, 'mypassword') -> aString
307  *
308  */
309 static VALUE
311 {
312  EVP_PKEY *pkey;
313  BIO *out;
314  const EVP_CIPHER *ciph = NULL;
315  char *passwd = NULL;
316  VALUE cipher, pass, str;
317 
318  GetPKeyDSA(self, pkey);
319  rb_scan_args(argc, argv, "02", &cipher, &pass);
320  if (!NIL_P(cipher)) {
321  ciph = GetCipherPtr(cipher);
322  if (!NIL_P(pass)) {
323  StringValue(pass);
324  if (RSTRING_LENINT(pass) < OSSL_MIN_PWD_LEN)
325  ossl_raise(eOSSLError, "OpenSSL requires passwords to be at least four characters long");
326  passwd = RSTRING_PTR(pass);
327  }
328  }
329  if (!(out = BIO_new(BIO_s_mem()))) {
331  }
332  if (DSA_HAS_PRIVATE(pkey->pkey.dsa)) {
333  if (!PEM_write_bio_DSAPrivateKey(out, pkey->pkey.dsa, ciph,
334  NULL, 0, ossl_pem_passwd_cb, passwd)){
335  BIO_free(out);
337  }
338  } else {
339  if (!PEM_write_bio_DSA_PUBKEY(out, pkey->pkey.dsa)) {
340  BIO_free(out);
342  }
343  }
344  str = ossl_membio2str(out);
345 
346  return str;
347 }
348 
349 /*
350  * call-seq:
351  * dsa.to_der -> aString
352  *
353  * Encodes this DSA to its DER encoding.
354  *
355  */
356 static VALUE
358 {
359  EVP_PKEY *pkey;
360  int (*i2d_func)_((DSA*, unsigned char**));
361  unsigned char *p;
362  long len;
363  VALUE str;
364 
365  GetPKeyDSA(self, pkey);
366  if(DSA_HAS_PRIVATE(pkey->pkey.dsa))
367  i2d_func = (int(*)_((DSA*,unsigned char**)))i2d_DSAPrivateKey;
368  else
369  i2d_func = i2d_DSA_PUBKEY;
370  if((len = i2d_func(pkey->pkey.dsa, NULL)) <= 0)
372  str = rb_str_new(0, len);
373  p = (unsigned char *)RSTRING_PTR(str);
374  if(i2d_func(pkey->pkey.dsa, &p) < 0)
376  ossl_str_adjust(str, p);
377 
378  return str;
379 }
380 
381 /*
382  * call-seq:
383  * dsa.params -> hash
384  *
385  * Stores all parameters of key to the hash
386  * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
387  * Don't use :-)) (I's up to you)
388  */
389 static VALUE
391 {
392  EVP_PKEY *pkey;
393  VALUE hash;
394 
395  GetPKeyDSA(self, pkey);
396 
397  hash = rb_hash_new();
398 
399  rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(pkey->pkey.dsa->p));
400  rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(pkey->pkey.dsa->q));
401  rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dsa->g));
402  rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dsa->pub_key));
403  rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dsa->priv_key));
404 
405  return hash;
406 }
407 
408 /*
409  * call-seq:
410  * dsa.to_text -> aString
411  *
412  * Prints all parameters of key to buffer
413  * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
414  * Don't use :-)) (I's up to you)
415  */
416 static VALUE
418 {
419  EVP_PKEY *pkey;
420  BIO *out;
421  VALUE str;
422 
423  GetPKeyDSA(self, pkey);
424  if (!(out = BIO_new(BIO_s_mem()))) {
426  }
427  if (!DSA_print(out, pkey->pkey.dsa, 0)) { /* offset = 0 */
428  BIO_free(out);
430  }
431  str = ossl_membio2str(out);
432 
433  return str;
434 }
435 
436 /*
437  * call-seq:
438  * dsa.public_key -> aDSA
439  *
440  * Returns a new DSA instance that carries just the public key information.
441  * If the current instance has also private key information, this will no
442  * longer be present in the new instance. This feature is helpful for
443  * publishing the public key information without leaking any of the private
444  * information.
445  *
446  * === Example
447  * dsa = OpenSSL::PKey::DSA.new(2048) # has public and private information
448  * pub_key = dsa.public_key # has only the public part available
449  * pub_key_der = pub_key.to_der # it's safe to publish this
450  *
451  *
452  */
453 static VALUE
455 {
456  EVP_PKEY *pkey;
457  DSA *dsa;
458  VALUE obj;
459 
460  GetPKeyDSA(self, pkey);
461  /* err check performed by dsa_instance */
462  dsa = DSAPublicKey_dup(pkey->pkey.dsa);
463  obj = dsa_instance(CLASS_OF(self), dsa);
464  if (obj == Qfalse) {
465  DSA_free(dsa);
467  }
468  return obj;
469 }
470 
471 #define ossl_dsa_buf_size(pkey) (DSA_size((pkey)->pkey.dsa)+16)
472 
473 /*
474  * call-seq:
475  * dsa.syssign(string) -> aString
476  *
477  * Computes and returns the DSA signature of +string+, where +string+ is
478  * expected to be an already-computed message digest of the original input
479  * data. The signature is issued using the private key of this DSA instance.
480  *
481  * === Parameters
482  * * +string+ is a message digest of the original input data to be signed
483  *
484  * === Example
485  * dsa = OpenSSL::PKey::DSA.new(2048)
486  * doc = "Sign me"
487  * digest = OpenSSL::Digest::SHA1.digest(doc)
488  * sig = dsa.syssign(digest)
489  *
490  *
491  */
492 static VALUE
494 {
495  EVP_PKEY *pkey;
496  unsigned int buf_len;
497  VALUE str;
498 
499  GetPKeyDSA(self, pkey);
500  StringValue(data);
501  if (!DSA_PRIVATE(self, pkey->pkey.dsa)) {
502  ossl_raise(eDSAError, "Private DSA key needed!");
503  }
504  str = rb_str_new(0, ossl_dsa_buf_size(pkey));
505  if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data),
506  (unsigned char *)RSTRING_PTR(str),
507  &buf_len, pkey->pkey.dsa)) { /* type is ignored (0) */
509  }
510  rb_str_set_len(str, buf_len);
511 
512  return str;
513 }
514 
515 /*
516  * call-seq:
517  * dsa.sysverify(digest, sig) -> true | false
518  *
519  * Verifies whether the signature is valid given the message digest input. It
520  * does so by validating +sig+ using the public key of this DSA instance.
521  *
522  * === Parameters
523  * * +digest+ is a message digest of the original input data to be signed
524  * * +sig+ is a DSA signature value
525  *
526  * === Example
527  * dsa = OpenSSL::PKey::DSA.new(2048)
528  * doc = "Sign me"
529  * digest = OpenSSL::Digest::SHA1.digest(doc)
530  * sig = dsa.syssign(digest)
531  * puts dsa.sysverify(digest, sig) # => true
532  *
533  */
534 static VALUE
535 ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
536 {
537  EVP_PKEY *pkey;
538  int ret;
539 
540  GetPKeyDSA(self, pkey);
541  StringValue(digest);
542  StringValue(sig);
543  /* type is ignored (0) */
544  ret = DSA_verify(0, (unsigned char *)RSTRING_PTR(digest), RSTRING_LENINT(digest),
545  (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey->pkey.dsa);
546  if (ret < 0) {
548  }
549  else if (ret == 1) {
550  return Qtrue;
551  }
552 
553  return Qfalse;
554 }
555 
556 OSSL_PKEY_BN(dsa, p)
557 OSSL_PKEY_BN(dsa, q)
558 OSSL_PKEY_BN(dsa, g)
559 OSSL_PKEY_BN(dsa, pub_key)
560 OSSL_PKEY_BN(dsa, priv_key)
561 
562 /*
563  * INIT
564  */
565 void
567 {
568 #if 0
569  mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL and mPKey */
571 #endif
572 
573  /* Document-class: OpenSSL::PKey::DSAError
574  *
575  * Generic exception that is raised if an operation on a DSA PKey
576  * fails unexpectedly or in case an instantiation of an instance of DSA
577  * fails due to non-conformant input data.
578  */
580 
581  /* Document-class: OpenSSL::PKey::DSA
582  *
583  * DSA, the Digital Signature Algorithm, is specified in NIST's
584  * FIPS 186-3. It is an asymmetric public key algorithm that may be used
585  * similar to e.g. RSA.
586  * Please note that for OpenSSL versions prior to 1.0.0 the digest
587  * algorithms OpenSSL::Digest::DSS (equivalent to SHA) or
588  * OpenSSL::Digest::DSS1 (equivalent to SHA-1) must be used for issuing
589  * signatures with a DSA key using OpenSSL::PKey#sign.
590  * Starting with OpenSSL 1.0.0, digest algorithms are no longer restricted,
591  * any Digest may be used for signing.
592  */
594 
596  rb_define_method(cDSA, "initialize", ossl_dsa_initialize, -1);
597 
598  rb_define_method(cDSA, "public?", ossl_dsa_is_public, 0);
599  rb_define_method(cDSA, "private?", ossl_dsa_is_private, 0);
600  rb_define_method(cDSA, "to_text", ossl_dsa_to_text, 0);
601  rb_define_method(cDSA, "export", ossl_dsa_export, -1);
602  rb_define_alias(cDSA, "to_pem", "export");
603  rb_define_alias(cDSA, "to_s", "export");
604  rb_define_method(cDSA, "to_der", ossl_dsa_to_der, 0);
605  rb_define_method(cDSA, "public_key", ossl_dsa_to_public_key, 0);
606  rb_define_method(cDSA, "syssign", ossl_dsa_sign, 1);
607  rb_define_method(cDSA, "sysverify", ossl_dsa_verify, 2);
608 
609  DEF_OSSL_PKEY_BN(cDSA, dsa, p);
610  DEF_OSSL_PKEY_BN(cDSA, dsa, q);
611  DEF_OSSL_PKEY_BN(cDSA, dsa, g);
612  DEF_OSSL_PKEY_BN(cDSA, dsa, pub_key);
613  DEF_OSSL_PKEY_BN(cDSA, dsa, priv_key);
614 
616 }
617 
618 #else /* defined NO_DSA */
619 void
621 {
622 }
623 #endif /* NO_DSA */
VALUE mOSSL
Definition: ossl.c:259
#define GetPKeyDSA(obj, pkey)
Definition: ossl_pkey_dsa.c:15
#define NUM2INT(x)
Definition: ruby.h:630
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
Definition: class.c:1646
VALUE mPKey
Definition: ossl_pkey.c:16
static VALUE ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
#define CLASS_OF(v)
Definition: ruby.h:440
VALUE ePKeyError
Definition: ossl_pkey.c:18
#define OSSL_PKEY_BN(keytype, name)
Definition: ossl_pkey.h:103
#define Qtrue
Definition: ruby.h:426
#define ossl_str_adjust(str, p)
Definition: ossl.h:138
static DSA * dsa_generate(int size)
VALUE rb_eTypeError
Definition: error.c:548
static VALUE ossl_dsa_is_public(VALUE self)
void rb_str_set_len(VALUE, long)
Definition: string.c:2007
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:657
VALUE eDSAError
Definition: ossl_pkey_dsa.c:29
#define GetPKey(obj, pkey)
Definition: ossl_pkey.h:30
VALUE ossl_membio2str(BIO *bio)
Definition: ossl_bio.c:77
#define FIXNUM_P(f)
Definition: ruby.h:347
#define OSSL_MIN_PWD_LEN
Definition: ossl.h:81
static VALUE dsa_instance(VALUE klass, DSA *dsa)
Definition: ossl_pkey_dsa.c:35
VALUE cDSA
Definition: ossl_pkey_dsa.c:28
void ossl_generate_cb(int p, int n, void *arg)
Definition: ossl_pkey.c:25
static VALUE ossl_dsa_to_text(VALUE self)
VALUE ossl_to_der_if_possible(VALUE obj)
Definition: ossl.c:283
static VALUE ossl_dsa_s_generate(VALUE klass, VALUE size)
int rb_block_given_p(void)
Definition: eval.c:712
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
Definition: hash.c:1402
static VALUE ossl_dsa_to_der(VALUE self)
#define OSSL_BIO_reset(bio)
Definition: ossl.h:155
static VALUE ossl_dsa_to_public_key(VALUE self)
#define NIL_P(v)
Definition: ruby.h:438
#define DEF_OSSL_PKEY_BN(class, keytype, name)
Definition: ossl_pkey.h:145
VALUE eOSSLError
Definition: ossl.c:264
int argc
Definition: ruby.c:131
#define Qfalse
Definition: ruby.h:425
#define rb_str_new2
Definition: intern.h:840
const EVP_CIPHER * GetCipherPtr(VALUE obj)
Definition: ossl_cipher.c:45
#define ossl_dsa_buf_size(pkey)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
Definition: class.c:1688
#define WrapPKey(klass, obj, pkey)
Definition: ossl_pkey.h:23
BIO * ossl_obj2bio(VALUE obj)
Definition: ossl_bio.c:17
VALUE rb_hash_new(void)
Definition: hash.c:307
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Definition: class.c:1719
static VALUE ossl_dsa_get_params(VALUE self)
unsigned long VALUE
Definition: ruby.h:88
static VALUE result
Definition: nkf.c:40
#define FIX2INT(x)
Definition: ruby.h:632
#define PEM_read_bio_DSAPublicKey(bp, x, cb, u)
void rb_jump_tag(int tag)
Definition: eval.c:706
#define _(args)
Definition: dln.h:28
#define DSAPublicKey_dup(dsa)
VALUE rb_define_module_under(VALUE outer, const char *name)
Definition: class.c:747
static VALUE ossl_dsa_sign(VALUE self, VALUE data)
#define RSTRING_PTR(str)
Definition: ruby.h:845
int size
Definition: encoding.c:49
VALUE ossl_dsa_new(EVP_PKEY *pkey)
Definition: ossl_pkey_dsa.c:56
static VALUE ossl_dsa_is_private(VALUE self)
void ossl_raise(VALUE exc, const char *fmt,...)
Definition: ossl.c:333
static unsigned int hash(const char *str, unsigned int len)
Definition: lex.c:56
static VALUE ossl_dsa_export(int argc, VALUE *argv, VALUE self)
VALUE ossl_bn_new(const BIGNUM *bn)
Definition: ossl_bn.c:43
#define StringValuePtr(v)
Definition: ruby.h:540
#define DSA_PRIVATE(obj, dsa)
Definition: ossl_pkey_dsa.c:23
int ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
Definition: ossl.c:162
static VALUE ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
#define RSTRING_LENINT(str)
Definition: ruby.h:853
void Init_ossl_dsa()
VALUE rb_define_module(const char *name)
Definition: class.c:727
VALUE cPKey
Definition: ossl_pkey.c:17
#define NULL
Definition: _sdbm.c:102
#define DSA_HAS_PRIVATE(dsa)
Definition: ossl_pkey_dsa.c:22
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1479
char ** argv
Definition: ruby.c:132
#define StringValue(v)
Definition: ruby.h:539
VALUE rb_str_new(const char *, long)
Definition: string.c:534