[2914] MacRuby/trunk/ext/openssl
Revision: 2914 http://trac.macosforge.org/projects/ruby/changeset/2914 Author: lsansonetti@apple.com Date: 2009-10-28 18:52:18 -0700 (Wed, 28 Oct 2009) Log Message: ----------- more openssl work Modified Paths: -------------- MacRuby/trunk/ext/openssl/lib/openssl.rb MacRuby/trunk/ext/openssl/ossl_digest.c MacRuby/trunk/ext/openssl/ossl_pkey_rsa.c MacRuby/trunk/ext/openssl/ossl_x509cert.c MacRuby/trunk/ext/openssl/ossl_x509crl.c MacRuby/trunk/ext/openssl/ossl_x509name.c MacRuby/trunk/ext/openssl/ossl_x509req.c MacRuby/trunk/ext/openssl/ossl_x509store.c Modified: MacRuby/trunk/ext/openssl/lib/openssl.rb =================================================================== --- MacRuby/trunk/ext/openssl/lib/openssl.rb 2009-10-29 01:51:59 UTC (rev 2913) +++ MacRuby/trunk/ext/openssl/lib/openssl.rb 2009-10-29 01:52:18 UTC (rev 2914) @@ -14,7 +14,7 @@ $Id: openssl.rb 25189 2009-10-02 12:04:37Z akr $ =end -require 'openssl.so' +require 'openssl.bundle' require 'openssl/bn' require 'openssl/cipher' Modified: MacRuby/trunk/ext/openssl/ossl_digest.c =================================================================== --- MacRuby/trunk/ext/openssl/ossl_digest.c 2009-10-29 01:51:59 UTC (rev 2913) +++ MacRuby/trunk/ext/openssl/ossl_digest.c 2009-10-29 01:52:18 UTC (rev 2914) @@ -170,18 +170,24 @@ EVP_MD_CTX *ctx; VALUE str; +printf("ossl_digest_finish %p\n", (void *)self); + rb_scan_args(argc, argv, "01", &str); GetDigest(self, ctx); if (NIL_P(str)) { - str = rb_str_new(NULL, EVP_MD_CTX_size(ctx)); - } else { + str = rb_bytestring_new(); + } + else { StringValue(str); - rb_str_resize(str, EVP_MD_CTX_size(ctx)); + if (CLASS_OF(str) != rb_cByteString) { + rb_raise(rb_eArgError, "expected ByteString object"); + } } + rb_bytestring_resize(str, EVP_MD_CTX_size(ctx)); - EVP_DigestFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), NULL); + EVP_DigestFinal_ex(ctx, rb_bytestring_byte_pointer(str), NULL); return str; } Modified: MacRuby/trunk/ext/openssl/ossl_pkey_rsa.c =================================================================== --- MacRuby/trunk/ext/openssl/ossl_pkey_rsa.c 2009-10-29 01:51:59 UTC (rev 2913) +++ MacRuby/trunk/ext/openssl/ossl_pkey_rsa.c 2009-10-29 01:52:18 UTC (rev 2914) @@ -94,7 +94,7 @@ * */ static VALUE -ossl_rsa_s_generate(int argc, VALUE *argv, VALUE klass) +ossl_rsa_s_generate(VALUE klass, SEL sel, int argc, VALUE *argv) { /* why does this method exist? why can't initialize take an optional exponent? */ RSA *rsa; @@ -129,7 +129,7 @@ * * RSA.new(File.read("rsa.pem"), "mypassword") -> rsa */ static VALUE -ossl_rsa_initialize(int argc, VALUE *argv, VALUE self) +ossl_rsa_initialize(VALUE self, SEL sel, int argc, VALUE *argv) { EVP_PKEY *pkey; RSA *rsa; @@ -228,7 +228,7 @@ * * rsa.to_pem(cipher, pass) -> aString */ static VALUE -ossl_rsa_export(int argc, VALUE *argv, VALUE self) +ossl_rsa_export(VALUE self, SEL sel, int argc, VALUE *argv) { EVP_PKEY *pkey; BIO *out; @@ -304,7 +304,7 @@ * */ static VALUE -ossl_rsa_public_encrypt(int argc, VALUE *argv, VALUE self) +ossl_rsa_public_encrypt(VALUE self, SEL sel, int argc, VALUE *argv) { EVP_PKEY *pkey; int buf_len, pad; @@ -330,7 +330,7 @@ * */ static VALUE -ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self) +ossl_rsa_public_decrypt(VALUE self, SEL sel, int argc, VALUE *argv) { EVP_PKEY *pkey; int buf_len, pad; @@ -356,7 +356,7 @@ * */ static VALUE -ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self) +ossl_rsa_private_encrypt(VALUE self, SEL sel, int argc, VALUE *argv) { EVP_PKEY *pkey; int buf_len, pad; @@ -386,7 +386,7 @@ * */ static VALUE -ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self) +ossl_rsa_private_decrypt(VALUE self, SEL sel, int argc, VALUE *argv) { EVP_PKEY *pkey; int buf_len, pad; @@ -545,21 +545,21 @@ cRSA = rb_define_class_under(mPKey, "RSA", cPKey); - rb_define_singleton_method(cRSA, "generate", ossl_rsa_s_generate, -1); - rb_define_method(cRSA, "initialize", ossl_rsa_initialize, -1); + rb_objc_define_method(*(VALUE *)cRSA, "generate", ossl_rsa_s_generate, -1); + rb_objc_define_method(cRSA, "initialize", ossl_rsa_initialize, -1); - rb_define_method(cRSA, "public?", ossl_rsa_is_public, 0); - rb_define_method(cRSA, "private?", ossl_rsa_is_private, 0); - rb_define_method(cRSA, "to_text", ossl_rsa_to_text, 0); - rb_define_method(cRSA, "export", ossl_rsa_export, -1); + rb_objc_define_method(cRSA, "public?", ossl_rsa_is_public, 0); + rb_objc_define_method(cRSA, "private?", ossl_rsa_is_private, 0); + rb_objc_define_method(cRSA, "to_text", ossl_rsa_to_text, 0); + rb_objc_define_method(cRSA, "export", ossl_rsa_export, -1); rb_define_alias(cRSA, "to_pem", "export"); rb_define_alias(cRSA, "to_s", "export"); - rb_define_method(cRSA, "to_der", ossl_rsa_to_der, 0); - rb_define_method(cRSA, "public_key", ossl_rsa_to_public_key, 0); - rb_define_method(cRSA, "public_encrypt", ossl_rsa_public_encrypt, -1); - rb_define_method(cRSA, "public_decrypt", ossl_rsa_public_decrypt, -1); - rb_define_method(cRSA, "private_encrypt", ossl_rsa_private_encrypt, -1); - rb_define_method(cRSA, "private_decrypt", ossl_rsa_private_decrypt, -1); + rb_objc_define_method(cRSA, "to_der", ossl_rsa_to_der, 0); + rb_objc_define_method(cRSA, "public_key", ossl_rsa_to_public_key, 0); + rb_objc_define_method(cRSA, "public_encrypt", ossl_rsa_public_encrypt, -1); + rb_objc_define_method(cRSA, "public_decrypt", ossl_rsa_public_decrypt, -1); + rb_objc_define_method(cRSA, "private_encrypt", ossl_rsa_private_encrypt, -1); + rb_objc_define_method(cRSA, "private_decrypt", ossl_rsa_private_decrypt, -1); DEF_OSSL_PKEY_BN(cRSA, rsa, n); DEF_OSSL_PKEY_BN(cRSA, rsa, e); @@ -570,7 +570,7 @@ DEF_OSSL_PKEY_BN(cRSA, rsa, dmq1); DEF_OSSL_PKEY_BN(cRSA, rsa, iqmp); - rb_define_method(cRSA, "params", ossl_rsa_get_params, 0); + rb_objc_define_method(cRSA, "params", ossl_rsa_get_params, 0); DefRSAConst(PKCS1_PADDING); DefRSAConst(SSLV23_PADDING); Modified: MacRuby/trunk/ext/openssl/ossl_x509cert.c =================================================================== --- MacRuby/trunk/ext/openssl/ossl_x509cert.c 2009-10-29 01:51:59 UTC (rev 2913) +++ MacRuby/trunk/ext/openssl/ossl_x509cert.c 2009-10-29 01:52:18 UTC (rev 2914) @@ -131,7 +131,7 @@ * Certificate.new(string) => cert */ static VALUE -ossl_x509_initialize(int argc, VALUE *argv, VALUE self) +ossl_x509_initialize(VALUE self, SEL sel, int argc, VALUE *argv) { BIO *in; X509 *x509, *x = DATA_PTR(self); @@ -290,7 +290,7 @@ * cert.version = integer => integer */ static VALUE -ossl_x509_set_version(VALUE self, VALUE version) +ossl_x509_set_version(VALUE self, SEL sel, VALUE version) { X509 *x509; long ver; @@ -325,7 +325,7 @@ * cert.serial = integer => integer */ static VALUE -ossl_x509_set_serial(VALUE self, VALUE num) +ossl_x509_set_serial(VALUE self, SEL sel, VALUE num) { X509 *x509; @@ -384,7 +384,7 @@ * cert.subject = name => name */ static VALUE -ossl_x509_set_subject(VALUE self, VALUE subject) +ossl_x509_set_subject(VALUE self, SEL sel, VALUE subject) { X509 *x509; @@ -419,7 +419,7 @@ * cert.issuer = name => name */ static VALUE -ossl_x509_set_issuer(VALUE self, VALUE issuer) +ossl_x509_set_issuer(VALUE self, SEL sel, VALUE issuer) { X509 *x509; @@ -454,7 +454,7 @@ * cert.not_before = time => time */ static VALUE -ossl_x509_set_not_before(VALUE self, VALUE time) +ossl_x509_set_not_before(VALUE self, SEL sel, VALUE time) { X509 *x509; time_t sec; @@ -491,7 +491,7 @@ * cert.not_before = time => time */ static VALUE -ossl_x509_set_not_after(VALUE self, VALUE time) +ossl_x509_set_not_after(VALUE self, SEL sel, VALUE time) { X509 *x509; time_t sec; @@ -528,7 +528,7 @@ * cert.public_key = key => key */ static VALUE -ossl_x509_set_public_key(VALUE self, VALUE key) +ossl_x509_set_public_key(VALUE self, SEL sel, VALUE key) { X509 *x509; @@ -545,7 +545,7 @@ * cert.sign(key, digest) => self */ static VALUE -ossl_x509_sign(VALUE self, VALUE key, VALUE digest) +ossl_x509_sign(VALUE self, SEL sel, VALUE key, VALUE digest) { X509 *x509; EVP_PKEY *pkey; @@ -568,7 +568,7 @@ * Checks that cert signature is made with PRIVversion of this PUBLIC 'key' */ static VALUE -ossl_x509_verify(VALUE self, VALUE key) +ossl_x509_verify(VALUE self, SEL sel, VALUE key) { X509 *x509; EVP_PKEY *pkey; @@ -593,7 +593,7 @@ * Checks if 'key' is PRIV key for this cert */ static VALUE -ossl_x509_check_private_key(VALUE self, VALUE key) +ossl_x509_check_private_key(VALUE self, SEL sel, VALUE key) { X509 *x509; EVP_PKEY *pkey; @@ -640,7 +640,7 @@ * cert.extensions = [ext...] => [ext...] */ static VALUE -ossl_x509_set_extensions(VALUE self, VALUE ary) +ossl_x509_set_extensions(VALUE self, SEL sel, VALUE ary) { X509 *x509; X509_EXTENSION *ext; @@ -672,7 +672,7 @@ * cert.add_extension(extension) => extension */ static VALUE -ossl_x509_add_extension(VALUE self, VALUE extension) +ossl_x509_add_extension(VALUE self, SEL sel, VALUE extension) { X509 *x509; X509_EXTENSION *ext; @@ -732,35 +732,35 @@ cX509Cert = rb_define_class_under(mX509, "Certificate", rb_cObject); - rb_define_alloc_func(cX509Cert, ossl_x509_alloc); - rb_define_method(cX509Cert, "initialize", ossl_x509_initialize, -1); + rb_objc_define_method(*(VALUE *)cX509Cert, "alloc", ossl_x509_alloc, 0); + rb_objc_define_method(cX509Cert, "initialize", ossl_x509_initialize, -1); rb_define_copy_func(cX509Cert, ossl_x509_copy); - rb_define_method(cX509Cert, "to_der", ossl_x509_to_der, 0); - rb_define_method(cX509Cert, "to_pem", ossl_x509_to_pem, 0); + rb_objc_define_method(cX509Cert, "to_der", ossl_x509_to_der, 0); + rb_objc_define_method(cX509Cert, "to_pem", ossl_x509_to_pem, 0); rb_define_alias(cX509Cert, "to_s", "to_pem"); - rb_define_method(cX509Cert, "to_text", ossl_x509_to_text, 0); - rb_define_method(cX509Cert, "version", ossl_x509_get_version, 0); - rb_define_method(cX509Cert, "version=", ossl_x509_set_version, 1); - rb_define_method(cX509Cert, "signature_algorithm", ossl_x509_get_signature_algorithm, 0); - rb_define_method(cX509Cert, "serial", ossl_x509_get_serial, 0); - rb_define_method(cX509Cert, "serial=", ossl_x509_set_serial, 1); - rb_define_method(cX509Cert, "subject", ossl_x509_get_subject, 0); - rb_define_method(cX509Cert, "subject=", ossl_x509_set_subject, 1); - rb_define_method(cX509Cert, "issuer", ossl_x509_get_issuer, 0); - rb_define_method(cX509Cert, "issuer=", ossl_x509_set_issuer, 1); - rb_define_method(cX509Cert, "not_before", ossl_x509_get_not_before, 0); - rb_define_method(cX509Cert, "not_before=", ossl_x509_set_not_before, 1); - rb_define_method(cX509Cert, "not_after", ossl_x509_get_not_after, 0); - rb_define_method(cX509Cert, "not_after=", ossl_x509_set_not_after, 1); - rb_define_method(cX509Cert, "public_key", ossl_x509_get_public_key, 0); - rb_define_method(cX509Cert, "public_key=", ossl_x509_set_public_key, 1); - rb_define_method(cX509Cert, "sign", ossl_x509_sign, 2); - rb_define_method(cX509Cert, "verify", ossl_x509_verify, 1); - rb_define_method(cX509Cert, "check_private_key", ossl_x509_check_private_key, 1); - rb_define_method(cX509Cert, "extensions", ossl_x509_get_extensions, 0); - rb_define_method(cX509Cert, "extensions=", ossl_x509_set_extensions, 1); - rb_define_method(cX509Cert, "add_extension", ossl_x509_add_extension, 1); - rb_define_method(cX509Cert, "inspect", ossl_x509_inspect, 0); + rb_objc_define_method(cX509Cert, "to_text", ossl_x509_to_text, 0); + rb_objc_define_method(cX509Cert, "version", ossl_x509_get_version, 0); + rb_objc_define_method(cX509Cert, "version=", ossl_x509_set_version, 1); + rb_objc_define_method(cX509Cert, "signature_algorithm", ossl_x509_get_signature_algorithm, 0); + rb_objc_define_method(cX509Cert, "serial", ossl_x509_get_serial, 0); + rb_objc_define_method(cX509Cert, "serial=", ossl_x509_set_serial, 1); + rb_objc_define_method(cX509Cert, "subject", ossl_x509_get_subject, 0); + rb_objc_define_method(cX509Cert, "subject=", ossl_x509_set_subject, 1); + rb_objc_define_method(cX509Cert, "issuer", ossl_x509_get_issuer, 0); + rb_objc_define_method(cX509Cert, "issuer=", ossl_x509_set_issuer, 1); + rb_objc_define_method(cX509Cert, "not_before", ossl_x509_get_not_before, 0); + rb_objc_define_method(cX509Cert, "not_before=", ossl_x509_set_not_before, 1); + rb_objc_define_method(cX509Cert, "not_after", ossl_x509_get_not_after, 0); + rb_objc_define_method(cX509Cert, "not_after=", ossl_x509_set_not_after, 1); + rb_objc_define_method(cX509Cert, "public_key", ossl_x509_get_public_key, 0); + rb_objc_define_method(cX509Cert, "public_key=", ossl_x509_set_public_key, 1); + rb_objc_define_method(cX509Cert, "sign", ossl_x509_sign, 2); + rb_objc_define_method(cX509Cert, "verify", ossl_x509_verify, 1); + rb_objc_define_method(cX509Cert, "check_private_key", ossl_x509_check_private_key, 1); + rb_objc_define_method(cX509Cert, "extensions", ossl_x509_get_extensions, 0); + rb_objc_define_method(cX509Cert, "extensions=", ossl_x509_set_extensions, 1); + rb_objc_define_method(cX509Cert, "add_extension", ossl_x509_add_extension, 1); + rb_objc_define_method(cX509Cert, "inspect", ossl_x509_inspect, 0); } Modified: MacRuby/trunk/ext/openssl/ossl_x509crl.c =================================================================== --- MacRuby/trunk/ext/openssl/ossl_x509crl.c 2009-10-29 01:51:59 UTC (rev 2913) +++ MacRuby/trunk/ext/openssl/ossl_x509crl.c 2009-10-29 01:52:18 UTC (rev 2914) @@ -88,7 +88,7 @@ } static VALUE -ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self) +ossl_x509crl_initialize(VALUE self, SEL sel, int argc, VALUE *argv) { BIO *in; X509_CRL *crl, *x = DATA_PTR(self); @@ -143,7 +143,7 @@ } static VALUE -ossl_x509crl_set_version(VALUE self, VALUE version) +ossl_x509crl_set_version(VALUE self, SEL sel, VALUE version) { X509_CRL *crl; long ver; @@ -192,7 +192,7 @@ } static VALUE -ossl_x509crl_set_issuer(VALUE self, VALUE issuer) +ossl_x509crl_set_issuer(VALUE self, SEL sel, VALUE issuer) { X509_CRL *crl; @@ -215,7 +215,7 @@ } static VALUE -ossl_x509crl_set_last_update(VALUE self, VALUE time) +ossl_x509crl_set_last_update(VALUE self, SEL sel, VALUE time) { X509_CRL *crl; time_t sec; @@ -240,7 +240,7 @@ } static VALUE -ossl_x509crl_set_next_update(VALUE self, VALUE time) +ossl_x509crl_set_next_update(VALUE self, SEL sel, VALUE time) { X509_CRL *crl; time_t sec; @@ -281,7 +281,7 @@ } static VALUE -ossl_x509crl_set_revoked(VALUE self, VALUE ary) +ossl_x509crl_set_revoked(VALUE self, SEL sel, VALUE ary) { X509_CRL *crl; X509_REVOKED *rev; @@ -307,7 +307,7 @@ } static VALUE -ossl_x509crl_add_revoked(VALUE self, VALUE revoked) +ossl_x509crl_add_revoked(VALUE self, SEL sel, VALUE revoked) { X509_CRL *crl; X509_REVOKED *rev; @@ -323,7 +323,7 @@ } static VALUE -ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest) +ossl_x509crl_sign(VALUE self, SEL sel, VALUE key, VALUE digest) { X509_CRL *crl; EVP_PKEY *pkey; @@ -340,7 +340,7 @@ } static VALUE -ossl_x509crl_verify(VALUE self, VALUE key) +ossl_x509crl_verify(VALUE self, SEL sel, VALUE key) { X509_CRL *crl; int ret; @@ -455,7 +455,7 @@ * Sets X509_EXTENSIONs */ static VALUE -ossl_x509crl_set_extensions(VALUE self, VALUE ary) +ossl_x509crl_set_extensions(VALUE self, SEL sel, VALUE ary) { X509_CRL *crl; X509_EXTENSION *ext; @@ -482,7 +482,7 @@ } static VALUE -ossl_x509crl_add_extension(VALUE self, VALUE extension) +ossl_x509crl_add_extension(VALUE self, SEL sel, VALUE extension) { X509_CRL *crl; X509_EXTENSION *ext; @@ -508,30 +508,30 @@ cX509CRL = rb_define_class_under(mX509, "CRL", rb_cObject); - rb_define_alloc_func(cX509CRL, ossl_x509crl_alloc); - rb_define_method(cX509CRL, "initialize", ossl_x509crl_initialize, -1); + rb_objc_define_method(*(VALUE *)cX509CRL, "alloc", ossl_x509crl_alloc, 0); + rb_objc_define_method(cX509CRL, "initialize", ossl_x509crl_initialize, -1); rb_define_copy_func(cX509CRL, ossl_x509crl_copy); - rb_define_method(cX509CRL, "version", ossl_x509crl_get_version, 0); - rb_define_method(cX509CRL, "version=", ossl_x509crl_set_version, 1); - rb_define_method(cX509CRL, "signature_algorithm", ossl_x509crl_get_signature_algorithm, 0); - rb_define_method(cX509CRL, "issuer", ossl_x509crl_get_issuer, 0); - rb_define_method(cX509CRL, "issuer=", ossl_x509crl_set_issuer, 1); - rb_define_method(cX509CRL, "last_update", ossl_x509crl_get_last_update, 0); - rb_define_method(cX509CRL, "last_update=", ossl_x509crl_set_last_update, 1); - rb_define_method(cX509CRL, "next_update", ossl_x509crl_get_next_update, 0); - rb_define_method(cX509CRL, "next_update=", ossl_x509crl_set_next_update, 1); - rb_define_method(cX509CRL, "revoked", ossl_x509crl_get_revoked, 0); - rb_define_method(cX509CRL, "revoked=", ossl_x509crl_set_revoked, 1); - rb_define_method(cX509CRL, "add_revoked", ossl_x509crl_add_revoked, 1); - rb_define_method(cX509CRL, "sign", ossl_x509crl_sign, 2); - rb_define_method(cX509CRL, "verify", ossl_x509crl_verify, 1); - rb_define_method(cX509CRL, "to_der", ossl_x509crl_to_der, 0); - rb_define_method(cX509CRL, "to_pem", ossl_x509crl_to_pem, 0); + rb_objc_define_method(cX509CRL, "version", ossl_x509crl_get_version, 0); + rb_objc_define_method(cX509CRL, "version=", ossl_x509crl_set_version, 1); + rb_objc_define_method(cX509CRL, "signature_algorithm", ossl_x509crl_get_signature_algorithm, 0); + rb_objc_define_method(cX509CRL, "issuer", ossl_x509crl_get_issuer, 0); + rb_objc_define_method(cX509CRL, "issuer=", ossl_x509crl_set_issuer, 1); + rb_objc_define_method(cX509CRL, "last_update", ossl_x509crl_get_last_update, 0); + rb_objc_define_method(cX509CRL, "last_update=", ossl_x509crl_set_last_update, 1); + rb_objc_define_method(cX509CRL, "next_update", ossl_x509crl_get_next_update, 0); + rb_objc_define_method(cX509CRL, "next_update=", ossl_x509crl_set_next_update, 1); + rb_objc_define_method(cX509CRL, "revoked", ossl_x509crl_get_revoked, 0); + rb_objc_define_method(cX509CRL, "revoked=", ossl_x509crl_set_revoked, 1); + rb_objc_define_method(cX509CRL, "add_revoked", ossl_x509crl_add_revoked, 1); + rb_objc_define_method(cX509CRL, "sign", ossl_x509crl_sign, 2); + rb_objc_define_method(cX509CRL, "verify", ossl_x509crl_verify, 1); + rb_objc_define_method(cX509CRL, "to_der", ossl_x509crl_to_der, 0); + rb_objc_define_method(cX509CRL, "to_pem", ossl_x509crl_to_pem, 0); rb_define_alias(cX509CRL, "to_s", "to_pem"); - rb_define_method(cX509CRL, "to_text", ossl_x509crl_to_text, 0); - rb_define_method(cX509CRL, "extensions", ossl_x509crl_get_extensions, 0); - rb_define_method(cX509CRL, "extensions=", ossl_x509crl_set_extensions, 1); - rb_define_method(cX509CRL, "add_extension", ossl_x509crl_add_extension, 1); + rb_objc_define_method(cX509CRL, "to_text", ossl_x509crl_to_text, 0); + rb_objc_define_method(cX509CRL, "extensions", ossl_x509crl_get_extensions, 0); + rb_objc_define_method(cX509CRL, "extensions=", ossl_x509crl_set_extensions, 1); + rb_objc_define_method(cX509CRL, "add_extension", ossl_x509crl_add_extension, 1); } Modified: MacRuby/trunk/ext/openssl/ossl_x509name.c =================================================================== --- MacRuby/trunk/ext/openssl/ossl_x509name.c 2009-10-29 01:51:59 UTC (rev 2913) +++ MacRuby/trunk/ext/openssl/ossl_x509name.c 2009-10-29 01:52:18 UTC (rev 2914) @@ -88,7 +88,7 @@ } static int id_aref; -static VALUE ossl_x509name_add_entry(int, VALUE*, VALUE); +static VALUE ossl_x509name_add_entry(VALUE, SEL, int, VALUE*); #define rb_aref(obj, key) rb_funcall(obj, id_aref, 1, key) static VALUE @@ -104,7 +104,7 @@ entry[2] = rb_ary_entry(i, 2); if(NIL_P(entry[2])) entry[2] = rb_aref(template, entry[0]); if(NIL_P(entry[2])) entry[2] = DEFAULT_OBJECT_TYPE; - ossl_x509name_add_entry(3, entry, self); + ossl_x509name_add_entry(self, 0, 3, entry); return Qnil; } @@ -117,7 +117,7 @@ * X509::Name.new(dn, template) => name */ static VALUE -ossl_x509name_initialize(int argc, VALUE *argv, VALUE self) +ossl_x509name_initialize(VALUE self, SEL sel, int argc, VALUE *argv) { X509_NAME *name; VALUE arg, template; @@ -156,7 +156,7 @@ * name.add_entry(oid, value [, type]) => self */ static -VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self) +VALUE ossl_x509name_add_entry(VALUE self, SEL sel, int argc, VALUE *argv) { X509_NAME *name; VALUE oid, value, type; @@ -195,7 +195,7 @@ * name.to_s(integer) => string */ static VALUE -ossl_x509name_to_s(int argc, VALUE *argv, VALUE self) +ossl_x509name_to_s(VALUE self, SEL sel, int argc, VALUE *argv) { X509_NAME *name; VALUE flag, str; @@ -267,7 +267,7 @@ } static VALUE -ossl_x509name_cmp(VALUE self, VALUE other) +ossl_x509name_cmp(VALUE self, SEL sel, VALUE other) { int result; @@ -279,7 +279,7 @@ } static VALUE -ossl_x509name_eql(VALUE self, VALUE other) +ossl_x509name_eql(VALUE self, SEL sel, VALUE other) { int result; @@ -342,16 +342,16 @@ eX509NameError = rb_define_class_under(mX509, "NameError", eOSSLError); cX509Name = rb_define_class_under(mX509, "Name", rb_cObject); - rb_define_alloc_func(cX509Name, ossl_x509name_alloc); - rb_define_method(cX509Name, "initialize", ossl_x509name_initialize, -1); - rb_define_method(cX509Name, "add_entry", ossl_x509name_add_entry, -1); - rb_define_method(cX509Name, "to_s", ossl_x509name_to_s, -1); - rb_define_method(cX509Name, "to_a", ossl_x509name_to_a, 0); - rb_define_method(cX509Name, "cmp", ossl_x509name_cmp, 1); + rb_objc_define_method(*(VALUE *)cX509Name, "alloc", ossl_x509name_alloc, 0); + rb_objc_define_method(cX509Name, "initialize", ossl_x509name_initialize, -1); + rb_objc_define_method(cX509Name, "add_entry", ossl_x509name_add_entry, -1); + rb_objc_define_method(cX509Name, "to_s", ossl_x509name_to_s, -1); + rb_objc_define_method(cX509Name, "to_a", ossl_x509name_to_a, 0); + rb_objc_define_method(cX509Name, "cmp", ossl_x509name_cmp, 1); rb_define_alias(cX509Name, "<=>", "cmp"); - rb_define_method(cX509Name, "eql?", ossl_x509name_eql, 1); - rb_define_method(cX509Name, "hash", ossl_x509name_hash, 0); - rb_define_method(cX509Name, "to_der", ossl_x509name_to_der, 0); + rb_objc_define_method(cX509Name, "eql?", ossl_x509name_eql, 1); + rb_objc_define_method(cX509Name, "hash", ossl_x509name_hash, 0); + rb_objc_define_method(cX509Name, "to_der", ossl_x509name_to_der, 0); utf8str = INT2NUM(V_ASN1_UTF8STRING); ptrstr = INT2NUM(V_ASN1_PRINTABLESTRING); Modified: MacRuby/trunk/ext/openssl/ossl_x509req.c =================================================================== --- MacRuby/trunk/ext/openssl/ossl_x509req.c 2009-10-29 01:51:59 UTC (rev 2913) +++ MacRuby/trunk/ext/openssl/ossl_x509req.c 2009-10-29 01:52:18 UTC (rev 2914) @@ -96,7 +96,7 @@ } static VALUE -ossl_x509req_initialize(int argc, VALUE *argv, VALUE self) +ossl_x509req_initialize(VALUE self, SEL sel, int argc, VALUE *argv) { BIO *in; X509_REQ *req, *x = DATA_PTR(self); @@ -237,7 +237,7 @@ } static VALUE -ossl_x509req_set_version(VALUE self, VALUE version) +ossl_x509req_set_version(VALUE self, SEL sel, VALUE version) { X509_REQ *req; long ver; @@ -268,7 +268,7 @@ } static VALUE -ossl_x509req_set_subject(VALUE self, VALUE subject) +ossl_x509req_set_subject(VALUE self, SEL sel, VALUE subject) { X509_REQ *req; @@ -319,7 +319,7 @@ } static VALUE -ossl_x509req_set_public_key(VALUE self, VALUE key) +ossl_x509req_set_public_key(VALUE self, SEL sel, VALUE key) { X509_REQ *req; EVP_PKEY *pkey; @@ -334,7 +334,7 @@ } static VALUE -ossl_x509req_sign(VALUE self, VALUE key, VALUE digest) +ossl_x509req_sign(VALUE self, SEL sel, VALUE key, VALUE digest) { X509_REQ *req; EVP_PKEY *pkey; @@ -354,7 +354,7 @@ * Checks that cert signature is made with PRIVversion of this PUBLIC 'key' */ static VALUE -ossl_x509req_verify(VALUE self, VALUE key) +ossl_x509req_verify(VALUE self, SEL sel, VALUE key) { X509_REQ *req; EVP_PKEY *pkey; @@ -397,7 +397,7 @@ } static VALUE -ossl_x509req_set_attributes(VALUE self, VALUE ary) +ossl_x509req_set_attributes(VALUE self, SEL sel, VALUE ary) { X509_REQ *req; X509_ATTRIBUTE *attr; @@ -422,7 +422,7 @@ } static VALUE -ossl_x509req_add_attribute(VALUE self, VALUE attr) +ossl_x509req_add_attribute(VALUE self, SEL sel, VALUE attr) { X509_REQ *req; @@ -444,25 +444,25 @@ cX509Req = rb_define_class_under(mX509, "Request", rb_cObject); - rb_define_alloc_func(cX509Req, ossl_x509req_alloc); - rb_define_method(cX509Req, "initialize", ossl_x509req_initialize, -1); + rb_objc_define_method(*(VALUE *)cX509Req, "alloc", ossl_x509req_alloc, 0); + rb_objc_define_method(cX509Req, "initialize", ossl_x509req_initialize, -1); rb_define_copy_func(cX509Req, ossl_x509req_copy); - rb_define_method(cX509Req, "to_pem", ossl_x509req_to_pem, 0); - rb_define_method(cX509Req, "to_der", ossl_x509req_to_der, 0); + rb_objc_define_method(cX509Req, "to_pem", ossl_x509req_to_pem, 0); + rb_objc_define_method(cX509Req, "to_der", ossl_x509req_to_der, 0); rb_define_alias(cX509Req, "to_s", "to_pem"); - rb_define_method(cX509Req, "to_text", ossl_x509req_to_text, 0); - rb_define_method(cX509Req, "version", ossl_x509req_get_version, 0); - rb_define_method(cX509Req, "version=", ossl_x509req_set_version, 1); - rb_define_method(cX509Req, "subject", ossl_x509req_get_subject, 0); - rb_define_method(cX509Req, "subject=", ossl_x509req_set_subject, 1); - rb_define_method(cX509Req, "signature_algorithm", ossl_x509req_get_signature_algorithm, 0); - rb_define_method(cX509Req, "public_key", ossl_x509req_get_public_key, 0); - rb_define_method(cX509Req, "public_key=", ossl_x509req_set_public_key, 1); - rb_define_method(cX509Req, "sign", ossl_x509req_sign, 2); - rb_define_method(cX509Req, "verify", ossl_x509req_verify, 1); - rb_define_method(cX509Req, "attributes", ossl_x509req_get_attributes, 0); - rb_define_method(cX509Req, "attributes=", ossl_x509req_set_attributes, 1); - rb_define_method(cX509Req, "add_attribute", ossl_x509req_add_attribute, 1); + rb_objc_define_method(cX509Req, "to_text", ossl_x509req_to_text, 0); + rb_objc_define_method(cX509Req, "version", ossl_x509req_get_version, 0); + rb_objc_define_method(cX509Req, "version=", ossl_x509req_set_version, 1); + rb_objc_define_method(cX509Req, "subject", ossl_x509req_get_subject, 0); + rb_objc_define_method(cX509Req, "subject=", ossl_x509req_set_subject, 1); + rb_objc_define_method(cX509Req, "signature_algorithm", ossl_x509req_get_signature_algorithm, 0); + rb_objc_define_method(cX509Req, "public_key", ossl_x509req_get_public_key, 0); + rb_objc_define_method(cX509Req, "public_key=", ossl_x509req_set_public_key, 1); + rb_objc_define_method(cX509Req, "sign", ossl_x509req_sign, 2); + rb_objc_define_method(cX509Req, "verify", ossl_x509req_verify, 1); + rb_objc_define_method(cX509Req, "attributes", ossl_x509req_get_attributes, 0); + rb_objc_define_method(cX509Req, "attributes=", ossl_x509req_set_attributes, 1); + rb_objc_define_method(cX509Req, "add_attribute", ossl_x509req_add_attribute, 1); } Modified: MacRuby/trunk/ext/openssl/ossl_x509store.c =================================================================== --- MacRuby/trunk/ext/openssl/ossl_x509store.c 2009-10-29 01:51:59 UTC (rev 2913) +++ MacRuby/trunk/ext/openssl/ossl_x509store.c 2009-10-29 01:52:18 UTC (rev 2914) @@ -106,7 +106,7 @@ * General callback for OpenSSL verify */ static VALUE -ossl_x509store_set_vfy_cb(VALUE self, VALUE cb) +ossl_x509store_set_vfy_cb(VALUE self, SEL sel, VALUE cb) { X509_STORE *store; @@ -124,14 +124,14 @@ * */ static VALUE -ossl_x509store_initialize(int argc, VALUE *argv, VALUE self) +ossl_x509store_initialize(VALUE self, SEL sel, int argc, VALUE *argv) { X509_STORE *store; /* BUG: This method takes any number of arguments but appears to ignore them. */ GetX509Store(self, store); X509_STORE_set_verify_cb_func(store, ossl_verify_cb); - ossl_x509store_set_vfy_cb(self, Qnil); + ossl_x509store_set_vfy_cb(self, 0, Qnil); #if (OPENSSL_VERSION_NUMBER < 0x00907000L) rb_iv_set(self, "@flags", INT2NUM(0)); @@ -149,7 +149,7 @@ } static VALUE -ossl_x509store_set_flags(VALUE self, VALUE flags) +ossl_x509store_set_flags(VALUE self, SEL sel, VALUE flags) { #if (OPENSSL_VERSION_NUMBER >= 0x00907000L) X509_STORE *store; @@ -165,7 +165,7 @@ } static VALUE -ossl_x509store_set_purpose(VALUE self, VALUE purpose) +ossl_x509store_set_purpose(VALUE self, SEL sel, VALUE purpose) { #if (OPENSSL_VERSION_NUMBER >= 0x00907000L) X509_STORE *store; @@ -181,7 +181,7 @@ } static VALUE -ossl_x509store_set_trust(VALUE self, VALUE trust) +ossl_x509store_set_trust(VALUE self, SEL sel, VALUE trust) { #if (OPENSSL_VERSION_NUMBER >= 0x00907000L) X509_STORE *store; @@ -197,14 +197,14 @@ } static VALUE -ossl_x509store_set_time(VALUE self, VALUE time) +ossl_x509store_set_time(VALUE self, SEL sel, VALUE time) { rb_iv_set(self, "@time", time); return time; } static VALUE -ossl_x509store_add_file(VALUE self, VALUE file) +ossl_x509store_add_file(VALUE self, SEL sel, VALUE file) { X509_STORE *store; X509_LOOKUP *lookup; @@ -225,7 +225,7 @@ } static VALUE -ossl_x509store_add_path(VALUE self, VALUE dir) +ossl_x509store_add_path(VALUE self, SEL sel, VALUE dir) { X509_STORE *store; X509_LOOKUP *lookup; @@ -259,7 +259,7 @@ } static VALUE -ossl_x509store_add_cert(VALUE self, VALUE arg) +ossl_x509store_add_cert(VALUE self, SEL sel, VALUE arg) { X509_STORE *store; X509 *cert; @@ -274,7 +274,7 @@ } static VALUE -ossl_x509store_add_crl(VALUE self, VALUE arg) +ossl_x509store_add_crl(VALUE self, SEL sel, VALUE arg) { X509_STORE *store; X509_CRL *crl; @@ -293,7 +293,7 @@ static VALUE ossl_x509stctx_get_chain(VALUE); static VALUE -ossl_x509store_verify(int argc, VALUE *argv, VALUE self) +ossl_x509store_verify(VALUE self, SEL sel, int argc, VALUE *argv) { VALUE cert, chain; VALUE ctx, proc, result; @@ -363,13 +363,13 @@ return obj; } -static VALUE ossl_x509stctx_set_flags(VALUE, VALUE); -static VALUE ossl_x509stctx_set_purpose(VALUE, VALUE); -static VALUE ossl_x509stctx_set_trust(VALUE, VALUE); -static VALUE ossl_x509stctx_set_time(VALUE, VALUE); +static VALUE ossl_x509stctx_set_flags(VALUE, SEL, VALUE); +static VALUE ossl_x509stctx_set_purpose(VALUE, SEL, VALUE); +static VALUE ossl_x509stctx_set_trust(VALUE, SEL, VALUE); +static VALUE ossl_x509stctx_set_time(VALUE, SEL, VALUE); static VALUE -ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self) +ossl_x509stctx_initialize(VALUE self, SEL sel, int argc, VALUE *argv) { VALUE store, cert, chain, t; X509_STORE_CTX *ctx; @@ -389,12 +389,12 @@ } #else X509_STORE_CTX_init(ctx, x509st, x509, x509s); - ossl_x509stctx_set_flags(self, rb_iv_get(store, "@flags")); - ossl_x509stctx_set_purpose(self, rb_iv_get(store, "@purpose")); - ossl_x509stctx_set_trust(self, rb_iv_get(store, "@trust")); + ossl_x509stctx_set_flags(self, 0, rb_iv_get(store, "@flags")); + ossl_x509stctx_set_purpose(self, 0, rb_iv_get(store, "@purpose")); + ossl_x509stctx_set_trust(self, 0, rb_iv_get(store, "@trust")); #endif if (!NIL_P(t = rb_iv_get(store, "@time"))) - ossl_x509stctx_set_time(self, t); + ossl_x509stctx_set_time(self, 0, t); rb_iv_set(self, "@verify_callback", rb_iv_get(store, "@verify_callback")); rb_iv_set(self, "@cert", cert); @@ -452,7 +452,7 @@ } static VALUE -ossl_x509stctx_set_error(VALUE self, VALUE err) +ossl_x509stctx_set_error(VALUE self, SEL sel, VALUE err) { X509_STORE_CTX *ctx; @@ -521,7 +521,7 @@ } static VALUE -ossl_x509stctx_set_flags(VALUE self, VALUE flags) +ossl_x509stctx_set_flags(VALUE self, SEL sel, VALUE flags) { X509_STORE_CTX *store; long f = NUM2LONG(flags); @@ -533,7 +533,7 @@ } static VALUE -ossl_x509stctx_set_purpose(VALUE self, VALUE purpose) +ossl_x509stctx_set_purpose(VALUE self, SEL sel, VALUE purpose) { X509_STORE_CTX *store; long p = NUM2LONG(purpose); @@ -545,7 +545,7 @@ } static VALUE -ossl_x509stctx_set_trust(VALUE self, VALUE trust) +ossl_x509stctx_set_trust(VALUE self, SEL sel, VALUE trust) { X509_STORE_CTX *store; long t = NUM2LONG(trust); @@ -561,7 +561,7 @@ * storectx.time = time => time */ static VALUE -ossl_x509stctx_set_time(VALUE self, VALUE time) +ossl_x509stctx_set_time(VALUE self, SEL sel, VALUE time) { X509_STORE_CTX *store; long t; @@ -588,36 +588,36 @@ rb_attr(cX509Store, rb_intern("error"), 1, 0, Qfalse); rb_attr(cX509Store, rb_intern("error_string"), 1, 0, Qfalse); rb_attr(cX509Store, rb_intern("chain"), 1, 0, Qfalse); - rb_define_alloc_func(cX509Store, ossl_x509store_alloc); - rb_define_method(cX509Store, "initialize", ossl_x509store_initialize, -1); - rb_define_method(cX509Store, "verify_callback=", ossl_x509store_set_vfy_cb, 1); - rb_define_method(cX509Store, "flags=", ossl_x509store_set_flags, 1); - rb_define_method(cX509Store, "purpose=", ossl_x509store_set_purpose, 1); - rb_define_method(cX509Store, "trust=", ossl_x509store_set_trust, 1); - rb_define_method(cX509Store, "time=", ossl_x509store_set_time, 1); - rb_define_method(cX509Store, "add_path", ossl_x509store_add_path, 1); - rb_define_method(cX509Store, "add_file", ossl_x509store_add_file, 1); - rb_define_method(cX509Store, "set_default_paths", ossl_x509store_set_default_paths, 0); - rb_define_method(cX509Store, "add_cert", ossl_x509store_add_cert, 1); - rb_define_method(cX509Store, "add_crl", ossl_x509store_add_crl, 1); - rb_define_method(cX509Store, "verify", ossl_x509store_verify, -1); + rb_objc_define_method(*(VALUE *)cX509Store, "alloc", ossl_x509store_alloc, 0); + rb_objc_define_method(cX509Store, "initialize", ossl_x509store_initialize, -1); + rb_objc_define_method(cX509Store, "verify_callback=", ossl_x509store_set_vfy_cb, 1); + rb_objc_define_method(cX509Store, "flags=", ossl_x509store_set_flags, 1); + rb_objc_define_method(cX509Store, "purpose=", ossl_x509store_set_purpose, 1); + rb_objc_define_method(cX509Store, "trust=", ossl_x509store_set_trust, 1); + rb_objc_define_method(cX509Store, "time=", ossl_x509store_set_time, 1); + rb_objc_define_method(cX509Store, "add_path", ossl_x509store_add_path, 1); + rb_objc_define_method(cX509Store, "add_file", ossl_x509store_add_file, 1); + rb_objc_define_method(cX509Store, "set_default_paths", ossl_x509store_set_default_paths, 0); + rb_objc_define_method(cX509Store, "add_cert", ossl_x509store_add_cert, 1); + rb_objc_define_method(cX509Store, "add_crl", ossl_x509store_add_crl, 1); + rb_objc_define_method(cX509Store, "verify", ossl_x509store_verify, -1); cX509StoreContext = rb_define_class_under(mX509,"StoreContext",rb_cObject); x509stctx = cX509StoreContext; - rb_define_alloc_func(cX509StoreContext, ossl_x509stctx_alloc); - rb_define_method(x509stctx,"initialize", ossl_x509stctx_initialize, -1); - rb_define_method(x509stctx,"verify", ossl_x509stctx_verify, 0); - rb_define_method(x509stctx,"chain", ossl_x509stctx_get_chain,0); - rb_define_method(x509stctx,"error", ossl_x509stctx_get_err, 0); - rb_define_method(x509stctx,"error=", ossl_x509stctx_set_error, 1); - rb_define_method(x509stctx,"error_string",ossl_x509stctx_get_err_string,0); - rb_define_method(x509stctx,"error_depth", ossl_x509stctx_get_err_depth, 0); - rb_define_method(x509stctx,"current_cert",ossl_x509stctx_get_curr_cert, 0); - rb_define_method(x509stctx,"current_crl", ossl_x509stctx_get_curr_crl, 0); - rb_define_method(x509stctx,"cleanup", ossl_x509stctx_cleanup, 0); - rb_define_method(x509stctx,"flags=", ossl_x509stctx_set_flags, 1); - rb_define_method(x509stctx,"purpose=", ossl_x509stctx_set_purpose, 1); - rb_define_method(x509stctx,"trust=", ossl_x509stctx_set_trust, 1); - rb_define_method(x509stctx,"time=", ossl_x509stctx_set_time, 1); + rb_objc_define_method(*(VALUE *)cX509StoreContext, "alloc", ossl_x509stctx_alloc, 0); + rb_objc_define_method(x509stctx,"initialize", ossl_x509stctx_initialize, -1); + rb_objc_define_method(x509stctx,"verify", ossl_x509stctx_verify, 0); + rb_objc_define_method(x509stctx,"chain", ossl_x509stctx_get_chain,0); + rb_objc_define_method(x509stctx,"error", ossl_x509stctx_get_err, 0); + rb_objc_define_method(x509stctx,"error=", ossl_x509stctx_set_error, 1); + rb_objc_define_method(x509stctx,"error_string",ossl_x509stctx_get_err_string,0); + rb_objc_define_method(x509stctx,"error_depth", ossl_x509stctx_get_err_depth, 0); + rb_objc_define_method(x509stctx,"current_cert",ossl_x509stctx_get_curr_cert, 0); + rb_objc_define_method(x509stctx,"current_crl", ossl_x509stctx_get_curr_crl, 0); + rb_objc_define_method(x509stctx,"cleanup", ossl_x509stctx_cleanup, 0); + rb_objc_define_method(x509stctx,"flags=", ossl_x509stctx_set_flags, 1); + rb_objc_define_method(x509stctx,"purpose=", ossl_x509stctx_set_purpose, 1); + rb_objc_define_method(x509stctx,"trust=", ossl_x509stctx_set_trust, 1); + rb_objc_define_method(x509stctx,"time=", ossl_x509stctx_set_time, 1); }
participants (1)
-
source_changes@macosforge.org