openssl 3.2.0 → 3.3.0
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.
- checksums.yaml +4 -4
 - data/CONTRIBUTING.md +180 -29
 - data/History.md +114 -1
 - data/README.md +11 -7
 - data/ext/openssl/extconf.rb +7 -9
 - data/ext/openssl/openssl_missing.c +1 -1
 - data/ext/openssl/openssl_missing.h +1 -1
 - data/ext/openssl/ossl.c +7 -9
 - data/ext/openssl/ossl.h +12 -8
 - data/ext/openssl/ossl_asn1.c +65 -261
 - data/ext/openssl/ossl_asn1.h +1 -19
 - data/ext/openssl/ossl_bio.c +1 -1
 - data/ext/openssl/ossl_bio.h +1 -1
 - data/ext/openssl/ossl_bn.c +12 -12
 - data/ext/openssl/ossl_bn.h +1 -2
 - data/ext/openssl/ossl_cipher.c +24 -9
 - data/ext/openssl/ossl_cipher.h +1 -4
 - data/ext/openssl/ossl_config.c +10 -9
 - data/ext/openssl/ossl_config.h +1 -1
 - data/ext/openssl/ossl_digest.c +39 -20
 - data/ext/openssl/ossl_digest.h +1 -4
 - data/ext/openssl/ossl_engine.c +3 -3
 - data/ext/openssl/ossl_engine.h +1 -4
 - data/ext/openssl/ossl_hmac.c +3 -3
 - data/ext/openssl/ossl_hmac.h +1 -4
 - data/ext/openssl/ossl_kdf.c +5 -5
 - data/ext/openssl/ossl_ns_spki.c +8 -8
 - data/ext/openssl/ossl_ns_spki.h +1 -5
 - data/ext/openssl/ossl_ocsp.c +8 -8
 - data/ext/openssl/ossl_ocsp.h +1 -8
 - data/ext/openssl/ossl_pkcs12.c +54 -3
 - data/ext/openssl/ossl_pkcs12.h +1 -4
 - data/ext/openssl/ossl_pkcs7.c +79 -22
 - data/ext/openssl/ossl_pkcs7.h +2 -22
 - data/ext/openssl/ossl_pkey.c +1 -1
 - data/ext/openssl/ossl_pkey.h +3 -14
 - data/ext/openssl/ossl_pkey_dh.c +2 -2
 - data/ext/openssl/ossl_pkey_dsa.c +2 -2
 - data/ext/openssl/ossl_pkey_ec.c +6 -6
 - data/ext/openssl/ossl_pkey_rsa.c +2 -2
 - data/ext/openssl/ossl_provider.c +1 -1
 - data/ext/openssl/ossl_rand.c +3 -3
 - data/ext/openssl/ossl_rand.h +1 -4
 - data/ext/openssl/ossl_ssl.c +71 -52
 - data/ext/openssl/ossl_ssl.h +1 -1
 - data/ext/openssl/ossl_ts.c +73 -15
 - data/ext/openssl/ossl_ts.h +1 -1
 - data/ext/openssl/ossl_x509.c +1 -1
 - data/ext/openssl/ossl_x509.h +1 -20
 - data/ext/openssl/ossl_x509attr.c +25 -26
 - data/ext/openssl/ossl_x509cert.c +42 -3
 - data/ext/openssl/ossl_x509crl.c +8 -4
 - data/ext/openssl/ossl_x509ext.c +3 -3
 - data/ext/openssl/ossl_x509name.c +3 -3
 - data/ext/openssl/ossl_x509req.c +8 -4
 - data/ext/openssl/ossl_x509revoked.c +2 -2
 - data/ext/openssl/ossl_x509store.c +16 -11
 - data/lib/openssl/asn1.rb +188 -0
 - data/lib/openssl/bn.rb +1 -1
 - data/lib/openssl/buffering.rb +24 -9
 - data/lib/openssl/cipher.rb +1 -1
 - data/lib/openssl/digest.rb +1 -1
 - data/lib/openssl/marshal.rb +1 -1
 - data/lib/openssl/ssl.rb +67 -4
 - data/lib/openssl/version.rb +1 -1
 - data/lib/openssl/x509.rb +6 -6
 - data/lib/openssl.rb +2 -1
 - metadata +6 -4
 - /data/{LICENSE.txt → COPYING} +0 -0
 
    
        data/ext/openssl/ossl_cipher.c
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #include "ossl.h"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -30,8 +30,8 @@ 
     | 
|
| 
       30 
30 
     | 
    
         
             
            /*
         
     | 
| 
       31 
31 
     | 
    
         
             
             * Classes
         
     | 
| 
       32 
32 
     | 
    
         
             
             */
         
     | 
| 
       33 
     | 
    
         
            -
            VALUE cCipher;
         
     | 
| 
       34 
     | 
    
         
            -
            VALUE eCipherError;
         
     | 
| 
      
 33 
     | 
    
         
            +
            static VALUE cCipher;
         
     | 
| 
      
 34 
     | 
    
         
            +
            static VALUE eCipherError;
         
     | 
| 
       35 
35 
     | 
    
         
             
            static ID id_auth_tag_len, id_key_set;
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
            static VALUE ossl_cipher_alloc(VALUE klass);
         
     | 
| 
         @@ -386,22 +386,37 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self) 
     | 
|
| 
       386 
386 
     | 
    
         
             
                in = (unsigned char *)RSTRING_PTR(data);
         
     | 
| 
       387 
387 
     | 
    
         
             
                in_len = RSTRING_LEN(data);
         
     | 
| 
       388 
388 
     | 
    
         
             
                GetCipher(self, ctx);
         
     | 
| 
       389 
     | 
    
         
            -
             
     | 
| 
       390 
     | 
    
         
            -
                 
     | 
| 
      
 389 
     | 
    
         
            +
             
     | 
| 
      
 390 
     | 
    
         
            +
                /*
         
     | 
| 
      
 391 
     | 
    
         
            +
                 * As of OpenSSL 3.2, there is no reliable way to determine the required
         
     | 
| 
      
 392 
     | 
    
         
            +
                 * output buffer size for arbitrary cipher modes.
         
     | 
| 
      
 393 
     | 
    
         
            +
                 * https://github.com/openssl/openssl/issues/22628
         
     | 
| 
      
 394 
     | 
    
         
            +
                 *
         
     | 
| 
      
 395 
     | 
    
         
            +
                 * in_len+block_size is usually sufficient, but AES key wrap with padding
         
     | 
| 
      
 396 
     | 
    
         
            +
                 * ciphers require in_len+15 even though they have a block size of 8 bytes.
         
     | 
| 
      
 397 
     | 
    
         
            +
                 *
         
     | 
| 
      
 398 
     | 
    
         
            +
                 * Using EVP_MAX_BLOCK_LENGTH (32) as a safe upper bound for ciphers
         
     | 
| 
      
 399 
     | 
    
         
            +
                 * currently implemented in OpenSSL, but this can change in the future.
         
     | 
| 
      
 400 
     | 
    
         
            +
                 */
         
     | 
| 
      
 401 
     | 
    
         
            +
                if (in_len > LONG_MAX - EVP_MAX_BLOCK_LENGTH) {
         
     | 
| 
       391 
402 
     | 
    
         
             
            	ossl_raise(rb_eRangeError,
         
     | 
| 
       392 
403 
     | 
    
         
             
            		   "data too big to make output buffer: %ld bytes", in_len);
         
     | 
| 
       393 
404 
     | 
    
         
             
                }
         
     | 
| 
      
 405 
     | 
    
         
            +
                out_len = in_len + EVP_MAX_BLOCK_LENGTH;
         
     | 
| 
       394 
406 
     | 
    
         | 
| 
       395 
407 
     | 
    
         
             
                if (NIL_P(str)) {
         
     | 
| 
       396 
408 
     | 
    
         
             
                    str = rb_str_new(0, out_len);
         
     | 
| 
       397 
409 
     | 
    
         
             
                } else {
         
     | 
| 
       398 
410 
     | 
    
         
             
                    StringValue(str);
         
     | 
| 
       399 
     | 
    
         
            -
                     
     | 
| 
      
 411 
     | 
    
         
            +
                    if ((long)rb_str_capacity(str) >= out_len)
         
     | 
| 
      
 412 
     | 
    
         
            +
                        rb_str_modify(str);
         
     | 
| 
      
 413 
     | 
    
         
            +
                    else
         
     | 
| 
      
 414 
     | 
    
         
            +
                        rb_str_modify_expand(str, out_len - RSTRING_LEN(str));
         
     | 
| 
       400 
415 
     | 
    
         
             
                }
         
     | 
| 
       401 
416 
     | 
    
         | 
| 
       402 
417 
     | 
    
         
             
                if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len))
         
     | 
| 
       403 
418 
     | 
    
         
             
            	ossl_raise(eCipherError, NULL);
         
     | 
| 
       404 
     | 
    
         
            -
                assert(out_len  
     | 
| 
      
 419 
     | 
    
         
            +
                assert(out_len <= RSTRING_LEN(str));
         
     | 
| 
       405 
420 
     | 
    
         
             
                rb_str_set_len(str, out_len);
         
     | 
| 
       406 
421 
     | 
    
         | 
| 
       407 
422 
     | 
    
         
             
                return str;
         
     | 
| 
         @@ -442,8 +457,8 @@ ossl_cipher_final(VALUE self) 
     | 
|
| 
       442 
457 
     | 
    
         
             
             *  call-seq:
         
     | 
| 
       443 
458 
     | 
    
         
             
             *     cipher.name -> string
         
     | 
| 
       444 
459 
     | 
    
         
             
             *
         
     | 
| 
       445 
     | 
    
         
            -
             *  Returns the name of the cipher which may differ slightly from the 
     | 
| 
       446 
     | 
    
         
            -
             *  name provided.
         
     | 
| 
      
 460 
     | 
    
         
            +
             *  Returns the short name of the cipher which may differ slightly from the
         
     | 
| 
      
 461 
     | 
    
         
            +
             *  original name provided.
         
     | 
| 
       447 
462 
     | 
    
         
             
             */
         
     | 
| 
       448 
463 
     | 
    
         
             
            static VALUE
         
     | 
| 
       449 
464 
     | 
    
         
             
            ossl_cipher_name(VALUE self)
         
     | 
    
        data/ext/openssl/ossl_cipher.h
    CHANGED
    
    | 
         @@ -5,14 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #if !defined(_OSSL_CIPHER_H_)
         
     | 
| 
       11 
11 
     | 
    
         
             
            #define _OSSL_CIPHER_H_
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            extern VALUE cCipher;
         
     | 
| 
       14 
     | 
    
         
            -
            extern VALUE eCipherError;
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
13 
     | 
    
         
             
            const EVP_CIPHER *ossl_evp_get_cipherbyname(VALUE);
         
     | 
| 
       17 
14 
     | 
    
         
             
            VALUE ossl_cipher_new(const EVP_CIPHER *);
         
     | 
| 
       18 
15 
     | 
    
         
             
            void Init_ossl_cipher(void);
         
     | 
    
        data/ext/openssl/ossl_config.c
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #include "ossl.h"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -22,7 +22,7 @@ static const rb_data_type_t ossl_config_type = { 
     | 
|
| 
       22 
22 
     | 
    
         
             
                {
         
     | 
| 
       23 
23 
     | 
    
         
             
                    0, nconf_free,
         
     | 
| 
       24 
24 
     | 
    
         
             
                },
         
     | 
| 
       25 
     | 
    
         
            -
                0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
         
     | 
| 
      
 25 
     | 
    
         
            +
                0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
         
     | 
| 
       26 
26 
     | 
    
         
             
            };
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
            CONF *
         
     | 
| 
         @@ -87,6 +87,7 @@ config_s_parse(VALUE klass, VALUE str) 
     | 
|
| 
       87 
87 
     | 
    
         | 
| 
       88 
88 
     | 
    
         
             
                bio = ossl_obj2bio(&str);
         
     | 
| 
       89 
89 
     | 
    
         
             
                config_load_bio(conf, bio); /* Consumes BIO */
         
     | 
| 
      
 90 
     | 
    
         
            +
                rb_obj_freeze(obj);
         
     | 
| 
       90 
91 
     | 
    
         
             
                return obj;
         
     | 
| 
       91 
92 
     | 
    
         
             
            }
         
     | 
| 
       92 
93 
     | 
    
         | 
| 
         @@ -144,6 +145,7 @@ config_initialize(int argc, VALUE *argv, VALUE self) 
     | 
|
| 
       144 
145 
     | 
    
         
             
                        ossl_raise(eConfigError, "BIO_new_file");
         
     | 
| 
       145 
146 
     | 
    
         
             
                    config_load_bio(conf, bio); /* Consumes BIO */
         
     | 
| 
       146 
147 
     | 
    
         
             
                }
         
     | 
| 
      
 148 
     | 
    
         
            +
                rb_obj_freeze(self);
         
     | 
| 
       147 
149 
     | 
    
         
             
                return self;
         
     | 
| 
       148 
150 
     | 
    
         
             
            }
         
     | 
| 
       149 
151 
     | 
    
         | 
| 
         @@ -158,6 +160,7 @@ config_initialize_copy(VALUE self, VALUE other) 
     | 
|
| 
       158 
160 
     | 
    
         
             
                rb_check_frozen(self);
         
     | 
| 
       159 
161 
     | 
    
         
             
                bio = ossl_obj2bio(&str);
         
     | 
| 
       160 
162 
     | 
    
         
             
                config_load_bio(conf, bio); /* Consumes BIO */
         
     | 
| 
      
 163 
     | 
    
         
            +
                rb_obj_freeze(self);
         
     | 
| 
       161 
164 
     | 
    
         
             
                return self;
         
     | 
| 
       162 
165 
     | 
    
         
             
            }
         
     | 
| 
       163 
166 
     | 
    
         | 
| 
         @@ -305,18 +308,16 @@ static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_conf_value, CONF_VALUE, VALUE) 
     | 
|
| 
       305 
308 
     | 
    
         
             
             *
         
     | 
| 
       306 
309 
     | 
    
         
             
             * Gets the parsable form of the current configuration.
         
     | 
| 
       307 
310 
     | 
    
         
             
             *
         
     | 
| 
       308 
     | 
    
         
            -
             * Given the following configuration being  
     | 
| 
      
 311 
     | 
    
         
            +
             * Given the following configuration file being loaded:
         
     | 
| 
       309 
312 
     | 
    
         
             
             *
         
     | 
| 
       310 
     | 
    
         
            -
             *   config = OpenSSL::Config. 
     | 
| 
       311 
     | 
    
         
            -
             *     #=> #<OpenSSL::Config sections=[]>
         
     | 
| 
       312 
     | 
    
         
            -
             *   config['default'] = {"foo"=>"bar","baz"=>"buz"}
         
     | 
| 
       313 
     | 
    
         
            -
             *     #=> {"foo"=>"bar", "baz"=>"buz"}
         
     | 
| 
      
 313 
     | 
    
         
            +
             *   config = OpenSSL::Config.load('baz.cnf')
         
     | 
| 
      
 314 
     | 
    
         
            +
             *     #=> #<OpenSSL::Config sections=["default"]>
         
     | 
| 
       314 
315 
     | 
    
         
             
             *   puts config.to_s
         
     | 
| 
       315 
316 
     | 
    
         
             
             *     #=> [ default ]
         
     | 
| 
       316 
317 
     | 
    
         
             
             *     #   foo=bar
         
     | 
| 
       317 
318 
     | 
    
         
             
             *     #   baz=buz
         
     | 
| 
       318 
319 
     | 
    
         
             
             *
         
     | 
| 
       319 
     | 
    
         
            -
             * You can  
     | 
| 
      
 320 
     | 
    
         
            +
             * You can get the serialized configuration using #to_s and then parse
         
     | 
| 
       320 
321 
     | 
    
         
             
             * it later:
         
     | 
| 
       321 
322 
     | 
    
         
             
             *
         
     | 
| 
       322 
323 
     | 
    
         
             
             *   serialized_config = config.to_s
         
     | 
| 
         @@ -455,6 +456,6 @@ Init_ossl_config(void) 
     | 
|
| 
       455 
456 
     | 
    
         
             
                 * The default system configuration file for OpenSSL.
         
     | 
| 
       456 
457 
     | 
    
         
             
                 */
         
     | 
| 
       457 
458 
     | 
    
         
             
                path = CONF_get1_default_config_file();
         
     | 
| 
       458 
     | 
    
         
            -
                path_str = ossl_buf2str(path, rb_long2int(strlen(path)));
         
     | 
| 
      
 459 
     | 
    
         
            +
                path_str = rb_obj_freeze(ossl_buf2str(path, rb_long2int(strlen(path))));
         
     | 
| 
       459 
460 
     | 
    
         
             
                rb_define_const(cConfig, "DEFAULT_CONFIG_FILE", path_str);
         
     | 
| 
       460 
461 
     | 
    
         
             
            }
         
     | 
    
        data/ext/openssl/ossl_config.h
    CHANGED
    
    
    
        data/ext/openssl/ossl_digest.c
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #include "ossl.h"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -19,8 +19,8 @@ 
     | 
|
| 
       19 
19 
     | 
    
         
             
            /*
         
     | 
| 
       20 
20 
     | 
    
         
             
             * Classes
         
     | 
| 
       21 
21 
     | 
    
         
             
             */
         
     | 
| 
       22 
     | 
    
         
            -
            VALUE cDigest;
         
     | 
| 
       23 
     | 
    
         
            -
            VALUE eDigestError;
         
     | 
| 
      
 22 
     | 
    
         
            +
            static VALUE cDigest;
         
     | 
| 
      
 23 
     | 
    
         
            +
            static VALUE eDigestError;
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
            static VALUE ossl_digest_alloc(VALUE klass);
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
         @@ -96,14 +96,15 @@ ossl_digest_alloc(VALUE klass) 
     | 
|
| 
       96 
96 
     | 
    
         
             
                return TypedData_Wrap_Struct(klass, &ossl_digest_type, 0);
         
     | 
| 
       97 
97 
     | 
    
         
             
            }
         
     | 
| 
       98 
98 
     | 
    
         | 
| 
       99 
     | 
    
         
            -
            VALUE ossl_digest_update(VALUE, VALUE);
         
     | 
| 
      
 99 
     | 
    
         
            +
            static VALUE ossl_digest_update(VALUE, VALUE);
         
     | 
| 
       100 
100 
     | 
    
         | 
| 
       101 
101 
     | 
    
         
             
            /*
         
     | 
| 
       102 
102 
     | 
    
         
             
             *  call-seq:
         
     | 
| 
       103 
103 
     | 
    
         
             
             *     Digest.new(string [, data]) -> Digest
         
     | 
| 
       104 
104 
     | 
    
         
             
             *
         
     | 
| 
       105 
105 
     | 
    
         
             
             * Creates a Digest instance based on _string_, which is either the ln
         
     | 
| 
       106 
     | 
    
         
            -
             * (long name) or sn (short name) of a supported digest algorithm.
         
     | 
| 
      
 106 
     | 
    
         
            +
             * (long name) or sn (short name) of a supported digest algorithm. A list of
         
     | 
| 
      
 107 
     | 
    
         
            +
             * supported algorithms can be obtained by calling OpenSSL::Digest.digests.
         
     | 
| 
       107 
108 
     | 
    
         
             
             *
         
     | 
| 
       108 
109 
     | 
    
         
             
             * If _data_ (a String) is given, it is used as the initial input to the
         
     | 
| 
       109 
110 
     | 
    
         
             
             * Digest instance, i.e.
         
     | 
| 
         @@ -162,6 +163,32 @@ ossl_digest_copy(VALUE self, VALUE other) 
     | 
|
| 
       162 
163 
     | 
    
         
             
                return self;
         
     | 
| 
       163 
164 
     | 
    
         
             
            }
         
     | 
| 
       164 
165 
     | 
    
         | 
| 
      
 166 
     | 
    
         
            +
            static void
         
     | 
| 
      
 167 
     | 
    
         
            +
            add_digest_name_to_ary(const OBJ_NAME *name, void *arg)
         
     | 
| 
      
 168 
     | 
    
         
            +
            {
         
     | 
| 
      
 169 
     | 
    
         
            +
                VALUE ary = (VALUE)arg;
         
     | 
| 
      
 170 
     | 
    
         
            +
                rb_ary_push(ary, rb_str_new2(name->name));
         
     | 
| 
      
 171 
     | 
    
         
            +
            }
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
            /*
         
     | 
| 
      
 174 
     | 
    
         
            +
             *  call-seq:
         
     | 
| 
      
 175 
     | 
    
         
            +
             *     OpenSSL::Digest.digests -> array[string...]
         
     | 
| 
      
 176 
     | 
    
         
            +
             *
         
     | 
| 
      
 177 
     | 
    
         
            +
             *  Returns the names of all available digests in an array.
         
     | 
| 
      
 178 
     | 
    
         
            +
             */
         
     | 
| 
      
 179 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 180 
     | 
    
         
            +
            ossl_s_digests(VALUE self)
         
     | 
| 
      
 181 
     | 
    
         
            +
            {
         
     | 
| 
      
 182 
     | 
    
         
            +
                VALUE ary;
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
                ary = rb_ary_new();
         
     | 
| 
      
 185 
     | 
    
         
            +
                OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH,
         
     | 
| 
      
 186 
     | 
    
         
            +
                                add_digest_name_to_ary,
         
     | 
| 
      
 187 
     | 
    
         
            +
                                (void*)ary);
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                return ary;
         
     | 
| 
      
 190 
     | 
    
         
            +
            }
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
       165 
192 
     | 
    
         
             
            /*
         
     | 
| 
       166 
193 
     | 
    
         
             
             *  call-seq:
         
     | 
| 
       167 
194 
     | 
    
         
             
             *     digest.reset -> self
         
     | 
| 
         @@ -198,7 +225,7 @@ ossl_digest_reset(VALUE self) 
     | 
|
| 
       198 
225 
     | 
    
         
             
             *   result = digest.digest
         
     | 
| 
       199 
226 
     | 
    
         
             
             *
         
     | 
| 
       200 
227 
     | 
    
         
             
             */
         
     | 
| 
       201 
     | 
    
         
            -
            VALUE
         
     | 
| 
      
 228 
     | 
    
         
            +
            static VALUE
         
     | 
| 
       202 
229 
     | 
    
         
             
            ossl_digest_update(VALUE self, VALUE data)
         
     | 
| 
       203 
230 
     | 
    
         
             
            {
         
     | 
| 
       204 
231 
     | 
    
         
             
                EVP_MD_CTX *ctx;
         
     | 
| 
         @@ -218,23 +245,13 @@ ossl_digest_update(VALUE self, VALUE data) 
     | 
|
| 
       218 
245 
     | 
    
         
             
             *
         
     | 
| 
       219 
246 
     | 
    
         
             
             */
         
     | 
| 
       220 
247 
     | 
    
         
             
            static VALUE
         
     | 
| 
       221 
     | 
    
         
            -
            ossl_digest_finish( 
     | 
| 
      
 248 
     | 
    
         
            +
            ossl_digest_finish(VALUE self)
         
     | 
| 
       222 
249 
     | 
    
         
             
            {
         
     | 
| 
       223 
250 
     | 
    
         
             
                EVP_MD_CTX *ctx;
         
     | 
| 
       224 
251 
     | 
    
         
             
                VALUE str;
         
     | 
| 
       225 
     | 
    
         
            -
                int out_len;
         
     | 
| 
       226 
252 
     | 
    
         | 
| 
       227 
253 
     | 
    
         
             
                GetDigest(self, ctx);
         
     | 
| 
       228 
     | 
    
         
            -
                 
     | 
| 
       229 
     | 
    
         
            -
                out_len = EVP_MD_CTX_size(ctx);
         
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
       231 
     | 
    
         
            -
                if (NIL_P(str)) {
         
     | 
| 
       232 
     | 
    
         
            -
                    str = rb_str_new(NULL, out_len);
         
     | 
| 
       233 
     | 
    
         
            -
                } else {
         
     | 
| 
       234 
     | 
    
         
            -
                    StringValue(str);
         
     | 
| 
       235 
     | 
    
         
            -
                    rb_str_resize(str, out_len);
         
     | 
| 
       236 
     | 
    
         
            -
                }
         
     | 
| 
       237 
     | 
    
         
            -
             
     | 
| 
      
 254 
     | 
    
         
            +
                str = rb_str_new(NULL, EVP_MD_CTX_size(ctx));
         
     | 
| 
       238 
255 
     | 
    
         
             
                if (!EVP_DigestFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), NULL))
         
     | 
| 
       239 
256 
     | 
    
         
             
            	ossl_raise(eDigestError, "EVP_DigestFinal_ex");
         
     | 
| 
       240 
257 
     | 
    
         | 
| 
         @@ -245,7 +262,8 @@ ossl_digest_finish(int argc, VALUE *argv, VALUE self) 
     | 
|
| 
       245 
262 
     | 
    
         
             
             *  call-seq:
         
     | 
| 
       246 
263 
     | 
    
         
             
             *      digest.name -> string
         
     | 
| 
       247 
264 
     | 
    
         
             
             *
         
     | 
| 
       248 
     | 
    
         
            -
             * Returns the  
     | 
| 
      
 265 
     | 
    
         
            +
             * Returns the short name of this Digest algorithm which may differ slightly
         
     | 
| 
      
 266 
     | 
    
         
            +
             * from the original name provided.
         
     | 
| 
       249 
267 
     | 
    
         
             
             *
         
     | 
| 
       250 
268 
     | 
    
         
             
             * === Example
         
     | 
| 
       251 
269 
     | 
    
         
             
             *   digest = OpenSSL::Digest.new('SHA512')
         
     | 
| 
         @@ -412,12 +430,13 @@ Init_ossl_digest(void) 
     | 
|
| 
       412 
430 
     | 
    
         | 
| 
       413 
431 
     | 
    
         
             
                rb_define_alloc_func(cDigest, ossl_digest_alloc);
         
     | 
| 
       414 
432 
     | 
    
         | 
| 
      
 433 
     | 
    
         
            +
                rb_define_module_function(cDigest, "digests", ossl_s_digests, 0);
         
     | 
| 
       415 
434 
     | 
    
         
             
                rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1);
         
     | 
| 
       416 
435 
     | 
    
         
             
                rb_define_method(cDigest, "initialize_copy", ossl_digest_copy, 1);
         
     | 
| 
       417 
436 
     | 
    
         
             
                rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
         
     | 
| 
       418 
437 
     | 
    
         
             
                rb_define_method(cDigest, "update", ossl_digest_update, 1);
         
     | 
| 
       419 
438 
     | 
    
         
             
                rb_define_alias(cDigest, "<<", "update");
         
     | 
| 
       420 
     | 
    
         
            -
                rb_define_private_method(cDigest, "finish", ossl_digest_finish,  
     | 
| 
      
 439 
     | 
    
         
            +
                rb_define_private_method(cDigest, "finish", ossl_digest_finish, 0);
         
     | 
| 
       421 
440 
     | 
    
         
             
                rb_define_method(cDigest, "digest_length", ossl_digest_size, 0);
         
     | 
| 
       422 
441 
     | 
    
         
             
                rb_define_method(cDigest, "block_length", ossl_digest_block_length, 0);
         
     | 
| 
       423 
442 
     | 
    
         | 
    
        data/ext/openssl/ossl_digest.h
    CHANGED
    
    | 
         @@ -5,14 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #if !defined(_OSSL_DIGEST_H_)
         
     | 
| 
       11 
11 
     | 
    
         
             
            #define _OSSL_DIGEST_H_
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            extern VALUE cDigest;
         
     | 
| 
       14 
     | 
    
         
            -
            extern VALUE eDigestError;
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
13 
     | 
    
         
             
            const EVP_MD *ossl_evp_get_digestbyname(VALUE);
         
     | 
| 
       17 
14 
     | 
    
         
             
            VALUE ossl_digest_new(const EVP_MD *);
         
     | 
| 
       18 
15 
     | 
    
         
             
            void Init_ossl_digest(void);
         
     | 
    
        data/ext/openssl/ossl_engine.c
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #include "ossl.h"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -37,12 +37,12 @@ 
     | 
|
| 
       37 
37 
     | 
    
         
             
             *
         
     | 
| 
       38 
38 
     | 
    
         
             
             * See also, https://www.openssl.org/docs/crypto/engine.html
         
     | 
| 
       39 
39 
     | 
    
         
             
             */
         
     | 
| 
       40 
     | 
    
         
            -
            VALUE cEngine;
         
     | 
| 
      
 40 
     | 
    
         
            +
            static VALUE cEngine;
         
     | 
| 
       41 
41 
     | 
    
         
             
            /* Document-class: OpenSSL::Engine::EngineError
         
     | 
| 
       42 
42 
     | 
    
         
             
             *
         
     | 
| 
       43 
43 
     | 
    
         
             
             * This is the generic exception for OpenSSL::Engine related errors
         
     | 
| 
       44 
44 
     | 
    
         
             
             */
         
     | 
| 
       45 
     | 
    
         
            -
            VALUE eEngineError;
         
     | 
| 
      
 45 
     | 
    
         
            +
            static VALUE eEngineError;
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
            /*
         
     | 
| 
       48 
48 
     | 
    
         
             
             * Private
         
     | 
    
        data/ext/openssl/ossl_engine.h
    CHANGED
    
    | 
         @@ -6,14 +6,11 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
             */
         
     | 
| 
       7 
7 
     | 
    
         
             
            /*
         
     | 
| 
       8 
8 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       9 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 9 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       10 
10 
     | 
    
         
             
             */
         
     | 
| 
       11 
11 
     | 
    
         
             
            #if !defined(OSSL_ENGINE_H)
         
     | 
| 
       12 
12 
     | 
    
         
             
            #define OSSL_ENGINE_H
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            extern VALUE cEngine;
         
     | 
| 
       15 
     | 
    
         
            -
            extern VALUE eEngineError;
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
14 
     | 
    
         
             
            void Init_ossl_engine(void);
         
     | 
| 
       18 
15 
     | 
    
         | 
| 
       19 
16 
     | 
    
         
             
            #endif /* OSSL_ENGINE_H */
         
     | 
    
        data/ext/openssl/ossl_hmac.c
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #include "ossl.h"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -21,8 +21,8 @@ 
     | 
|
| 
       21 
21 
     | 
    
         
             
            /*
         
     | 
| 
       22 
22 
     | 
    
         
             
             * Classes
         
     | 
| 
       23 
23 
     | 
    
         
             
             */
         
     | 
| 
       24 
     | 
    
         
            -
            VALUE cHMAC;
         
     | 
| 
       25 
     | 
    
         
            -
            VALUE eHMACError;
         
     | 
| 
      
 24 
     | 
    
         
            +
            static VALUE cHMAC;
         
     | 
| 
      
 25 
     | 
    
         
            +
            static VALUE eHMACError;
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
            /*
         
     | 
| 
       28 
28 
     | 
    
         
             
             * Public
         
     | 
    
        data/ext/openssl/ossl_hmac.h
    CHANGED
    
    | 
         @@ -5,14 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #if !defined(_OSSL_HMAC_H_)
         
     | 
| 
       11 
11 
     | 
    
         
             
            #define _OSSL_HMAC_H_
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            extern VALUE cHMAC;
         
     | 
| 
       14 
     | 
    
         
            -
            extern VALUE eHMACError;
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
13 
     | 
    
         
             
            void Init_ossl_hmac(void);
         
     | 
| 
       17 
14 
     | 
    
         | 
| 
       18 
15 
     | 
    
         
             
            #endif /* _OSSL_HMAC_H_ */
         
     | 
    
        data/ext/openssl/ossl_kdf.c
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ static VALUE mKDF, eKDF; 
     | 
|
| 
       18 
18 
     | 
    
         
             
             * of _length_ bytes.
         
     | 
| 
       19 
19 
     | 
    
         
             
             *
         
     | 
| 
       20 
20 
     | 
    
         
             
             * For more information about PBKDF2, see RFC 2898 Section 5.2
         
     | 
| 
       21 
     | 
    
         
            -
             * (https:// 
     | 
| 
      
 21 
     | 
    
         
            +
             * (https://www.rfc-editor.org/rfc/rfc2898#section-5.2).
         
     | 
| 
       22 
22 
     | 
    
         
             
             *
         
     | 
| 
       23 
23 
     | 
    
         
             
             * === Parameters
         
     | 
| 
       24 
24 
     | 
    
         
             
             * pass       :: The password.
         
     | 
| 
         @@ -81,10 +81,10 @@ kdf_pbkdf2_hmac(int argc, VALUE *argv, VALUE self) 
     | 
|
| 
       81 
81 
     | 
    
         
             
             * bcrypt.
         
     | 
| 
       82 
82 
     | 
    
         
             
             *
         
     | 
| 
       83 
83 
     | 
    
         
             
             * The keyword arguments _N_, _r_ and _p_ can be used to tune scrypt. RFC 7914
         
     | 
| 
       84 
     | 
    
         
            -
             * (published on 2016-08, https:// 
     | 
| 
      
 84 
     | 
    
         
            +
             * (published on 2016-08, https://www.rfc-editor.org/rfc/rfc7914#section-2) states
         
     | 
| 
       85 
85 
     | 
    
         
             
             * that using values r=8 and p=1 appears to yield good results.
         
     | 
| 
       86 
86 
     | 
    
         
             
             *
         
     | 
| 
       87 
     | 
    
         
            -
             * See RFC 7914 (https:// 
     | 
| 
      
 87 
     | 
    
         
            +
             * See RFC 7914 (https://www.rfc-editor.org/rfc/rfc7914) for more information.
         
     | 
| 
       88 
88 
     | 
    
         
             
             *
         
     | 
| 
       89 
89 
     | 
    
         
             
             * === Parameters
         
     | 
| 
       90 
90 
     | 
    
         
             
             * pass   :: Passphrase.
         
     | 
| 
         @@ -147,7 +147,7 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self) 
     | 
|
| 
       147 
147 
     | 
    
         
             
             *    KDF.hkdf(ikm, salt:, info:, length:, hash:) -> String
         
     | 
| 
       148 
148 
     | 
    
         
             
             *
         
     | 
| 
       149 
149 
     | 
    
         
             
             * HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as specified in
         
     | 
| 
       150 
     | 
    
         
            -
             * {RFC 5869}[https:// 
     | 
| 
      
 150 
     | 
    
         
            +
             * {RFC 5869}[https://www.rfc-editor.org/rfc/rfc5869].
         
     | 
| 
       151 
151 
     | 
    
         
             
             *
         
     | 
| 
       152 
152 
     | 
    
         
             
             * New in OpenSSL 1.1.0.
         
     | 
| 
       153 
153 
     | 
    
         
             
             *
         
     | 
| 
         @@ -165,7 +165,7 @@ kdf_scrypt(int argc, VALUE *argv, VALUE self) 
     | 
|
| 
       165 
165 
     | 
    
         
             
             *   The hash function.
         
     | 
| 
       166 
166 
     | 
    
         
             
             *
         
     | 
| 
       167 
167 
     | 
    
         
             
             * === Example
         
     | 
| 
       168 
     | 
    
         
            -
             *   # The values from https:// 
     | 
| 
      
 168 
     | 
    
         
            +
             *   # The values from https://www.rfc-editor.org/rfc/rfc5869#appendix-A.1
         
     | 
| 
       169 
169 
     | 
    
         
             
             *   ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*")
         
     | 
| 
       170 
170 
     | 
    
         
             
             *   salt = ["000102030405060708090a0b0c"].pack("H*")
         
     | 
| 
       171 
171 
     | 
    
         
             
             *   info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*")
         
     | 
    
        data/ext/openssl/ossl_ns_spki.c
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #include "ossl.h"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -27,9 +27,9 @@ 
     | 
|
| 
       27 
27 
     | 
    
         
             
            /*
         
     | 
| 
       28 
28 
     | 
    
         
             
             * Classes
         
     | 
| 
       29 
29 
     | 
    
         
             
             */
         
     | 
| 
       30 
     | 
    
         
            -
            VALUE mNetscape;
         
     | 
| 
       31 
     | 
    
         
            -
            VALUE cSPKI;
         
     | 
| 
       32 
     | 
    
         
            -
            VALUE eSPKIError;
         
     | 
| 
      
 30 
     | 
    
         
            +
            static VALUE mNetscape;
         
     | 
| 
      
 31 
     | 
    
         
            +
            static VALUE cSPKI;
         
     | 
| 
      
 32 
     | 
    
         
            +
            static VALUE eSPKIError;
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
            /*
         
     | 
| 
       35 
35 
     | 
    
         
             
             * Public functions
         
     | 
| 
         @@ -115,11 +115,11 @@ ossl_spki_to_der(VALUE self) 
     | 
|
| 
       115 
115 
     | 
    
         | 
| 
       116 
116 
     | 
    
         
             
                GetSPKI(self, spki);
         
     | 
| 
       117 
117 
     | 
    
         
             
                if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0)
         
     | 
| 
       118 
     | 
    
         
            -
                    ossl_raise( 
     | 
| 
      
 118 
     | 
    
         
            +
                    ossl_raise(eSPKIError, "i2d_NETSCAPE_SPKI");
         
     | 
| 
       119 
119 
     | 
    
         
             
                str = rb_str_new(0, len);
         
     | 
| 
       120 
120 
     | 
    
         
             
                p = (unsigned char *)RSTRING_PTR(str);
         
     | 
| 
       121 
121 
     | 
    
         
             
                if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
         
     | 
| 
       122 
     | 
    
         
            -
                    ossl_raise( 
     | 
| 
      
 122 
     | 
    
         
            +
                    ossl_raise(eSPKIError, "i2d_NETSCAPE_SPKI");
         
     | 
| 
       123 
123 
     | 
    
         
             
                ossl_str_adjust(str, p);
         
     | 
| 
       124 
124 
     | 
    
         | 
| 
       125 
125 
     | 
    
         
             
                return str;
         
     | 
| 
         @@ -365,8 +365,8 @@ ossl_spki_verify(VALUE self, VALUE key) 
     | 
|
| 
       365 
365 
     | 
    
         
             
             *
         
     | 
| 
       366 
366 
     | 
    
         
             
             * OpenSSL::Netscape is a namespace for SPKI (Simple Public Key
         
     | 
| 
       367 
367 
     | 
    
         
             
             * Infrastructure) which implements Signed Public Key and Challenge.
         
     | 
| 
       368 
     | 
    
         
            -
             * See {RFC 2692}[ 
     | 
| 
       369 
     | 
    
         
            -
             * 2693}[ 
     | 
| 
      
 368 
     | 
    
         
            +
             * See {RFC 2692}[https://www.rfc-editor.org/rfc/rfc2692] and {RFC
         
     | 
| 
      
 369 
     | 
    
         
            +
             * 2693}[https://www.rfc-editor.org/rfc/rfc2692] for details.
         
     | 
| 
       370 
370 
     | 
    
         
             
             */
         
     | 
| 
       371 
371 
     | 
    
         | 
| 
       372 
372 
     | 
    
         
             
            /* Document-class: OpenSSL::Netscape::SPKIError
         
     | 
    
        data/ext/openssl/ossl_ns_spki.h
    CHANGED
    
    | 
         @@ -5,15 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
             */
         
     | 
| 
       6 
6 
     | 
    
         
             
            /*
         
     | 
| 
       7 
7 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       8 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       9 
9 
     | 
    
         
             
             */
         
     | 
| 
       10 
10 
     | 
    
         
             
            #if !defined(_OSSL_NS_SPKI_H_)
         
     | 
| 
       11 
11 
     | 
    
         
             
            #define _OSSL_NS_SPKI_H_
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            extern VALUE mNetscape;
         
     | 
| 
       14 
     | 
    
         
            -
            extern VALUE cSPKI;
         
     | 
| 
       15 
     | 
    
         
            -
            extern VALUE eSPKIError;
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
13 
     | 
    
         
             
            void Init_ossl_ns_spki(void);
         
     | 
| 
       18 
14 
     | 
    
         | 
| 
       19 
15 
     | 
    
         
             
            #endif /* _OSSL_NS_SPKI_H_ */
         
     | 
    
        data/ext/openssl/ossl_ocsp.c
    CHANGED
    
    | 
         @@ -6,7 +6,7 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
             */
         
     | 
| 
       7 
7 
     | 
    
         
             
            /*
         
     | 
| 
       8 
8 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       9 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 9 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       10 
10 
     | 
    
         
             
             */
         
     | 
| 
       11 
11 
     | 
    
         
             
            #include "ossl.h"
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
         @@ -67,13 +67,13 @@ 
     | 
|
| 
       67 
67 
     | 
    
         
             
                if(!(cid)) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \
         
     | 
| 
       68 
68 
     | 
    
         
             
            } while (0)
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
            VALUE mOCSP;
         
     | 
| 
       71 
     | 
    
         
            -
            VALUE eOCSPError;
         
     | 
| 
       72 
     | 
    
         
            -
            VALUE cOCSPReq;
         
     | 
| 
       73 
     | 
    
         
            -
            VALUE cOCSPRes;
         
     | 
| 
       74 
     | 
    
         
            -
            VALUE cOCSPBasicRes;
         
     | 
| 
       75 
     | 
    
         
            -
            VALUE cOCSPSingleRes;
         
     | 
| 
       76 
     | 
    
         
            -
            VALUE cOCSPCertId;
         
     | 
| 
      
 70 
     | 
    
         
            +
            static VALUE mOCSP;
         
     | 
| 
      
 71 
     | 
    
         
            +
            static VALUE eOCSPError;
         
     | 
| 
      
 72 
     | 
    
         
            +
            static VALUE cOCSPReq;
         
     | 
| 
      
 73 
     | 
    
         
            +
            static VALUE cOCSPRes;
         
     | 
| 
      
 74 
     | 
    
         
            +
            static VALUE cOCSPBasicRes;
         
     | 
| 
      
 75 
     | 
    
         
            +
            static VALUE cOCSPSingleRes;
         
     | 
| 
      
 76 
     | 
    
         
            +
            static VALUE cOCSPCertId;
         
     | 
| 
       77 
77 
     | 
    
         | 
| 
       78 
78 
     | 
    
         
             
            static void
         
     | 
| 
       79 
79 
     | 
    
         
             
            ossl_ocsp_request_free(void *ptr)
         
     | 
    
        data/ext/openssl/ossl_ocsp.h
    CHANGED
    
    | 
         @@ -6,18 +6,11 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
             */
         
     | 
| 
       7 
7 
     | 
    
         
             
            /*
         
     | 
| 
       8 
8 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       9 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 9 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       10 
10 
     | 
    
         
             
             */
         
     | 
| 
       11 
11 
     | 
    
         
             
            #if !defined(_OSSL_OCSP_H_)
         
     | 
| 
       12 
12 
     | 
    
         
             
            #define _OSSL_OCSP_H_
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            #if !defined(OPENSSL_NO_OCSP)
         
     | 
| 
       15 
     | 
    
         
            -
            extern VALUE mOCSP;
         
     | 
| 
       16 
     | 
    
         
            -
            extern VALUE cOCSPReq;
         
     | 
| 
       17 
     | 
    
         
            -
            extern VALUE cOCSPRes;
         
     | 
| 
       18 
     | 
    
         
            -
            extern VALUE cOCSPBasicRes;
         
     | 
| 
       19 
     | 
    
         
            -
            #endif
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
14 
     | 
    
         
             
            void Init_ossl_ocsp(void);
         
     | 
| 
       22 
15 
     | 
    
         | 
| 
       23 
16 
     | 
    
         
             
            #endif /* _OSSL_OCSP_H_ */
         
     | 
    
        data/ext/openssl/ossl_pkcs12.c
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            /*
         
     | 
| 
       2 
2 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       3 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 3 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       4 
4 
     | 
    
         
             
             */
         
     | 
| 
       5 
5 
     | 
    
         
             
            #include "ossl.h"
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
         @@ -27,8 +27,8 @@ 
     | 
|
| 
       27 
27 
     | 
    
         
             
            /*
         
     | 
| 
       28 
28 
     | 
    
         
             
             * Classes
         
     | 
| 
       29 
29 
     | 
    
         
             
             */
         
     | 
| 
       30 
     | 
    
         
            -
            VALUE cPKCS12;
         
     | 
| 
       31 
     | 
    
         
            -
            VALUE ePKCS12Error;
         
     | 
| 
      
 30 
     | 
    
         
            +
            static VALUE cPKCS12;
         
     | 
| 
      
 31 
     | 
    
         
            +
            static VALUE ePKCS12Error;
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
            /*
         
     | 
| 
       34 
34 
     | 
    
         
             
             * Private
         
     | 
| 
         @@ -134,6 +134,10 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self) 
     | 
|
| 
       134 
134 
     | 
    
         
             
                if (!NIL_P(keytype))
         
     | 
| 
       135 
135 
     | 
    
         
             
                    ktype = NUM2INT(keytype);
         
     | 
| 
       136 
136 
     | 
    
         | 
| 
      
 137 
     | 
    
         
            +
                if (ktype != 0 && ktype != KEY_SIG && ktype != KEY_EX) {
         
     | 
| 
      
 138 
     | 
    
         
            +
                    ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
         
     | 
| 
      
 139 
     | 
    
         
            +
                }
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
       137 
141 
     | 
    
         
             
                obj = NewPKCS12(cPKCS12);
         
     | 
| 
       138 
142 
     | 
    
         
             
                x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
         
     | 
| 
       139 
143 
     | 
    
         
             
                p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
         
     | 
| 
         @@ -247,6 +251,48 @@ ossl_pkcs12_to_der(VALUE self) 
     | 
|
| 
       247 
251 
     | 
    
         
             
                return str;
         
     | 
| 
       248 
252 
     | 
    
         
             
            }
         
     | 
| 
       249 
253 
     | 
    
         | 
| 
      
 254 
     | 
    
         
            +
            /*
         
     | 
| 
      
 255 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 256 
     | 
    
         
            +
             *    pkcs12.set_mac(pass, salt = nil, iter = nil, md_type = nil)
         
     | 
| 
      
 257 
     | 
    
         
            +
             *
         
     | 
| 
      
 258 
     | 
    
         
            +
             * Sets MAC parameters and generates MAC over the PKCS #12 structure.
         
     | 
| 
      
 259 
     | 
    
         
            +
             *
         
     | 
| 
      
 260 
     | 
    
         
            +
             * This method uses HMAC and the PKCS #12 specific password-based KDF as
         
     | 
| 
      
 261 
     | 
    
         
            +
             * specified in the original PKCS #12.
         
     | 
| 
      
 262 
     | 
    
         
            +
             *
         
     | 
| 
      
 263 
     | 
    
         
            +
             * See also the man page PKCS12_set_mac(3).
         
     | 
| 
      
 264 
     | 
    
         
            +
             *
         
     | 
| 
      
 265 
     | 
    
         
            +
             * Added in version 3.3.0.
         
     | 
| 
      
 266 
     | 
    
         
            +
             */
         
     | 
| 
      
 267 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 268 
     | 
    
         
            +
            pkcs12_set_mac(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 269 
     | 
    
         
            +
            {
         
     | 
| 
      
 270 
     | 
    
         
            +
                PKCS12 *p12;
         
     | 
| 
      
 271 
     | 
    
         
            +
                VALUE pass, salt, iter, md_name;
         
     | 
| 
      
 272 
     | 
    
         
            +
                int iter_i = 0;
         
     | 
| 
      
 273 
     | 
    
         
            +
                const EVP_MD *md_type = NULL;
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
                rb_scan_args(argc, argv, "13", &pass, &salt, &iter, &md_name);
         
     | 
| 
      
 276 
     | 
    
         
            +
                rb_check_frozen(self);
         
     | 
| 
      
 277 
     | 
    
         
            +
                GetPKCS12(self, p12);
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
                StringValue(pass);
         
     | 
| 
      
 280 
     | 
    
         
            +
                if (!NIL_P(salt))
         
     | 
| 
      
 281 
     | 
    
         
            +
                    StringValue(salt);
         
     | 
| 
      
 282 
     | 
    
         
            +
                if (!NIL_P(iter))
         
     | 
| 
      
 283 
     | 
    
         
            +
                    iter_i = NUM2INT(iter);
         
     | 
| 
      
 284 
     | 
    
         
            +
                if (!NIL_P(md_name))
         
     | 
| 
      
 285 
     | 
    
         
            +
                    md_type = ossl_evp_get_digestbyname(md_name);
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
                if (!PKCS12_set_mac(p12, RSTRING_PTR(pass), RSTRING_LENINT(pass),
         
     | 
| 
      
 288 
     | 
    
         
            +
                                    !NIL_P(salt) ? (unsigned char *)RSTRING_PTR(salt) : NULL,
         
     | 
| 
      
 289 
     | 
    
         
            +
                                    !NIL_P(salt) ? RSTRING_LENINT(salt) : 0,
         
     | 
| 
      
 290 
     | 
    
         
            +
                                    iter_i, md_type))
         
     | 
| 
      
 291 
     | 
    
         
            +
                    ossl_raise(ePKCS12Error, "PKCS12_set_mac");
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 294 
     | 
    
         
            +
            }
         
     | 
| 
      
 295 
     | 
    
         
            +
             
     | 
| 
       250 
296 
     | 
    
         
             
            void
         
     | 
| 
       251 
297 
     | 
    
         
             
            Init_ossl_pkcs12(void)
         
     | 
| 
       252 
298 
     | 
    
         
             
            {
         
     | 
| 
         @@ -272,4 +318,9 @@ Init_ossl_pkcs12(void) 
     | 
|
| 
       272 
318 
     | 
    
         
             
                rb_attr(cPKCS12, rb_intern("ca_certs"), 1, 0, Qfalse);
         
     | 
| 
       273 
319 
     | 
    
         
             
                rb_define_method(cPKCS12, "initialize", ossl_pkcs12_initialize, -1);
         
     | 
| 
       274 
320 
     | 
    
         
             
                rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
         
     | 
| 
      
 321 
     | 
    
         
            +
                rb_define_method(cPKCS12, "set_mac", pkcs12_set_mac, -1);
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
                /* MSIE specific PKCS12 key usage extensions */
         
     | 
| 
      
 324 
     | 
    
         
            +
                rb_define_const(cPKCS12, "KEY_EX", INT2NUM(KEY_EX));
         
     | 
| 
      
 325 
     | 
    
         
            +
                rb_define_const(cPKCS12, "KEY_SIG", INT2NUM(KEY_SIG));
         
     | 
| 
       275 
326 
     | 
    
         
             
            }
         
     | 
    
        data/ext/openssl/ossl_pkcs12.h
    CHANGED
    
    | 
         @@ -1,13 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            /*
         
     | 
| 
       2 
2 
     | 
    
         
             
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
       3 
     | 
    
         
            -
             * (See the file ' 
     | 
| 
      
 3 
     | 
    
         
            +
             * (See the file 'COPYING'.)
         
     | 
| 
       4 
4 
     | 
    
         
             
             */
         
     | 
| 
       5 
5 
     | 
    
         
             
            #if !defined(_OSSL_PKCS12_H_)
         
     | 
| 
       6 
6 
     | 
    
         
             
            #define _OSSL_PKCS12_H_
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            extern VALUE cPKCS12;
         
     | 
| 
       9 
     | 
    
         
            -
            extern VALUE ePKCS12Error;
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
8 
     | 
    
         
             
            void Init_ossl_pkcs12(void);
         
     | 
| 
       12 
9 
     | 
    
         | 
| 
       13 
10 
     | 
    
         
             
            #endif /* _OSSL_PKCS12_H_ */
         
     |