Ruby: ext/openssl/ossl_x509name.c Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

ossl_x509name.c
Go to the documentation of this file.
1/*
2 * 'OpenSSL for Ruby' project
3 * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
4 * All rights reserved.
5 */
6/*
7 * This program is licensed under the same licence as Ruby.
8 * (See the file 'LICENCE'.)
9 */
10#include "ossl.h"
11
12#define NewX509Name(klass) \
13 TypedData_Wrap_Struct((klass), &ossl_x509name_type, 0)
14#define SetX509Name(obj, name) do { \
15 if (!(name)) { \
16 ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
17 } \
18 RTYPEDDATA_DATA(obj) = (name); \
19} while (0)
20#define GetX509Name(obj, name) do { \
21 TypedData_Get_Struct((obj), X509_NAME, &ossl_x509name_type, (name)); \
22 if (!(name)) { \
23 ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
24 } \
25} while (0)
26
27#define OBJECT_TYPE_TEMPLATE \
28 rb_const_get(cX509Name, rb_intern("OBJECT_TYPE_TEMPLATE"))
29#define DEFAULT_OBJECT_TYPE \
30 rb_const_get(cX509Name, rb_intern("DEFAULT_OBJECT_TYPE"))
31
32/*
33 * Classes
34 */
35 VALUE cX509Name;
36 VALUE eX509NameError;
37
38static void
39ossl_x509name_free(void *ptr)
40{
41 X509_NAME_free(ptr);
42}
43
44static const rb_data_type_t ossl_x509name_type = {
45 "OpenSSL/X509/NAME",
46 {
47 0, ossl_x509name_free,
48 },
49 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
50};
51
52/*
53 * Public
54 */
55 VALUE
56 ossl_x509name_new(X509_NAME *name)
57{
58 X509_NAME *new;
59 VALUE obj;
60
61 obj = NewX509Name(cX509Name);
62 if (!name) {
63 new = X509_NAME_new();
64 } else {
65 new = X509_NAME_dup(name);
66 }
67 if (!new) {
68 ossl_raise(eX509NameError, NULL);
69 }
70 SetX509Name(obj, new);
71
72 return obj;
73}
74
75X509_NAME *
76 GetX509NamePtr(VALUE obj)
77{
78 X509_NAME *name;
79
80 GetX509Name(obj, name);
81
82 return name;
83}
84
85/*
86 * Private
87 */
88static VALUE
89ossl_x509name_alloc(VALUE klass)
90{
91 X509_NAME *name;
92 VALUE obj;
93
94 obj = NewX509Name(klass);
95 if (!(name = X509_NAME_new())) {
96 ossl_raise(eX509NameError, NULL);
97 }
98 SetX509Name(obj, name);
99
100 return obj;
101}
102
103static ID id_aref;
104static VALUE ossl_x509name_add_entry(int, VALUE*, VALUE);
105#define rb_aref(obj, key) rb_funcall((obj), id_aref, 1, (key))
106
107static VALUE
108ossl_x509name_init_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
109{
110 VALUE self = rb_ary_entry(args, 0);
111 VALUE template = rb_ary_entry(args, 1);
112 VALUE entry[3];
113
114 Check_Type(i, T_ARRAY);
115 entry[0] = rb_ary_entry(i, 0);
116 entry[1] = rb_ary_entry(i, 1);
117 entry[2] = rb_ary_entry(i, 2);
118 if(NIL_P(entry[2])) entry[2] = rb_aref(template, entry[0]);
119 if(NIL_P(entry[2])) entry[2] = DEFAULT_OBJECT_TYPE;
120 ossl_x509name_add_entry(3, entry, self);
121
122 return Qnil;
123}
124
125/*
126 * call-seq:
127 * X509::Name.new => name
128 * X509::Name.new(der) => name
129 * X509::Name.new(distinguished_name) => name
130 * X509::Name.new(distinguished_name, template) => name
131 *
132 * Creates a new Name.
133 *
134 * A name may be created from a DER encoded string _der_, an Array
135 * representing a _distinguished_name_ or a _distinguished_name_ along with a
136 * _template_.
137 *
138 * name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]
139 *
140 * name = OpenSSL::X509::Name.new name.to_der
141 *
142 * See add_entry for a description of the _distinguished_name_ Array's
143 * contents
144 */
145static VALUE
146ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)
147{
148 X509_NAME *name;
149 VALUE arg, template;
150
151 GetX509Name(self, name);
152 if (rb_scan_args(argc, argv, "02", &arg, &template) == 0) {
153 return self;
154 }
155 else {
156 VALUE tmp = rb_check_array_type(arg);
157 if (!NIL_P(tmp)) {
158 VALUE args;
159 if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE;
160 args = rb_ary_new3(2, self, template);
161 rb_block_call(tmp, rb_intern("each"), 0, 0, ossl_x509name_init_i, args);
162 }
163 else{
164 const unsigned char *p;
165 VALUE str = ossl_to_der_if_possible(arg);
166 X509_NAME *x;
167 StringValue(str);
168 p = (unsigned char *)RSTRING_PTR(str);
169 x = d2i_X509_NAME(&name, &p, RSTRING_LEN(str));
170 DATA_PTR(self) = name;
171 if(!x){
172 ossl_raise(eX509NameError, NULL);
173 }
174 }
175 }
176
177 return self;
178}
179
180static VALUE
181ossl_x509name_initialize_copy(VALUE self, VALUE other)
182{
183 X509_NAME *name, *name_other, *name_new;
184
185 rb_check_frozen(self);
186 GetX509Name(self, name);
187 GetX509Name(other, name_other);
188
189 name_new = X509_NAME_dup(name_other);
190 if (!name_new)
191 ossl_raise(eX509NameError, "X509_NAME_dup");
192
193 SetX509Name(self, name_new);
194 X509_NAME_free(name);
195
196 return self;
197}
198
199/*
200 * call-seq:
201 * name.add_entry(oid, value [, type], loc: -1, set: 0) => self
202 *
203 * Adds a new entry with the given _oid_ and _value_ to this name. The _oid_
204 * is an object identifier defined in ASN.1. Some common OIDs are:
205 *
206 * C:: Country Name
207 * CN:: Common Name
208 * DC:: Domain Component
209 * O:: Organization Name
210 * OU:: Organizational Unit Name
211 * ST:: State or Province Name
212 *
213 * The optional keyword parameters _loc_ and _set_ specify where to insert the
214 * new attribute. Refer to the manpage of X509_NAME_add_entry(3) for details.
215 * _loc_ defaults to -1 and _set_ defaults to 0. This appends a single-valued
216 * RDN to the end.
217 */
218static
219 VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
220{
221 X509_NAME *name;
222 VALUE oid, value, type, opts, kwargs[2];
223 static ID kwargs_ids[2];
224 const char *oid_name;
225 int loc = -1, set = 0;
226
227 if (!kwargs_ids[0]) {
228 kwargs_ids[0] = rb_intern_const("loc");
229 kwargs_ids[1] = rb_intern_const("set");
230 }
231 rb_scan_args(argc, argv, "21:", &oid, &value, &type, &opts);
232 rb_get_kwargs(opts, kwargs_ids, 0, 2, kwargs);
233 oid_name = StringValueCStr(oid);
234 StringValue(value);
235 if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
236 if (kwargs[0] != Qundef)
237 loc = NUM2INT(kwargs[0]);
238 if (kwargs[1] != Qundef)
239 set = NUM2INT(kwargs[1]);
240 GetX509Name(self, name);
241 if (!X509_NAME_add_entry_by_txt(name, oid_name, NUM2INT(type),
242 (unsigned char *)RSTRING_PTR(value),
243 RSTRING_LENINT(value), loc, set))
244 ossl_raise(eX509NameError, "X509_NAME_add_entry_by_txt");
245 return self;
246}
247
248static VALUE
249ossl_x509name_to_s_old(VALUE self)
250{
251 X509_NAME *name;
252 char *buf;
253
254 GetX509Name(self, name);
255 buf = X509_NAME_oneline(name, NULL, 0);
256 if (!buf)
257 ossl_raise(eX509NameError, "X509_NAME_oneline");
258 return ossl_buf2str(buf, rb_long2int(strlen(buf)));
259}
260
261static VALUE
262x509name_print(VALUE self, unsigned long iflag)
263{
264 X509_NAME *name;
265 BIO *out;
266 int ret;
267
268 GetX509Name(self, name);
269 out = BIO_new(BIO_s_mem());
270 if (!out)
271 ossl_raise(eX509NameError, NULL);
272 ret = X509_NAME_print_ex(out, name, 0, iflag);
273 if (ret < 0 || (iflag == XN_FLAG_COMPAT && ret == 0)) {
274 BIO_free(out);
275 ossl_raise(eX509NameError, "X509_NAME_print_ex");
276 }
277 return ossl_membio2str(out);
278}
279
280/*
281 * call-seq:
282 * name.to_s -> string
283 * name.to_s(format) -> string
284 *
285 * Returns a String representation of the Distinguished Name. _format_ is
286 * one of:
287 *
288 * * OpenSSL::X509::Name::COMPAT
289 * * OpenSSL::X509::Name::RFC2253
290 * * OpenSSL::X509::Name::ONELINE
291 * * OpenSSL::X509::Name::MULTILINE
292 *
293 * If _format_ is omitted, the largely broken and traditional OpenSSL format
294 * is used.
295 */
296static VALUE
297ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
298{
299 rb_check_arity(argc, 0, 1);
300 /* name.to_s(nil) was allowed */
301 if (!argc || NIL_P(argv[0]))
302 return ossl_x509name_to_s_old(self);
303 else
304 return x509name_print(self, NUM2ULONG(argv[0]));
305}
306
307/*
308 * call-seq:
309 * name.to_utf8 -> string
310 *
311 * Returns an UTF-8 representation of the distinguished name, as specified
312 * in {RFC 2253}[https://www.ietf.org/rfc/rfc2253.txt].
313 */
314static VALUE
315ossl_x509name_to_utf8(VALUE self)
316{
317 VALUE str = x509name_print(self, XN_FLAG_RFC2253 & ~ASN1_STRFLGS_ESC_MSB);
318 rb_enc_associate_index(str, rb_utf8_encindex());
319 return str;
320}
321
322/* :nodoc: */
323static VALUE
324ossl_x509name_inspect(VALUE self)
325{
326 return rb_enc_sprintf(rb_utf8_encoding(), "#<%"PRIsVALUE" %"PRIsVALUE">",
327 rb_obj_class(self), ossl_x509name_to_utf8(self));
328}
329
330/*
331 * call-seq:
332 * name.to_a => [[name, data, type], ...]
333 *
334 * Returns an Array representation of the distinguished name suitable for
335 * passing to ::new
336 */
337static VALUE
338ossl_x509name_to_a(VALUE self)
339{
340 X509_NAME *name;
341 X509_NAME_ENTRY *entry;
342 int i,entries,nid;
343 char long_name[512];
344 const char *short_name;
345 VALUE ary, vname, ret;
346 ASN1_STRING *value;
347
348 GetX509Name(self, name);
349 entries = X509_NAME_entry_count(name);
350 if (entries < 0) {
351 OSSL_Debug("name entries < 0!");
352 return rb_ary_new();
353 }
354 ret = rb_ary_new2(entries);
355 for (i=0; i<entries; i++) {
356 if (!(entry = X509_NAME_get_entry(name, i))) {
357 ossl_raise(eX509NameError, NULL);
358 }
359 if (!i2t_ASN1_OBJECT(long_name, sizeof(long_name),
360 X509_NAME_ENTRY_get_object(entry))) {
361 ossl_raise(eX509NameError, NULL);
362 }
363 nid = OBJ_ln2nid(long_name);
364 if (nid == NID_undef) {
365 vname = rb_str_new2((const char *) &long_name);
366 } else {
367 short_name = OBJ_nid2sn(nid);
368 vname = rb_str_new2(short_name); /*do not free*/
369 }
370 value = X509_NAME_ENTRY_get_data(entry);
371 ary = rb_ary_new3(3, vname, asn1str_to_str(value), INT2NUM(value->type));
372 rb_ary_push(ret, ary);
373 }
374 return ret;
375}
376
377static int
378ossl_x509name_cmp0(VALUE self, VALUE other)
379{
380 X509_NAME *name1, *name2;
381
382 GetX509Name(self, name1);
383 GetX509Name(other, name2);
384
385 return X509_NAME_cmp(name1, name2);
386}
387
388/*
389 * call-seq:
390 * name.cmp(other) -> -1 | 0 | 1 | nil
391 * name <=> other -> -1 | 0 | 1 | nil
392 *
393 * Compares this Name with _other_ and returns +0+ if they are the same and +-1+
394 * or ++1+ if they are greater or less than each other respectively.
395 * Returns +nil+ if they are not comparable (i.e. different types).
396 */
397static VALUE
398ossl_x509name_cmp(VALUE self, VALUE other)
399{
400 int result;
401
402 if (!rb_obj_is_kind_of(other, cX509Name))
403 return Qnil;
404
405 result = ossl_x509name_cmp0(self, other);
406 if (result < 0) return INT2FIX(-1);
407 if (result > 0) return INT2FIX(1);
408
409 return INT2FIX(0);
410}
411
412/*
413 * call-seq:
414 * name.eql?(other) -> true | false
415 *
416 * Returns true if _name_ and _other_ refer to the same hash key.
417 */
418static VALUE
419ossl_x509name_eql(VALUE self, VALUE other)
420{
421 if (!rb_obj_is_kind_of(other, cX509Name))
422 return Qfalse;
423
424 return ossl_x509name_cmp0(self, other) == 0 ? Qtrue : Qfalse;
425}
426
427/*
428 * call-seq:
429 * name.hash => integer
430 *
431 * The hash value returned is suitable for use as a certificate's filename in
432 * a CA path.
433 */
434static VALUE
435ossl_x509name_hash(VALUE self)
436{
437 X509_NAME *name;
438 unsigned long hash;
439
440 GetX509Name(self, name);
441
442 hash = X509_NAME_hash(name);
443
444 return ULONG2NUM(hash);
445}
446
447/*
448 * call-seq:
449 * name.hash_old => integer
450 *
451 * Returns an MD5 based hash used in OpenSSL 0.9.X.
452 */
453static VALUE
454ossl_x509name_hash_old(VALUE self)
455{
456 X509_NAME *name;
457 unsigned long hash;
458
459 GetX509Name(self, name);
460
461 hash = X509_NAME_hash_old(name);
462
463 return ULONG2NUM(hash);
464}
465
466/*
467 * call-seq:
468 * name.to_der => string
469 *
470 * Converts the name to DER encoding
471 */
472static VALUE
473ossl_x509name_to_der(VALUE self)
474{
475 X509_NAME *name;
476 VALUE str;
477 long len;
478 unsigned char *p;
479
480 GetX509Name(self, name);
481 if((len = i2d_X509_NAME(name, NULL)) <= 0)
482 ossl_raise(eX509NameError, NULL);
483 str = rb_str_new(0, len);
484 p = (unsigned char *)RSTRING_PTR(str);
485 if(i2d_X509_NAME(name, &p) <= 0)
486 ossl_raise(eX509NameError, NULL);
487 ossl_str_adjust(str, p);
488
489 return str;
490}
491
492/*
493 * Document-class: OpenSSL::X509::Name
494 *
495 * An X.509 name represents a hostname, email address or other entity
496 * associated with a public key.
497 *
498 * You can create a Name by parsing a distinguished name String or by
499 * supplying the distinguished name as an Array.
500 *
501 * name = OpenSSL::X509::Name.parse '/CN=nobody/DC=example'
502 *
503 * name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]
504 */
505
506void
507 Init_ossl_x509name(void)
508{
509#undef rb_intern
510 VALUE utf8str, ptrstr, ia5str, hash;
511
512#if 0
513 mOSSL = rb_define_module("OpenSSL");
514 eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
515 mX509 = rb_define_module_under(mOSSL, "X509");
516#endif
517
518 id_aref = rb_intern("[]");
519 eX509NameError = rb_define_class_under(mX509, "NameError", eOSSLError);
520 cX509Name = rb_define_class_under(mX509, "Name", rb_cObject);
521
522 rb_include_module(cX509Name, rb_mComparable);
523
524 rb_define_alloc_func(cX509Name, ossl_x509name_alloc);
525 rb_define_method(cX509Name, "initialize", ossl_x509name_initialize, -1);
526 rb_define_method(cX509Name, "initialize_copy", ossl_x509name_initialize_copy, 1);
527 rb_define_method(cX509Name, "add_entry", ossl_x509name_add_entry, -1);
528 rb_define_method(cX509Name, "to_s", ossl_x509name_to_s, -1);
529 rb_define_method(cX509Name, "to_utf8", ossl_x509name_to_utf8, 0);
530 rb_define_method(cX509Name, "inspect", ossl_x509name_inspect, 0);
531 rb_define_method(cX509Name, "to_a", ossl_x509name_to_a, 0);
532 rb_define_method(cX509Name, "cmp", ossl_x509name_cmp, 1);
533 rb_define_alias(cX509Name, "<=>", "cmp");
534 rb_define_method(cX509Name, "eql?", ossl_x509name_eql, 1);
535 rb_define_method(cX509Name, "hash", ossl_x509name_hash, 0);
536 rb_define_method(cX509Name, "hash_old", ossl_x509name_hash_old, 0);
537 rb_define_method(cX509Name, "to_der", ossl_x509name_to_der, 0);
538
539 utf8str = INT2NUM(V_ASN1_UTF8STRING);
540 ptrstr = INT2NUM(V_ASN1_PRINTABLESTRING);
541 ia5str = INT2NUM(V_ASN1_IA5STRING);
542
543 /*
544 * The default object type for name entries.
545 */
546 rb_define_const(cX509Name, "DEFAULT_OBJECT_TYPE", utf8str);
547 hash = rb_hash_new();
548 RHASH_SET_IFNONE(hash, utf8str);
549 rb_hash_aset(hash, rb_str_new2("C"), ptrstr);
550 rb_hash_aset(hash, rb_str_new2("countryName"), ptrstr);
551 rb_hash_aset(hash, rb_str_new2("serialNumber"), ptrstr);
552 rb_hash_aset(hash, rb_str_new2("dnQualifier"), ptrstr);
553 rb_hash_aset(hash, rb_str_new2("DC"), ia5str);
554 rb_hash_aset(hash, rb_str_new2("domainComponent"), ia5str);
555 rb_hash_aset(hash, rb_str_new2("emailAddress"), ia5str);
556
557 /*
558 * The default object type template for name entries.
559 */
560 rb_define_const(cX509Name, "OBJECT_TYPE_TEMPLATE", hash);
561
562 /*
563 * A flag for #to_s.
564 *
565 * Breaks the name returned into multiple lines if longer than 80
566 * characters.
567 */
568 rb_define_const(cX509Name, "COMPAT", ULONG2NUM(XN_FLAG_COMPAT));
569
570 /*
571 * A flag for #to_s.
572 *
573 * Returns an RFC2253 format name.
574 */
575 rb_define_const(cX509Name, "RFC2253", ULONG2NUM(XN_FLAG_RFC2253));
576
577 /*
578 * A flag for #to_s.
579 *
580 * Returns a more readable format than RFC2253.
581 */
582 rb_define_const(cX509Name, "ONELINE", ULONG2NUM(XN_FLAG_ONELINE));
583
584 /*
585 * A flag for #to_s.
586 *
587 * Returns a multiline format.
588 */
589 rb_define_const(cX509Name, "MULTILINE", ULONG2NUM(XN_FLAG_MULTILINE));
590}
rb_ary_push
VALUE rb_ary_push(VALUE ary, VALUE item)
Definition: array.c:1301
rb_ary_new
VALUE rb_ary_new(void)
Definition: array.c:749
rb_check_array_type
VALUE rb_check_array_type(VALUE ary)
Definition: array.c:988
rb_ary_entry
VALUE rb_ary_entry(VALUE ary, long offset)
Definition: array.c:1672
rb_mComparable
VALUE rb_mComparable
Definition: compar.c:19
rb_define_method
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
Definition: cxxanyargs.hpp:653
ptr
struct RIMemo * ptr
Definition: debug.c:88
rb_utf8_encindex
#define rb_utf8_encindex()
Definition: encindex.h:58
rb_utf8_encoding
rb_encoding * rb_utf8_encoding(void)
Definition: encoding.c:1537
rb_enc_associate_index
VALUE rb_enc_associate_index(VALUE obj, int idx)
Definition: encoding.c:1036
out
string_t out
Definition: enough.c:230
len
uint8_t len
Definition: escape.c:17
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
RSTRING_LEN
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
RSTRING_PTR
#define RSTRING_PTR(string)
Definition: fbuffer.h:19
PRIsVALUE
#define PRIsVALUE
Definition: function.c:10
rb_include_module
void rb_include_module(VALUE klass, VALUE module)
Definition: class.c:962
rb_define_class_under
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:797
rb_define_module
VALUE rb_define_module(const char *name)
Definition: class.c:871
rb_define_module_under
VALUE rb_define_module_under(VALUE outer, const char *name)
Definition: class.c:895
rb_define_alias
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
Definition: class.c:1999
rb_scan_args
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Definition: class.c:2296
rb_get_kwargs
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
Definition: class.c:2085
rb_eStandardError
VALUE rb_eStandardError
Definition: error.c:1054
rb_cObject
VALUE rb_cObject
Object class.
Definition: object.c:49
rb_obj_class
VALUE rb_obj_class(VALUE)
Definition: object.c:245
rb_obj_is_kind_of
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Determines if obj is a kind of c.
Definition: object.c:724
rb_hash_aset
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
Definition: hash.c:2901
rb_hash_new
VALUE rb_hash_new(void)
Definition: hash.c:1538
rb_enc_sprintf
VALUE rb_enc_sprintf(rb_encoding *, const char *,...)
Definition: sprintf.c:1184
rb_ary_new3
#define rb_ary_new3
Definition: array.h:73
rb_ary_new2
#define rb_ary_new2
Definition: array.h:72
rb_check_frozen
#define rb_check_frozen
Definition: error.h:72
rb_check_arity
#define rb_check_arity
Definition: error.h:34
rb_str_new2
#define rb_str_new2
Definition: string.h:276
rb_str_new
#define rb_str_new(str, len)
Definition: string.h:213
rb_define_alloc_func
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
rb_intern
ID rb_intern(const char *)
Definition: symbol.c:785
rb_define_const
void rb_define_const(VALUE, const char *, VALUE)
Definition: variable.c:3150
NUM2INT
#define NUM2INT
Definition: int.h:44
INT2NUM
#define INT2NUM
Definition: int.h:43
buf
voidpf void * buf
Definition: ioapi.h:138
RB_BLOCK_CALL_FUNC_ARGLIST
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Definition: iterator.h:31
NUM2ULONG
#define NUM2ULONG
Definition: long.h:52
INT2FIX
#define INT2FIX
Definition: long.h:48
ULONG2NUM
#define ULONG2NUM
Definition: long.h:60
rb_long2int
#define rb_long2int
Definition: long.h:62
ruby::backward::cxxanyargs::rb_block_call
VALUE rb_block_call(VALUE q, ID w, int e, const VALUE *r, type *t, VALUE y)
Call a method with a block.
Definition: cxxanyargs.hpp:230
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:56
name
const char * name
Definition: nkf.c:208
nid
int nid
Definition: openssl_missing.c:28
mOSSL
VALUE mOSSL
Definition: ossl.c:231
ossl_buf2str
VALUE ossl_buf2str(char *buf, int len)
Definition: ossl.c:120
ossl_to_der_if_possible
VALUE ossl_to_der_if_possible(VALUE obj)
Definition: ossl.c:255
ossl_raise
void ossl_raise(VALUE exc, const char *fmt,...)
Definition: ossl.c:293
eOSSLError
VALUE eOSSLError
Definition: ossl.c:236
ossl.h
OSSL_Debug
#define OSSL_Debug(...)
Definition: ossl.h:140
ossl_str_adjust
#define ossl_str_adjust(str, p)
Definition: ossl.h:89
asn1str_to_str
VALUE asn1str_to_str(const ASN1_STRING *str)
Definition: ossl_asn1.c:92
ossl_membio2str
VALUE ossl_membio2str(BIO *bio)
Definition: ossl_bio.c:29
mX509
VALUE mX509
Definition: ossl_x509.c:12
eX509NameError
VALUE eX509NameError
Definition: ossl_x509name.c:36
cX509Name
VALUE cX509Name
Definition: ossl_x509name.c:35
GetX509NamePtr
X509_NAME * GetX509NamePtr(VALUE obj)
Definition: ossl_x509name.c:76
OBJECT_TYPE_TEMPLATE
#define OBJECT_TYPE_TEMPLATE
Definition: ossl_x509name.c:27
SetX509Name
#define SetX509Name(obj, name)
Definition: ossl_x509name.c:14
Init_ossl_x509name
void Init_ossl_x509name(void)
Definition: ossl_x509name.c:507
ossl_x509name_new
VALUE ossl_x509name_new(X509_NAME *name)
Definition: ossl_x509name.c:56
GetX509Name
#define GetX509Name(obj, name)
Definition: ossl_x509name.c:20
NewX509Name
#define NewX509Name(klass)
Definition: ossl_x509name.c:12
DEFAULT_OBJECT_TYPE
#define DEFAULT_OBJECT_TYPE
Definition: ossl_x509name.c:29
rb_aref
#define rb_aref(obj, key)
Definition: ossl_x509name.c:105
DATA_PTR
#define DATA_PTR(obj)
Definition: rdata.h:56
NULL
#define NULL
Definition: regenc.h:69
RHASH_SET_IFNONE
#define RHASH_SET_IFNONE(h, ifnone)
Definition: rhash.h:52
StringValue
#define StringValue(v)
Definition: rstring.h:50
StringValueCStr
#define StringValueCStr(v)
Definition: rstring.h:52
RUBY_TYPED_FREE_IMMEDIATELY
@ RUBY_TYPED_FREE_IMMEDIATELY
Definition: rtypeddata.h:62
argc
int argc
Definition: ruby.c:240
argv
char ** argv
Definition: ruby.c:241
Qundef
#define Qundef
Definition: special_consts.h:53
Qtrue
#define Qtrue
Definition: special_consts.h:52
Qnil
#define Qnil
Definition: special_consts.h:51
Qfalse
#define Qfalse
Definition: special_consts.h:50
NIL_P
#define NIL_P
Definition: special_consts.h:46
strlen
size_t strlen(const char *)
rb_data_type_struct
Definition: rtypeddata.h:70
VALUE
unsigned long VALUE
Definition: value.h:38
ID
unsigned long ID
Definition: value.h:39
T_ARRAY
#define T_ARRAY
Definition: value_type.h:55