zig_example 0.3.0 → 0.3.1
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/ext/mkmf.rb +2734 -0
 - data/ext/openssl/openssl_missing.c +40 -0
 - data/ext/openssl/openssl_missing.h +238 -0
 - data/ext/openssl/ossl.c +1295 -0
 - data/ext/openssl/ossl.h +201 -0
 - data/ext/openssl/ossl_asn1.c +1891 -0
 - data/ext/openssl/ossl_asn1.h +62 -0
 - data/ext/openssl/ossl_bio.c +42 -0
 - data/ext/openssl/ossl_bio.h +16 -0
 - data/ext/openssl/ossl_bn.c +1344 -0
 - data/ext/openssl/ossl_bn.h +26 -0
 - data/ext/openssl/ossl_cipher.c +1074 -0
 - data/ext/openssl/ossl_cipher.h +20 -0
 - data/ext/openssl/ossl_config.c +460 -0
 - data/ext/openssl/ossl_config.h +16 -0
 - data/ext/openssl/ossl_digest.c +425 -0
 - data/ext/openssl/ossl_digest.h +20 -0
 - data/ext/openssl/ossl_engine.c +568 -0
 - data/ext/openssl/ossl_engine.h +19 -0
 - data/ext/openssl/ossl_hmac.c +310 -0
 - data/ext/openssl/ossl_hmac.h +18 -0
 - data/ext/openssl/ossl_kdf.c +311 -0
 - data/ext/openssl/ossl_kdf.h +6 -0
 - data/ext/openssl/ossl_ns_spki.c +405 -0
 - data/ext/openssl/ossl_ns_spki.h +19 -0
 - data/ext/openssl/ossl_ocsp.c +1965 -0
 - data/ext/openssl/ossl_ocsp.h +23 -0
 - data/ext/openssl/ossl_pkcs12.c +275 -0
 - data/ext/openssl/ossl_pkcs12.h +13 -0
 - data/ext/openssl/ossl_pkcs7.c +1081 -0
 - data/ext/openssl/ossl_pkcs7.h +36 -0
 - data/ext/openssl/ossl_pkey.c +1624 -0
 - data/ext/openssl/ossl_pkey.h +204 -0
 - data/ext/openssl/ossl_pkey_dh.c +440 -0
 - data/ext/openssl/ossl_pkey_dsa.c +359 -0
 - data/ext/openssl/ossl_pkey_ec.c +1655 -0
 - data/ext/openssl/ossl_pkey_rsa.c +579 -0
 - data/ext/openssl/ossl_rand.c +200 -0
 - data/ext/openssl/ossl_rand.h +18 -0
 - data/ext/openssl/ossl_ssl.c +3142 -0
 - data/ext/openssl/ossl_ssl.h +36 -0
 - data/ext/openssl/ossl_ssl_session.c +331 -0
 - data/ext/openssl/ossl_ts.c +1539 -0
 - data/ext/openssl/ossl_ts.h +16 -0
 - data/ext/openssl/ossl_x509.c +256 -0
 - data/ext/openssl/ossl_x509.h +115 -0
 - data/ext/openssl/ossl_x509attr.c +324 -0
 - data/ext/openssl/ossl_x509cert.c +1002 -0
 - data/ext/openssl/ossl_x509crl.c +545 -0
 - data/ext/openssl/ossl_x509ext.c +490 -0
 - data/ext/openssl/ossl_x509name.c +597 -0
 - data/ext/openssl/ossl_x509req.c +444 -0
 - data/ext/openssl/ossl_x509revoked.c +300 -0
 - data/ext/openssl/ossl_x509store.c +986 -0
 - data/ext/zigrb_100doors/build.zig +0 -12
 - data/ext/zigrb_100doors/extconf.rb +2 -19
 - data/ext/zigrb_ackermann/build.zig +0 -12
 - data/ext/zigrb_ackermann/extconf.rb +2 -19
 - data/ext/zigrb_lucas_lehmer/build.zig +0 -12
 - data/ext/zigrb_lucas_lehmer/extconf.rb +2 -19
 - data/lib/zig_example/version.rb +1 -1
 - metadata +56 -2
 
    
        data/ext/openssl/ossl.h
    ADDED
    
    | 
         @@ -0,0 +1,201 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /*
         
     | 
| 
      
 2 
     | 
    
         
            +
             * 'OpenSSL for Ruby' project
         
     | 
| 
      
 3 
     | 
    
         
            +
             * Copyright (C) 2001-2002  Michal Rokos <m.rokos@sh.cvut.cz>
         
     | 
| 
      
 4 
     | 
    
         
            +
             * All rights reserved.
         
     | 
| 
      
 5 
     | 
    
         
            +
             */
         
     | 
| 
      
 6 
     | 
    
         
            +
            /*
         
     | 
| 
      
 7 
     | 
    
         
            +
             * This program is licensed under the same licence as Ruby.
         
     | 
| 
      
 8 
     | 
    
         
            +
             * (See the file 'LICENCE'.)
         
     | 
| 
      
 9 
     | 
    
         
            +
             */
         
     | 
| 
      
 10 
     | 
    
         
            +
            #if !defined(_OSSL_H_)
         
     | 
| 
      
 11 
     | 
    
         
            +
            #define _OSSL_H_
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            #include RUBY_EXTCONF_H
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            #include <assert.h>
         
     | 
| 
      
 16 
     | 
    
         
            +
            #include <ruby.h>
         
     | 
| 
      
 17 
     | 
    
         
            +
            #include <errno.h>
         
     | 
| 
      
 18 
     | 
    
         
            +
            #include <ruby/io.h>
         
     | 
| 
      
 19 
     | 
    
         
            +
            #include <ruby/thread.h>
         
     | 
| 
      
 20 
     | 
    
         
            +
            #include <openssl/opensslv.h>
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            #include <openssl/err.h>
         
     | 
| 
      
 23 
     | 
    
         
            +
            #include <openssl/asn1.h>
         
     | 
| 
      
 24 
     | 
    
         
            +
            #include <openssl/x509v3.h>
         
     | 
| 
      
 25 
     | 
    
         
            +
            #include <openssl/ssl.h>
         
     | 
| 
      
 26 
     | 
    
         
            +
            #include <openssl/pkcs12.h>
         
     | 
| 
      
 27 
     | 
    
         
            +
            #include <openssl/pkcs7.h>
         
     | 
| 
      
 28 
     | 
    
         
            +
            #include <openssl/rand.h>
         
     | 
| 
      
 29 
     | 
    
         
            +
            #include <openssl/conf.h>
         
     | 
| 
      
 30 
     | 
    
         
            +
            #ifndef OPENSSL_NO_TS
         
     | 
| 
      
 31 
     | 
    
         
            +
              #include <openssl/ts.h>
         
     | 
| 
      
 32 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 33 
     | 
    
         
            +
            #include <openssl/crypto.h>
         
     | 
| 
      
 34 
     | 
    
         
            +
            #if !defined(OPENSSL_NO_OCSP)
         
     | 
| 
      
 35 
     | 
    
         
            +
            #  include <openssl/ocsp.h>
         
     | 
| 
      
 36 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 37 
     | 
    
         
            +
            #include <openssl/bn.h>
         
     | 
| 
      
 38 
     | 
    
         
            +
            #include <openssl/rsa.h>
         
     | 
| 
      
 39 
     | 
    
         
            +
            #include <openssl/dsa.h>
         
     | 
| 
      
 40 
     | 
    
         
            +
            #include <openssl/evp.h>
         
     | 
| 
      
 41 
     | 
    
         
            +
            #include <openssl/dh.h>
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            #ifndef LIBRESSL_VERSION_NUMBER
         
     | 
| 
      
 44 
     | 
    
         
            +
            # define OSSL_IS_LIBRESSL 0
         
     | 
| 
      
 45 
     | 
    
         
            +
            # define OSSL_OPENSSL_PREREQ(maj, min, pat) \
         
     | 
| 
      
 46 
     | 
    
         
            +
                  (OPENSSL_VERSION_NUMBER >= ((maj << 28) | (min << 20) | (pat << 12)))
         
     | 
| 
      
 47 
     | 
    
         
            +
            # define OSSL_LIBRESSL_PREREQ(maj, min, pat) 0
         
     | 
| 
      
 48 
     | 
    
         
            +
            #else
         
     | 
| 
      
 49 
     | 
    
         
            +
            # define OSSL_IS_LIBRESSL 1
         
     | 
| 
      
 50 
     | 
    
         
            +
            # define OSSL_OPENSSL_PREREQ(maj, min, pat) 0
         
     | 
| 
      
 51 
     | 
    
         
            +
            # define OSSL_LIBRESSL_PREREQ(maj, min, pat) \
         
     | 
| 
      
 52 
     | 
    
         
            +
                  (LIBRESSL_VERSION_NUMBER >= ((maj << 28) | (min << 20) | (pat << 12)))
         
     | 
| 
      
 53 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            #if OSSL_OPENSSL_PREREQ(3, 0, 0)
         
     | 
| 
      
 56 
     | 
    
         
            +
            # define OSSL_3_const const
         
     | 
| 
      
 57 
     | 
    
         
            +
            #else
         
     | 
| 
      
 58 
     | 
    
         
            +
            # define OSSL_3_const /* const */
         
     | 
| 
      
 59 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            #if !defined(OPENSSL_NO_ENGINE) && !OSSL_OPENSSL_PREREQ(3, 0, 0)
         
     | 
| 
      
 62 
     | 
    
         
            +
            # define OSSL_USE_ENGINE
         
     | 
| 
      
 63 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            /*
         
     | 
| 
      
 66 
     | 
    
         
            +
             * Common Module
         
     | 
| 
      
 67 
     | 
    
         
            +
             */
         
     | 
| 
      
 68 
     | 
    
         
            +
            extern VALUE mOSSL;
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            /*
         
     | 
| 
      
 71 
     | 
    
         
            +
             * Common Error Class
         
     | 
| 
      
 72 
     | 
    
         
            +
             */
         
     | 
| 
      
 73 
     | 
    
         
            +
            extern VALUE eOSSLError;
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            /*
         
     | 
| 
      
 76 
     | 
    
         
            +
             * CheckTypes
         
     | 
| 
      
 77 
     | 
    
         
            +
             */
         
     | 
| 
      
 78 
     | 
    
         
            +
            #define OSSL_Check_Kind(obj, klass) do {\
         
     | 
| 
      
 79 
     | 
    
         
            +
              if (!rb_obj_is_kind_of((obj), (klass))) {\
         
     | 
| 
      
 80 
     | 
    
         
            +
                ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
         
     | 
| 
      
 81 
     | 
    
         
            +
                           rb_obj_class(obj), (klass));\
         
     | 
| 
      
 82 
     | 
    
         
            +
              }\
         
     | 
| 
      
 83 
     | 
    
         
            +
            } while (0)
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            /*
         
     | 
| 
      
 86 
     | 
    
         
            +
             * Type conversions
         
     | 
| 
      
 87 
     | 
    
         
            +
             */
         
     | 
| 
      
 88 
     | 
    
         
            +
            #if !defined(NUM2UINT64T) /* in case Ruby starts to provide */
         
     | 
| 
      
 89 
     | 
    
         
            +
            #  if SIZEOF_LONG == 8
         
     | 
| 
      
 90 
     | 
    
         
            +
            #    define NUM2UINT64T(x) ((uint64_t)NUM2ULONG(x))
         
     | 
| 
      
 91 
     | 
    
         
            +
            #  elif defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
         
     | 
| 
      
 92 
     | 
    
         
            +
            #    define NUM2UINT64T(x) ((uint64_t)NUM2ULL(x))
         
     | 
| 
      
 93 
     | 
    
         
            +
            #  else
         
     | 
| 
      
 94 
     | 
    
         
            +
            #    error "unknown platform; no 64-bit width integer"
         
     | 
| 
      
 95 
     | 
    
         
            +
            #  endif
         
     | 
| 
      
 96 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
            /*
         
     | 
| 
      
 99 
     | 
    
         
            +
             * Data Conversion
         
     | 
| 
      
 100 
     | 
    
         
            +
             */
         
     | 
| 
      
 101 
     | 
    
         
            +
            STACK_OF(X509) *ossl_x509_ary2sk(VALUE);
         
     | 
| 
      
 102 
     | 
    
         
            +
            STACK_OF(X509) *ossl_protect_x509_ary2sk(VALUE,int*);
         
     | 
| 
      
 103 
     | 
    
         
            +
            VALUE ossl_x509_sk2ary(const STACK_OF(X509) *certs);
         
     | 
| 
      
 104 
     | 
    
         
            +
            VALUE ossl_x509crl_sk2ary(const STACK_OF(X509_CRL) *crl);
         
     | 
| 
      
 105 
     | 
    
         
            +
            VALUE ossl_x509name_sk2ary(const STACK_OF(X509_NAME) *names);
         
     | 
| 
      
 106 
     | 
    
         
            +
            VALUE ossl_buf2str(char *buf, int len);
         
     | 
| 
      
 107 
     | 
    
         
            +
            VALUE ossl_str_new(const char *, long, int *);
         
     | 
| 
      
 108 
     | 
    
         
            +
            #define ossl_str_adjust(str, p) \
         
     | 
| 
      
 109 
     | 
    
         
            +
            do{\
         
     | 
| 
      
 110 
     | 
    
         
            +
                long newlen = (long)((p) - (unsigned char*)RSTRING_PTR(str));\
         
     | 
| 
      
 111 
     | 
    
         
            +
                assert(newlen <= RSTRING_LEN(str));\
         
     | 
| 
      
 112 
     | 
    
         
            +
                rb_str_set_len((str), newlen);\
         
     | 
| 
      
 113 
     | 
    
         
            +
            }while(0)
         
     | 
| 
      
 114 
     | 
    
         
            +
            /*
         
     | 
| 
      
 115 
     | 
    
         
            +
             * Convert binary string to hex string. The caller is responsible for
         
     | 
| 
      
 116 
     | 
    
         
            +
             * ensuring out has (2 * len) bytes of capacity.
         
     | 
| 
      
 117 
     | 
    
         
            +
             */
         
     | 
| 
      
 118 
     | 
    
         
            +
            void ossl_bin2hex(unsigned char *in, char *out, size_t len);
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            /*
         
     | 
| 
      
 121 
     | 
    
         
            +
             * Our default PEM callback
         
     | 
| 
      
 122 
     | 
    
         
            +
             */
         
     | 
| 
      
 123 
     | 
    
         
            +
            /* Convert the argument to String and validate the length. Note this may raise. */
         
     | 
| 
      
 124 
     | 
    
         
            +
            VALUE ossl_pem_passwd_value(VALUE);
         
     | 
| 
      
 125 
     | 
    
         
            +
            /* Can be casted to pem_password_cb. If a password (String) is passed as the
         
     | 
| 
      
 126 
     | 
    
         
            +
             * "arbitrary data" (typically the last parameter of PEM_{read,write}_
         
     | 
| 
      
 127 
     | 
    
         
            +
             * functions), uses the value. If not, but a block is given, yields to it.
         
     | 
| 
      
 128 
     | 
    
         
            +
             * If not either, fallbacks to PEM_def_callback() which reads from stdin. */
         
     | 
| 
      
 129 
     | 
    
         
            +
            int ossl_pem_passwd_cb(char *, int, int, void *);
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
            /*
         
     | 
| 
      
 132 
     | 
    
         
            +
             * Clear BIO* with this in PEM/DER fallback scenarios to avoid decoding
         
     | 
| 
      
 133 
     | 
    
         
            +
             * errors piling up in OpenSSL::Errors
         
     | 
| 
      
 134 
     | 
    
         
            +
             */
         
     | 
| 
      
 135 
     | 
    
         
            +
            #define OSSL_BIO_reset(bio) do { \
         
     | 
| 
      
 136 
     | 
    
         
            +
                (void)BIO_reset((bio)); \
         
     | 
| 
      
 137 
     | 
    
         
            +
                ossl_clear_error(); \
         
     | 
| 
      
 138 
     | 
    
         
            +
            } while (0)
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
            /*
         
     | 
| 
      
 141 
     | 
    
         
            +
             * ERRor messages
         
     | 
| 
      
 142 
     | 
    
         
            +
             */
         
     | 
| 
      
 143 
     | 
    
         
            +
            PRINTF_ARGS(NORETURN(void ossl_raise(VALUE, const char *, ...)), 2, 3);
         
     | 
| 
      
 144 
     | 
    
         
            +
            /* Make exception instance from str and OpenSSL error reason string. */
         
     | 
| 
      
 145 
     | 
    
         
            +
            VALUE ossl_make_error(VALUE exc, VALUE str);
         
     | 
| 
      
 146 
     | 
    
         
            +
            /* Clear OpenSSL error queue. If dOSSL is set, rb_warn() them. */
         
     | 
| 
      
 147 
     | 
    
         
            +
            void ossl_clear_error(void);
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
            /*
         
     | 
| 
      
 150 
     | 
    
         
            +
             * String to DER String
         
     | 
| 
      
 151 
     | 
    
         
            +
             */
         
     | 
| 
      
 152 
     | 
    
         
            +
            VALUE ossl_to_der(VALUE);
         
     | 
| 
      
 153 
     | 
    
         
            +
            VALUE ossl_to_der_if_possible(VALUE);
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
            /*
         
     | 
| 
      
 156 
     | 
    
         
            +
             * Debug
         
     | 
| 
      
 157 
     | 
    
         
            +
             */
         
     | 
| 
      
 158 
     | 
    
         
            +
            extern VALUE dOSSL;
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
            #if defined(HAVE_VA_ARGS_MACRO)
         
     | 
| 
      
 161 
     | 
    
         
            +
            #define OSSL_Debug(...) do { \
         
     | 
| 
      
 162 
     | 
    
         
            +
              if (dOSSL == Qtrue) { \
         
     | 
| 
      
 163 
     | 
    
         
            +
                fprintf(stderr, "OSSL_DEBUG: "); \
         
     | 
| 
      
 164 
     | 
    
         
            +
                fprintf(stderr, __VA_ARGS__); \
         
     | 
| 
      
 165 
     | 
    
         
            +
                fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \
         
     | 
| 
      
 166 
     | 
    
         
            +
              } \
         
     | 
| 
      
 167 
     | 
    
         
            +
            } while (0)
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
            #else
         
     | 
| 
      
 170 
     | 
    
         
            +
            void ossl_debug(const char *, ...);
         
     | 
| 
      
 171 
     | 
    
         
            +
            #define OSSL_Debug ossl_debug
         
     | 
| 
      
 172 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
            /*
         
     | 
| 
      
 175 
     | 
    
         
            +
             * Include all parts
         
     | 
| 
      
 176 
     | 
    
         
            +
             */
         
     | 
| 
      
 177 
     | 
    
         
            +
            #include "openssl_missing.h"
         
     | 
| 
      
 178 
     | 
    
         
            +
            #include "ossl_asn1.h"
         
     | 
| 
      
 179 
     | 
    
         
            +
            #include "ossl_bio.h"
         
     | 
| 
      
 180 
     | 
    
         
            +
            #include "ossl_bn.h"
         
     | 
| 
      
 181 
     | 
    
         
            +
            #include "ossl_cipher.h"
         
     | 
| 
      
 182 
     | 
    
         
            +
            #include "ossl_config.h"
         
     | 
| 
      
 183 
     | 
    
         
            +
            #include "ossl_digest.h"
         
     | 
| 
      
 184 
     | 
    
         
            +
            #include "ossl_hmac.h"
         
     | 
| 
      
 185 
     | 
    
         
            +
            #include "ossl_ns_spki.h"
         
     | 
| 
      
 186 
     | 
    
         
            +
            #include "ossl_ocsp.h"
         
     | 
| 
      
 187 
     | 
    
         
            +
            #include "ossl_pkcs12.h"
         
     | 
| 
      
 188 
     | 
    
         
            +
            #include "ossl_pkcs7.h"
         
     | 
| 
      
 189 
     | 
    
         
            +
            #include "ossl_pkey.h"
         
     | 
| 
      
 190 
     | 
    
         
            +
            #include "ossl_rand.h"
         
     | 
| 
      
 191 
     | 
    
         
            +
            #include "ossl_ssl.h"
         
     | 
| 
      
 192 
     | 
    
         
            +
            #ifndef OPENSSL_NO_TS
         
     | 
| 
      
 193 
     | 
    
         
            +
              #include "ossl_ts.h"
         
     | 
| 
      
 194 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 195 
     | 
    
         
            +
            #include "ossl_x509.h"
         
     | 
| 
      
 196 
     | 
    
         
            +
            #include "ossl_engine.h"
         
     | 
| 
      
 197 
     | 
    
         
            +
            #include "ossl_kdf.h"
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
            void Init_openssl(void);
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
            #endif /* _OSSL_H_ */
         
     |