openssl 2.0.9 → 2.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openssl might be problematic. Click here for more details.
- checksums.yaml +5 -5
 - data/History.md +28 -69
 - data/README.md +1 -1
 - data/ext/openssl/deprecation.rb +0 -3
 - data/ext/openssl/extconf.rb +8 -52
 - data/ext/openssl/openssl_missing.c +0 -67
 - data/ext/openssl/openssl_missing.h +3 -50
 - data/ext/openssl/ossl.c +81 -74
 - data/ext/openssl/ossl.h +14 -27
 - data/ext/openssl/ossl_asn1.c +287 -374
 - data/ext/openssl/ossl_asn1.h +0 -4
 - data/ext/openssl/ossl_bio.c +5 -20
 - data/ext/openssl/ossl_bio.h +0 -2
 - data/ext/openssl/ossl_bn.c +70 -28
 - data/ext/openssl/ossl_cipher.c +18 -42
 - data/ext/openssl/ossl_cipher.h +1 -1
 - data/ext/openssl/ossl_digest.c +8 -12
 - data/ext/openssl/ossl_digest.h +1 -1
 - data/ext/openssl/ossl_engine.c +47 -47
 - data/ext/openssl/ossl_hmac.c +19 -22
 - data/ext/openssl/ossl_kdf.c +221 -0
 - data/ext/openssl/ossl_kdf.h +6 -0
 - data/ext/openssl/ossl_ns_spki.c +17 -21
 - data/ext/openssl/ossl_ocsp.c +85 -80
 - data/ext/openssl/ossl_pkcs12.c +15 -21
 - data/ext/openssl/ossl_pkcs7.c +8 -21
 - data/ext/openssl/ossl_pkey.c +24 -48
 - data/ext/openssl/ossl_pkey.h +1 -6
 - data/ext/openssl/ossl_pkey_dh.c +11 -11
 - data/ext/openssl/ossl_pkey_dsa.c +16 -22
 - data/ext/openssl/ossl_pkey_ec.c +43 -56
 - data/ext/openssl/ossl_pkey_rsa.c +19 -19
 - data/ext/openssl/ossl_rand.c +12 -12
 - data/ext/openssl/ossl_ssl.c +291 -243
 - data/ext/openssl/ossl_ssl.h +0 -5
 - data/ext/openssl/ossl_ssl_session.c +7 -9
 - data/ext/openssl/ossl_version.h +1 -1
 - data/ext/openssl/ossl_x509.c +0 -15
 - data/ext/openssl/ossl_x509.h +0 -7
 - data/ext/openssl/ossl_x509attr.c +3 -7
 - data/ext/openssl/ossl_x509cert.c +17 -54
 - data/ext/openssl/ossl_x509crl.c +15 -25
 - data/ext/openssl/ossl_x509ext.c +9 -14
 - data/ext/openssl/ossl_x509name.c +76 -41
 - data/ext/openssl/ossl_x509req.c +10 -47
 - data/ext/openssl/ossl_x509revoked.c +8 -8
 - data/ext/openssl/ossl_x509store.c +15 -45
 - data/ext/openssl/ruby_missing.h +2 -13
 - data/lib/openssl.rb +1 -0
 - data/lib/openssl/bn.rb +2 -1
 - data/lib/openssl/buffering.rb +24 -23
 - data/lib/openssl/config.rb +12 -11
 - data/lib/openssl/digest.rb +3 -6
 - data/lib/openssl/pkcs5.rb +22 -0
 - data/lib/openssl/pkey.rb +0 -41
 - data/lib/openssl/ssl.rb +118 -16
 - data/lib/openssl/x509.rb +7 -1
 - metadata +8 -7
 - data/ext/openssl/ossl_pkcs5.c +0 -180
 - data/ext/openssl/ossl_pkcs5.h +0 -6
 
    
        data/ext/openssl/ossl_x509ext.c
    CHANGED
    
    | 
         @@ -23,10 +23,6 @@ 
     | 
|
| 
       23 
23 
     | 
    
         
             
            	ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
         
     | 
| 
       24 
24 
     | 
    
         
             
                } \
         
     | 
| 
       25 
25 
     | 
    
         
             
            } while (0)
         
     | 
| 
       26 
     | 
    
         
            -
            #define SafeGetX509Ext(obj, ext) do { \
         
     | 
| 
       27 
     | 
    
         
            -
                OSSL_Check_Kind((obj), cX509Ext); \
         
     | 
| 
       28 
     | 
    
         
            -
                GetX509Ext((obj), (ext)); \
         
     | 
| 
       29 
     | 
    
         
            -
            } while (0)
         
     | 
| 
       30 
26 
     | 
    
         
             
            #define MakeX509ExtFactory(klass, obj, ctx) do { \
         
     | 
| 
       31 
27 
     | 
    
         
             
                (obj) = TypedData_Wrap_Struct((klass), &ossl_x509extfactory_type, 0); \
         
     | 
| 
       32 
28 
     | 
    
         
             
                if (!((ctx) = OPENSSL_malloc(sizeof(X509V3_CTX)))) \
         
     | 
| 
         @@ -90,7 +86,7 @@ GetX509ExtPtr(VALUE obj) 
     | 
|
| 
       90 
86 
     | 
    
         
             
            {
         
     | 
| 
       91 
87 
     | 
    
         
             
                X509_EXTENSION *ext;
         
     | 
| 
       92 
88 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
                 
     | 
| 
      
 89 
     | 
    
         
            +
                GetX509Ext(obj, ext);
         
     | 
| 
       94 
90 
     | 
    
         | 
| 
       95 
91 
     | 
    
         
             
                return ext;
         
     | 
| 
       96 
92 
     | 
    
         
             
            }
         
     | 
| 
         @@ -263,15 +259,15 @@ ossl_x509ext_alloc(VALUE klass) 
     | 
|
| 
       263 
259 
     | 
    
         | 
| 
       264 
260 
     | 
    
         
             
            /*
         
     | 
| 
       265 
261 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       266 
     | 
    
         
            -
             *    OpenSSL::X509::Extension.new 
     | 
| 
       267 
     | 
    
         
            -
             *    OpenSSL::X509::Extension.new 
     | 
| 
       268 
     | 
    
         
            -
             *    OpenSSL::X509::Extension.new 
     | 
| 
      
 262 
     | 
    
         
            +
             *    OpenSSL::X509::Extension.new(der)
         
     | 
| 
      
 263 
     | 
    
         
            +
             *    OpenSSL::X509::Extension.new(oid, value)
         
     | 
| 
      
 264 
     | 
    
         
            +
             *    OpenSSL::X509::Extension.new(oid, value, critical)
         
     | 
| 
       269 
265 
     | 
    
         
             
             *
         
     | 
| 
       270 
266 
     | 
    
         
             
             * Creates an X509 extension.
         
     | 
| 
       271 
267 
     | 
    
         
             
             *
         
     | 
| 
       272 
     | 
    
         
            -
             * The extension may be created from  
     | 
| 
       273 
     | 
    
         
            -
             * and  
     | 
| 
       274 
     | 
    
         
            -
             *  
     | 
| 
      
 268 
     | 
    
         
            +
             * The extension may be created from _der_ data or from an extension _oid_
         
     | 
| 
      
 269 
     | 
    
         
            +
             * and _value_.  The _oid_ may be either an OID or an extension name.  If
         
     | 
| 
      
 270 
     | 
    
         
            +
             * _critical_ is +true+ the extension is marked critical.
         
     | 
| 
       275 
271 
     | 
    
         
             
             */
         
     | 
| 
       276 
272 
     | 
    
         
             
            static VALUE
         
     | 
| 
       277 
273 
     | 
    
         
             
            ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
         
     | 
| 
         @@ -305,7 +301,7 @@ ossl_x509ext_initialize_copy(VALUE self, VALUE other) 
     | 
|
| 
       305 
301 
     | 
    
         | 
| 
       306 
302 
     | 
    
         
             
                rb_check_frozen(self);
         
     | 
| 
       307 
303 
     | 
    
         
             
                GetX509Ext(self, ext);
         
     | 
| 
       308 
     | 
    
         
            -
                 
     | 
| 
      
 304 
     | 
    
         
            +
                GetX509Ext(other, ext_other);
         
     | 
| 
       309 
305 
     | 
    
         | 
| 
       310 
306 
     | 
    
         
             
                ext_new = X509_EXTENSION_dup(ext_other);
         
     | 
| 
       311 
307 
     | 
    
         
             
                if (!ext_new)
         
     | 
| 
         @@ -441,7 +437,6 @@ ossl_x509ext_to_der(VALUE obj) 
     | 
|
| 
       441 
437 
     | 
    
         
             
            void
         
     | 
| 
       442 
438 
     | 
    
         
             
            Init_ossl_x509ext(void)
         
     | 
| 
       443 
439 
     | 
    
         
             
            {
         
     | 
| 
       444 
     | 
    
         
            -
            #undef rb_intern
         
     | 
| 
       445 
440 
     | 
    
         
             
            #if 0
         
     | 
| 
       446 
441 
     | 
    
         
             
                mOSSL = rb_define_module("OpenSSL");
         
     | 
| 
       447 
442 
     | 
    
         
             
                eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
         
     | 
| 
         @@ -470,7 +465,7 @@ Init_ossl_x509ext(void) 
     | 
|
| 
       470 
465 
     | 
    
         
             
                cX509Ext = rb_define_class_under(mX509, "Extension", rb_cObject);
         
     | 
| 
       471 
466 
     | 
    
         
             
                rb_define_alloc_func(cX509Ext, ossl_x509ext_alloc);
         
     | 
| 
       472 
467 
     | 
    
         
             
                rb_define_method(cX509Ext, "initialize", ossl_x509ext_initialize, -1);
         
     | 
| 
       473 
     | 
    
         
            -
                 
     | 
| 
      
 468 
     | 
    
         
            +
                rb_define_method(cX509Ext, "initialize_copy", ossl_x509ext_initialize_copy, 1);
         
     | 
| 
       474 
469 
     | 
    
         
             
                rb_define_method(cX509Ext, "oid=", ossl_x509ext_set_oid, 1);
         
     | 
| 
       475 
470 
     | 
    
         
             
                rb_define_method(cX509Ext, "value=", ossl_x509ext_set_value, 1);
         
     | 
| 
       476 
471 
     | 
    
         
             
                rb_define_method(cX509Ext, "critical=", ossl_x509ext_set_critical, 1);
         
     | 
    
        data/ext/openssl/ossl_x509name.c
    CHANGED
    
    | 
         @@ -23,10 +23,6 @@ 
     | 
|
| 
       23 
23 
     | 
    
         
             
            	ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
         
     | 
| 
       24 
24 
     | 
    
         
             
                } \
         
     | 
| 
       25 
25 
     | 
    
         
             
            } while (0)
         
     | 
| 
       26 
     | 
    
         
            -
            #define SafeGetX509Name(obj, name) do { \
         
     | 
| 
       27 
     | 
    
         
            -
                OSSL_Check_Kind((obj), cX509Name); \
         
     | 
| 
       28 
     | 
    
         
            -
                GetX509Name((obj), (name)); \
         
     | 
| 
       29 
     | 
    
         
            -
            } while (0)
         
     | 
| 
       30 
26 
     | 
    
         | 
| 
       31 
27 
     | 
    
         
             
            #define OBJECT_TYPE_TEMPLATE \
         
     | 
| 
       32 
28 
     | 
    
         
             
              rb_const_get(cX509Name, rb_intern("OBJECT_TYPE_TEMPLATE"))
         
     | 
| 
         @@ -81,7 +77,7 @@ GetX509NamePtr(VALUE obj) 
     | 
|
| 
       81 
77 
     | 
    
         
             
            {
         
     | 
| 
       82 
78 
     | 
    
         
             
                X509_NAME *name;
         
     | 
| 
       83 
79 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
                 
     | 
| 
      
 80 
     | 
    
         
            +
                GetX509Name(obj, name);
         
     | 
| 
       85 
81 
     | 
    
         | 
| 
       86 
82 
     | 
    
         
             
                return name;
         
     | 
| 
       87 
83 
     | 
    
         
             
            }
         
     | 
| 
         @@ -135,15 +131,15 @@ ossl_x509name_init_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args)) 
     | 
|
| 
       135 
131 
     | 
    
         
             
             *
         
     | 
| 
       136 
132 
     | 
    
         
             
             * Creates a new Name.
         
     | 
| 
       137 
133 
     | 
    
         
             
             *
         
     | 
| 
       138 
     | 
    
         
            -
             * A name may be created from a DER encoded string  
     | 
| 
       139 
     | 
    
         
            -
             * representing a  
     | 
| 
       140 
     | 
    
         
            -
             *  
     | 
| 
      
 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_.
         
     | 
| 
       141 
137 
     | 
    
         
             
             *
         
     | 
| 
       142 
138 
     | 
    
         
             
             *   name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]
         
     | 
| 
       143 
139 
     | 
    
         
             
             *
         
     | 
| 
       144 
140 
     | 
    
         
             
             *   name = OpenSSL::X509::Name.new name.to_der
         
     | 
| 
       145 
141 
     | 
    
         
             
             *
         
     | 
| 
       146 
     | 
    
         
            -
             * See add_entry for a description of the  
     | 
| 
      
 142 
     | 
    
         
            +
             * See add_entry for a description of the _distinguished_name_ Array's
         
     | 
| 
       147 
143 
     | 
    
         
             
             * contents
         
     | 
| 
       148 
144 
     | 
    
         
             
             */
         
     | 
| 
       149 
145 
     | 
    
         
             
            static VALUE
         
     | 
| 
         @@ -188,7 +184,7 @@ ossl_x509name_initialize_copy(VALUE self, VALUE other) 
     | 
|
| 
       188 
184 
     | 
    
         | 
| 
       189 
185 
     | 
    
         
             
                rb_check_frozen(self);
         
     | 
| 
       190 
186 
     | 
    
         
             
                GetX509Name(self, name);
         
     | 
| 
       191 
     | 
    
         
            -
                 
     | 
| 
      
 187 
     | 
    
         
            +
                GetX509Name(other, name_other);
         
     | 
| 
       192 
188 
     | 
    
         | 
| 
       193 
189 
     | 
    
         
             
                name_new = X509_NAME_dup(name_other);
         
     | 
| 
       194 
190 
     | 
    
         
             
                if (!name_new)
         
     | 
| 
         @@ -202,9 +198,9 @@ ossl_x509name_initialize_copy(VALUE self, VALUE other) 
     | 
|
| 
       202 
198 
     | 
    
         | 
| 
       203 
199 
     | 
    
         
             
            /*
         
     | 
| 
       204 
200 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       205 
     | 
    
         
            -
             *    name.add_entry(oid, value [, type]) => self
         
     | 
| 
      
 201 
     | 
    
         
            +
             *    name.add_entry(oid, value [, type], loc: -1, set: 0) => self
         
     | 
| 
       206 
202 
     | 
    
         
             
             *
         
     | 
| 
       207 
     | 
    
         
            -
             * Adds a new entry with the given  
     | 
| 
      
 203 
     | 
    
         
            +
             * Adds a new entry with the given _oid_ and _value_ to this name.  The _oid_
         
     | 
| 
       208 
204 
     | 
    
         
             
             * is an object identifier defined in ASN.1.  Some common OIDs are:
         
     | 
| 
       209 
205 
     | 
    
         
             
             *
         
     | 
| 
       210 
206 
     | 
    
         
             
             * C::  Country Name
         
     | 
| 
         @@ -213,24 +209,39 @@ ossl_x509name_initialize_copy(VALUE self, VALUE other) 
     | 
|
| 
       213 
209 
     | 
    
         
             
             * O::  Organization Name
         
     | 
| 
       214 
210 
     | 
    
         
             
             * OU:: Organizational Unit Name
         
     | 
| 
       215 
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.
         
     | 
| 
       216 
217 
     | 
    
         
             
             */
         
     | 
| 
       217 
218 
     | 
    
         
             
            static
         
     | 
| 
       218 
219 
     | 
    
         
             
            VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
         
     | 
| 
       219 
220 
     | 
    
         
             
            {
         
     | 
| 
       220 
221 
     | 
    
         
             
                X509_NAME *name;
         
     | 
| 
       221 
     | 
    
         
            -
                VALUE oid, value, type;
         
     | 
| 
      
 222 
     | 
    
         
            +
                VALUE oid, value, type, opts, kwargs[2];
         
     | 
| 
      
 223 
     | 
    
         
            +
                static ID kwargs_ids[2];
         
     | 
| 
       222 
224 
     | 
    
         
             
                const char *oid_name;
         
     | 
| 
      
 225 
     | 
    
         
            +
                int loc = -1, set = 0;
         
     | 
| 
       223 
226 
     | 
    
         | 
| 
       224 
     | 
    
         
            -
                 
     | 
| 
      
 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);
         
     | 
| 
       225 
233 
     | 
    
         
             
                oid_name = StringValueCStr(oid);
         
     | 
| 
       226 
234 
     | 
    
         
             
                StringValue(value);
         
     | 
| 
       227 
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]);
         
     | 
| 
       228 
240 
     | 
    
         
             
                GetX509Name(self, name);
         
     | 
| 
       229 
241 
     | 
    
         
             
                if (!X509_NAME_add_entry_by_txt(name, oid_name, NUM2INT(type),
         
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
       231 
     | 
    
         
            -
             
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
      
 242 
     | 
    
         
            +
            				    (unsigned char *)RSTRING_PTR(value),
         
     | 
| 
      
 243 
     | 
    
         
            +
            				    RSTRING_LENINT(value), loc, set))
         
     | 
| 
      
 244 
     | 
    
         
            +
            	ossl_raise(eX509NameError, "X509_NAME_add_entry_by_txt");
         
     | 
| 
       234 
245 
     | 
    
         
             
                return self;
         
     | 
| 
       235 
246 
     | 
    
         
             
            }
         
     | 
| 
       236 
247 
     | 
    
         | 
| 
         @@ -239,12 +250,14 @@ ossl_x509name_to_s_old(VALUE self) 
     | 
|
| 
       239 
250 
     | 
    
         
             
            {
         
     | 
| 
       240 
251 
     | 
    
         
             
                X509_NAME *name;
         
     | 
| 
       241 
252 
     | 
    
         
             
                char *buf;
         
     | 
| 
      
 253 
     | 
    
         
            +
                VALUE str;
         
     | 
| 
       242 
254 
     | 
    
         | 
| 
       243 
255 
     | 
    
         
             
                GetX509Name(self, name);
         
     | 
| 
       244 
256 
     | 
    
         
             
                buf = X509_NAME_oneline(name, NULL, 0);
         
     | 
| 
       245 
     | 
    
         
            -
                 
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
      
 257 
     | 
    
         
            +
                str = rb_str_new2(buf);
         
     | 
| 
      
 258 
     | 
    
         
            +
                OPENSSL_free(buf);
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
                return str;
         
     | 
| 
       248 
261 
     | 
    
         
             
            }
         
     | 
| 
       249 
262 
     | 
    
         | 
| 
       250 
263 
     | 
    
         
             
            static VALUE
         
     | 
| 
         @@ -252,14 +265,12 @@ x509name_print(VALUE self, unsigned long iflag) 
     | 
|
| 
       252 
265 
     | 
    
         
             
            {
         
     | 
| 
       253 
266 
     | 
    
         
             
                X509_NAME *name;
         
     | 
| 
       254 
267 
     | 
    
         
             
                BIO *out;
         
     | 
| 
       255 
     | 
    
         
            -
                int ret;
         
     | 
| 
       256 
268 
     | 
    
         | 
| 
       257 
269 
     | 
    
         
             
                GetX509Name(self, name);
         
     | 
| 
       258 
270 
     | 
    
         
             
                out = BIO_new(BIO_s_mem());
         
     | 
| 
       259 
271 
     | 
    
         
             
                if (!out)
         
     | 
| 
       260 
272 
     | 
    
         
             
            	ossl_raise(eX509NameError, NULL);
         
     | 
| 
       261 
     | 
    
         
            -
                 
     | 
| 
       262 
     | 
    
         
            -
                if (ret < 0 || iflag == XN_FLAG_COMPAT && ret == 0) {
         
     | 
| 
      
 273 
     | 
    
         
            +
                if (!X509_NAME_print_ex(out, name, 0, iflag)) {
         
     | 
| 
       263 
274 
     | 
    
         
             
            	BIO_free(out);
         
     | 
| 
       264 
275 
     | 
    
         
             
            	ossl_raise(eX509NameError, "X509_NAME_print_ex");
         
     | 
| 
       265 
276 
     | 
    
         
             
                }
         
     | 
| 
         @@ -268,15 +279,19 @@ x509name_print(VALUE self, unsigned long iflag) 
     | 
|
| 
       268 
279 
     | 
    
         | 
| 
       269 
280 
     | 
    
         
             
            /*
         
     | 
| 
       270 
281 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       271 
     | 
    
         
            -
             *    name.to_s  
     | 
| 
       272 
     | 
    
         
            -
             *    name.to_s( 
     | 
| 
      
 282 
     | 
    
         
            +
             *    name.to_s         -> string
         
     | 
| 
      
 283 
     | 
    
         
            +
             *    name.to_s(format) -> string
         
     | 
| 
       273 
284 
     | 
    
         
             
             *
         
     | 
| 
       274 
     | 
    
         
            -
             * Returns  
     | 
| 
      
 285 
     | 
    
         
            +
             * Returns a String representation of the Distinguished Name. _format_ is
         
     | 
| 
      
 286 
     | 
    
         
            +
             * one of:
         
     | 
| 
       275 
287 
     | 
    
         
             
             *
         
     | 
| 
       276 
288 
     | 
    
         
             
             * * OpenSSL::X509::Name::COMPAT
         
     | 
| 
       277 
289 
     | 
    
         
             
             * * OpenSSL::X509::Name::RFC2253
         
     | 
| 
       278 
290 
     | 
    
         
             
             * * OpenSSL::X509::Name::ONELINE
         
     | 
| 
       279 
291 
     | 
    
         
             
             * * OpenSSL::X509::Name::MULTILINE
         
     | 
| 
      
 292 
     | 
    
         
            +
             *
         
     | 
| 
      
 293 
     | 
    
         
            +
             * If _format_ is omitted, the largely broken and traditional OpenSSL format
         
     | 
| 
      
 294 
     | 
    
         
            +
             * is used.
         
     | 
| 
       280 
295 
     | 
    
         
             
             */
         
     | 
| 
       281 
296 
     | 
    
         
             
            static VALUE
         
     | 
| 
       282 
297 
     | 
    
         
             
            ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
         
     | 
| 
         @@ -289,6 +304,29 @@ ossl_x509name_to_s(int argc, VALUE *argv, VALUE self) 
     | 
|
| 
       289 
304 
     | 
    
         
             
            	return x509name_print(self, NUM2ULONG(argv[0]));
         
     | 
| 
       290 
305 
     | 
    
         
             
            }
         
     | 
| 
       291 
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 
     | 
    
         
            +
             */
         
     | 
| 
      
 314 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 315 
     | 
    
         
            +
            ossl_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: */
         
     | 
| 
      
 323 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 324 
     | 
    
         
            +
            ossl_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 
     | 
    
         
            +
             
     | 
| 
       292 
330 
     | 
    
         
             
            /*
         
     | 
| 
       293 
331 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       294 
332 
     | 
    
         
             
             *    name.to_a => [[name, data, type], ...]
         
     | 
| 
         @@ -342,18 +380,18 @@ ossl_x509name_cmp0(VALUE self, VALUE other) 
     | 
|
| 
       342 
380 
     | 
    
         
             
                X509_NAME *name1, *name2;
         
     | 
| 
       343 
381 
     | 
    
         | 
| 
       344 
382 
     | 
    
         
             
                GetX509Name(self, name1);
         
     | 
| 
       345 
     | 
    
         
            -
                 
     | 
| 
      
 383 
     | 
    
         
            +
                GetX509Name(other, name2);
         
     | 
| 
       346 
384 
     | 
    
         | 
| 
       347 
385 
     | 
    
         
             
                return X509_NAME_cmp(name1, name2);
         
     | 
| 
       348 
386 
     | 
    
         
             
            }
         
     | 
| 
       349 
387 
     | 
    
         | 
| 
       350 
388 
     | 
    
         
             
            /*
         
     | 
| 
       351 
389 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       352 
     | 
    
         
            -
             *    name.cmp 
     | 
| 
       353 
     | 
    
         
            -
             *    name 
     | 
| 
      
 390 
     | 
    
         
            +
             *    name.cmp(other) -> -1 | 0 | 1
         
     | 
| 
      
 391 
     | 
    
         
            +
             *    name <=> other  -> -1 | 0 | 1
         
     | 
| 
       354 
392 
     | 
    
         
             
             *
         
     | 
| 
       355 
     | 
    
         
            -
             * Compares this Name with  
     | 
| 
       356 
     | 
    
         
            -
             * + 
     | 
| 
      
 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.
         
     | 
| 
       357 
395 
     | 
    
         
             
             */
         
     | 
| 
       358 
396 
     | 
    
         
             
            static VALUE
         
     | 
| 
       359 
397 
     | 
    
         
             
            ossl_x509name_cmp(VALUE self, VALUE other)
         
     | 
| 
         @@ -362,16 +400,16 @@ ossl_x509name_cmp(VALUE self, VALUE other) 
     | 
|
| 
       362 
400 
     | 
    
         | 
| 
       363 
401 
     | 
    
         
             
                result = ossl_x509name_cmp0(self, other);
         
     | 
| 
       364 
402 
     | 
    
         
             
                if (result < 0) return INT2FIX(-1);
         
     | 
| 
       365 
     | 
    
         
            -
                if (result >  
     | 
| 
      
 403 
     | 
    
         
            +
                if (result > 1) return INT2FIX(1);
         
     | 
| 
       366 
404 
     | 
    
         | 
| 
       367 
405 
     | 
    
         
             
                return INT2FIX(0);
         
     | 
| 
       368 
406 
     | 
    
         
             
            }
         
     | 
| 
       369 
407 
     | 
    
         | 
| 
       370 
408 
     | 
    
         
             
            /*
         
     | 
| 
       371 
409 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       372 
     | 
    
         
            -
             *   name.eql? 
     | 
| 
      
 410 
     | 
    
         
            +
             *   name.eql?(other) -> true | false
         
     | 
| 
       373 
411 
     | 
    
         
             
             *
         
     | 
| 
       374 
     | 
    
         
            -
             * Returns true if  
     | 
| 
      
 412 
     | 
    
         
            +
             * Returns true if _name_ and _other_ refer to the same hash key.
         
     | 
| 
       375 
413 
     | 
    
         
             
             */
         
     | 
| 
       376 
414 
     | 
    
         
             
            static VALUE
         
     | 
| 
       377 
415 
     | 
    
         
             
            ossl_x509name_eql(VALUE self, VALUE other)
         
     | 
| 
         @@ -402,7 +440,6 @@ ossl_x509name_hash(VALUE self) 
     | 
|
| 
       402 
440 
     | 
    
         
             
                return ULONG2NUM(hash);
         
     | 
| 
       403 
441 
     | 
    
         
             
            }
         
     | 
| 
       404 
442 
     | 
    
         | 
| 
       405 
     | 
    
         
            -
            #ifdef HAVE_X509_NAME_HASH_OLD
         
     | 
| 
       406 
443 
     | 
    
         
             
            /*
         
     | 
| 
       407 
444 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       408 
445 
     | 
    
         
             
             *    name.hash_old => integer
         
     | 
| 
         @@ -421,7 +458,6 @@ ossl_x509name_hash_old(VALUE self) 
     | 
|
| 
       421 
458 
     | 
    
         | 
| 
       422 
459 
     | 
    
         
             
                return ULONG2NUM(hash);
         
     | 
| 
       423 
460 
     | 
    
         
             
            }
         
     | 
| 
       424 
     | 
    
         
            -
            #endif
         
     | 
| 
       425 
461 
     | 
    
         | 
| 
       426 
462 
     | 
    
         
             
            /*
         
     | 
| 
       427 
463 
     | 
    
         
             
             * call-seq:
         
     | 
| 
         @@ -466,7 +502,6 @@ ossl_x509name_to_der(VALUE self) 
     | 
|
| 
       466 
502 
     | 
    
         
             
            void
         
     | 
| 
       467 
503 
     | 
    
         
             
            Init_ossl_x509name(void)
         
     | 
| 
       468 
504 
     | 
    
         
             
            {
         
     | 
| 
       469 
     | 
    
         
            -
            #undef rb_intern
         
     | 
| 
       470 
505 
     | 
    
         
             
                VALUE utf8str, ptrstr, ia5str, hash;
         
     | 
| 
       471 
506 
     | 
    
         | 
| 
       472 
507 
     | 
    
         
             
            #if 0
         
     | 
| 
         @@ -483,17 +518,17 @@ Init_ossl_x509name(void) 
     | 
|
| 
       483 
518 
     | 
    
         | 
| 
       484 
519 
     | 
    
         
             
                rb_define_alloc_func(cX509Name, ossl_x509name_alloc);
         
     | 
| 
       485 
520 
     | 
    
         
             
                rb_define_method(cX509Name, "initialize", ossl_x509name_initialize, -1);
         
     | 
| 
       486 
     | 
    
         
            -
                 
     | 
| 
      
 521 
     | 
    
         
            +
                rb_define_method(cX509Name, "initialize_copy", ossl_x509name_initialize_copy, 1);
         
     | 
| 
       487 
522 
     | 
    
         
             
                rb_define_method(cX509Name, "add_entry", ossl_x509name_add_entry, -1);
         
     | 
| 
       488 
523 
     | 
    
         
             
                rb_define_method(cX509Name, "to_s", ossl_x509name_to_s, -1);
         
     | 
| 
      
 524 
     | 
    
         
            +
                rb_define_method(cX509Name, "to_utf8", ossl_x509name_to_utf8, 0);
         
     | 
| 
      
 525 
     | 
    
         
            +
                rb_define_method(cX509Name, "inspect", ossl_x509name_inspect, 0);
         
     | 
| 
       489 
526 
     | 
    
         
             
                rb_define_method(cX509Name, "to_a", ossl_x509name_to_a, 0);
         
     | 
| 
       490 
527 
     | 
    
         
             
                rb_define_method(cX509Name, "cmp", ossl_x509name_cmp, 1);
         
     | 
| 
       491 
528 
     | 
    
         
             
                rb_define_alias(cX509Name, "<=>", "cmp");
         
     | 
| 
       492 
529 
     | 
    
         
             
                rb_define_method(cX509Name, "eql?", ossl_x509name_eql, 1);
         
     | 
| 
       493 
530 
     | 
    
         
             
                rb_define_method(cX509Name, "hash", ossl_x509name_hash, 0);
         
     | 
| 
       494 
     | 
    
         
            -
            #ifdef HAVE_X509_NAME_HASH_OLD
         
     | 
| 
       495 
531 
     | 
    
         
             
                rb_define_method(cX509Name, "hash_old", ossl_x509name_hash_old, 0);
         
     | 
| 
       496 
     | 
    
         
            -
            #endif
         
     | 
| 
       497 
532 
     | 
    
         
             
                rb_define_method(cX509Name, "to_der", ossl_x509name_to_der, 0);
         
     | 
| 
       498 
533 
     | 
    
         | 
| 
       499 
534 
     | 
    
         
             
                utf8str = INT2NUM(V_ASN1_UTF8STRING);
         
     | 
    
        data/ext/openssl/ossl_x509req.c
    CHANGED
    
    | 
         @@ -23,10 +23,6 @@ 
     | 
|
| 
       23 
23 
     | 
    
         
             
            	ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
         
     | 
| 
       24 
24 
     | 
    
         
             
                } \
         
     | 
| 
       25 
25 
     | 
    
         
             
            } while (0)
         
     | 
| 
       26 
     | 
    
         
            -
            #define SafeGetX509Req(obj, req) do { \
         
     | 
| 
       27 
     | 
    
         
            -
                OSSL_Check_Kind((obj), cX509Req); \
         
     | 
| 
       28 
     | 
    
         
            -
                GetX509Req((obj), (req)); \
         
     | 
| 
       29 
     | 
    
         
            -
            } while (0)
         
     | 
| 
       30 
26 
     | 
    
         | 
| 
       31 
27 
     | 
    
         
             
            /*
         
     | 
| 
       32 
28 
     | 
    
         
             
             * Classes
         
     | 
| 
         @@ -51,49 +47,16 @@ static const rb_data_type_t ossl_x509req_type = { 
     | 
|
| 
       51 
47 
     | 
    
         
             
            /*
         
     | 
| 
       52 
48 
     | 
    
         
             
             * Public functions
         
     | 
| 
       53 
49 
     | 
    
         
             
             */
         
     | 
| 
       54 
     | 
    
         
            -
            VALUE
         
     | 
| 
       55 
     | 
    
         
            -
            ossl_x509req_new(X509_REQ *req)
         
     | 
| 
       56 
     | 
    
         
            -
            {
         
     | 
| 
       57 
     | 
    
         
            -
                X509_REQ *new;
         
     | 
| 
       58 
     | 
    
         
            -
                VALUE obj;
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                obj = NewX509Req(cX509Req);
         
     | 
| 
       61 
     | 
    
         
            -
                if (!req) {
         
     | 
| 
       62 
     | 
    
         
            -
            	new = X509_REQ_new();
         
     | 
| 
       63 
     | 
    
         
            -
                } else {
         
     | 
| 
       64 
     | 
    
         
            -
            	new = X509_REQ_dup(req);
         
     | 
| 
       65 
     | 
    
         
            -
                }
         
     | 
| 
       66 
     | 
    
         
            -
                if (!new) {
         
     | 
| 
       67 
     | 
    
         
            -
            	ossl_raise(eX509ReqError, NULL);
         
     | 
| 
       68 
     | 
    
         
            -
                }
         
     | 
| 
       69 
     | 
    
         
            -
                SetX509Req(obj, new);
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                return obj;
         
     | 
| 
       72 
     | 
    
         
            -
            }
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
50 
     | 
    
         
             
            X509_REQ *
         
     | 
| 
       75 
51 
     | 
    
         
             
            GetX509ReqPtr(VALUE obj)
         
     | 
| 
       76 
52 
     | 
    
         
             
            {
         
     | 
| 
       77 
53 
     | 
    
         
             
                X509_REQ *req;
         
     | 
| 
       78 
54 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
                 
     | 
| 
      
 55 
     | 
    
         
            +
                GetX509Req(obj, req);
         
     | 
| 
       80 
56 
     | 
    
         | 
| 
       81 
57 
     | 
    
         
             
                return req;
         
     | 
| 
       82 
58 
     | 
    
         
             
            }
         
     | 
| 
       83 
59 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
            X509_REQ *
         
     | 
| 
       85 
     | 
    
         
            -
            DupX509ReqPtr(VALUE obj)
         
     | 
| 
       86 
     | 
    
         
            -
            {
         
     | 
| 
       87 
     | 
    
         
            -
                X509_REQ *req, *new;
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                SafeGetX509Req(obj, req);
         
     | 
| 
       90 
     | 
    
         
            -
                if (!(new = X509_REQ_dup(req))) {
         
     | 
| 
       91 
     | 
    
         
            -
            	ossl_raise(eX509ReqError, NULL);
         
     | 
| 
       92 
     | 
    
         
            -
                }
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                return new;
         
     | 
| 
       95 
     | 
    
         
            -
            }
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
60 
     | 
    
         
             
            /*
         
     | 
| 
       98 
61 
     | 
    
         
             
             * Private functions
         
     | 
| 
       99 
62 
     | 
    
         
             
             */
         
     | 
| 
         @@ -145,7 +108,7 @@ ossl_x509req_copy(VALUE self, VALUE other) 
     | 
|
| 
       145 
108 
     | 
    
         
             
                rb_check_frozen(self);
         
     | 
| 
       146 
109 
     | 
    
         
             
                if (self == other) return self;
         
     | 
| 
       147 
110 
     | 
    
         
             
                GetX509Req(self, a);
         
     | 
| 
       148 
     | 
    
         
            -
                 
     | 
| 
      
 111 
     | 
    
         
            +
                GetX509Req(other, b);
         
     | 
| 
       149 
112 
     | 
    
         
             
                if (!(req = X509_REQ_dup(b))) {
         
     | 
| 
       150 
113 
     | 
    
         
             
            	ossl_raise(eX509ReqError, NULL);
         
     | 
| 
       151 
114 
     | 
    
         
             
                }
         
     | 
| 
         @@ -330,10 +293,11 @@ ossl_x509req_set_public_key(VALUE self, VALUE key) 
     | 
|
| 
       330 
293 
     | 
    
         
             
                EVP_PKEY *pkey;
         
     | 
| 
       331 
294 
     | 
    
         | 
| 
       332 
295 
     | 
    
         
             
                GetX509Req(self, req);
         
     | 
| 
       333 
     | 
    
         
            -
                pkey = GetPKeyPtr(key);
         
     | 
| 
       334 
     | 
    
         
            -
                 
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
       336 
     | 
    
         
            -
             
     | 
| 
      
 296 
     | 
    
         
            +
                pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
         
     | 
| 
      
 297 
     | 
    
         
            +
                if (!X509_REQ_set_pubkey(req, pkey)) {
         
     | 
| 
      
 298 
     | 
    
         
            +
            	ossl_raise(eX509ReqError, NULL);
         
     | 
| 
      
 299 
     | 
    
         
            +
                }
         
     | 
| 
      
 300 
     | 
    
         
            +
             
     | 
| 
       337 
301 
     | 
    
         
             
                return key;
         
     | 
| 
       338 
302 
     | 
    
         
             
            }
         
     | 
| 
       339 
303 
     | 
    
         | 
| 
         @@ -346,7 +310,7 @@ ossl_x509req_sign(VALUE self, VALUE key, VALUE digest) 
     | 
|
| 
       346 
310 
     | 
    
         | 
| 
       347 
311 
     | 
    
         
             
                GetX509Req(self, req);
         
     | 
| 
       348 
312 
     | 
    
         
             
                pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
         
     | 
| 
       349 
     | 
    
         
            -
                md =  
     | 
| 
      
 313 
     | 
    
         
            +
                md = ossl_evp_get_digestbyname(digest);
         
     | 
| 
       350 
314 
     | 
    
         
             
                if (!X509_REQ_sign(req, pkey, md)) {
         
     | 
| 
       351 
315 
     | 
    
         
             
            	ossl_raise(eX509ReqError, NULL);
         
     | 
| 
       352 
316 
     | 
    
         
             
                }
         
     | 
| 
         @@ -364,8 +328,7 @@ ossl_x509req_verify(VALUE self, VALUE key) 
     | 
|
| 
       364 
328 
     | 
    
         
             
                EVP_PKEY *pkey;
         
     | 
| 
       365 
329 
     | 
    
         | 
| 
       366 
330 
     | 
    
         
             
                GetX509Req(self, req);
         
     | 
| 
       367 
     | 
    
         
            -
                pkey = GetPKeyPtr(key);
         
     | 
| 
       368 
     | 
    
         
            -
                ossl_pkey_check_public_key(pkey);
         
     | 
| 
      
 331 
     | 
    
         
            +
                pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
         
     | 
| 
       369 
332 
     | 
    
         
             
                switch (X509_REQ_verify(req, pkey)) {
         
     | 
| 
       370 
333 
     | 
    
         
             
                  case 1:
         
     | 
| 
       371 
334 
     | 
    
         
             
            	return Qtrue;
         
     | 
| 
         @@ -457,7 +420,7 @@ Init_ossl_x509req(void) 
     | 
|
| 
       457 
420 
     | 
    
         | 
| 
       458 
421 
     | 
    
         
             
                rb_define_alloc_func(cX509Req, ossl_x509req_alloc);
         
     | 
| 
       459 
422 
     | 
    
         
             
                rb_define_method(cX509Req, "initialize", ossl_x509req_initialize, -1);
         
     | 
| 
       460 
     | 
    
         
            -
                 
     | 
| 
      
 423 
     | 
    
         
            +
                rb_define_method(cX509Req, "initialize_copy", ossl_x509req_copy, 1);
         
     | 
| 
       461 
424 
     | 
    
         | 
| 
       462 
425 
     | 
    
         
             
                rb_define_method(cX509Req, "to_pem", ossl_x509req_to_pem, 0);
         
     | 
| 
       463 
426 
     | 
    
         
             
                rb_define_method(cX509Req, "to_der", ossl_x509req_to_der, 0);
         
     |