diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2001-11-18 19:00:06 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2001-11-18 19:00:06 +0000 |
commit | dd5dc9508d397e96ee4aa849f411567e78b49e32 (patch) | |
tree | da9f0f10e1cb9c0c4533b7fd28a071ff82c22154 | |
parent | 48053b2987e812c63e1c5dd1d60d311886767ee3 (diff) | |
download | ruby-openssl-history-dd5dc9508d397e96ee4aa849f411567e78b49e32.tar.gz |
Released as 0.0.9
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | README | 37 | ||||
-rw-r--r-- | openssl_missing.h | 4 | ||||
-rw-r--r-- | ossl.c | 21 | ||||
-rw-r--r-- | ossl_cipher.c | 1 | ||||
-rw-r--r-- | ossl_pkcs7.c | 2 | ||||
-rw-r--r-- | ossl_pkey_dsa.c | 5 | ||||
-rw-r--r-- | ossl_pkey_rsa.c | 5 |
8 files changed, 66 insertions, 13 deletions
@@ -3,6 +3,10 @@ $Id$ Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz> All rights reserved. +2001/11/18 (ossl-0.0.9) + * all project is moved to savannah.gnu.org + * applied patch to make yielding optional (GOTOU Yuuzou - thanks!) + 2001/11/17 * ossl_version.h - new file * SSL::VERSION and SSL::OPENSSL_VERSION went under OpenSSL @@ -23,7 +23,7 @@ This program is licenced under the same licence as Ruby. = Cipher::... - various ciphers = basic PRNG functions (random generator) for OpenSSL module and class Random = SSLSocket (merged Gotou Yuuzou's SSLsocket-Ruby project) -= PKCS7 (first try) += PKCS7 (signing&data_verify is working, rest needs some testing) [To-Do] = check for memory leaking :-)) @@ -66,14 +66,14 @@ OpenSSL:: Random .seed(String) => true|false - .load_random_file(Filename) => true|false - .write_random_file(Filename) => true|false + .load_random_file(String (filename)) => true|false + .write_random_file(String (filename)) => true|false .random_bytes(size) => String Cipher:: constants: UNSPEC - ECB, CFB, OFB, CBC (modes) - EDE, EDE3, BIT40, BIT64 (types) + modes: ECB, CFB, OFB, CBC + types: EDE, EDE3, BIT40, BIT64 BlowFish (allowed: ECB, CFB, OFB, CBC) Cast5 (ECB, CFB, OFB, CBC) @@ -116,11 +116,32 @@ OpenSSL:: .sign(PKey, Digest) => self .verify(PKey) => true|false .challenge => String - .challenge(String) => String + .challenge=(String) => String + + PKCS7:: + constants: SIGNED, ENVELOPED, SIGNED_ENVELOPED + + PKCS7 + .new(CONST|String (PEM)) => self + .add_signer(PKey::Any (private), PKCS7::Signer) + .signers => Ary of PKCS7::Signer + .cipher=(Cipher::Any) => Cipher + .add_recipient(X509::Certificate) => self + .add_certificate(X509::Certificate) => self + .add_crl(X509::CRL) => self + .add_data(String (data), [true|false] (detached)) => self + .verify_data(X509::Store, [String] (detached)) => true|false, yields PKCS7::Signer + .decode_data(PKey::Any (private), X509::Certificate) => String + .to_pem => String (PEM) + Signer + .new(PKey::Any (private), X509::Certificate, Digest::Any) => self + .name => X509::Name + .serial => FixNum + .signed_time => Time PKey:: DSA - .new([keylen | String (PEM)]) => self + .new([keylen | String (PEM)]) => self, yields |p,n| when generating new .public? => true|false .private? => true|false .to_str => String @@ -134,7 +155,7 @@ OpenSSL:: .verify_digest(String (dig), String (sig)) => true|false RSA - .new([keylen | String (PEM)]) => self + .new([keylen | String (PEM)]) => self, yields |p,n| when generating new .public? => true|false .private? => true|false .to_str => String diff --git a/openssl_missing.h b/openssl_missing.h index 0b14a8b..4c8f24d 100644 --- a/openssl_missing.h +++ b/openssl_missing.h @@ -15,18 +15,22 @@ */ /* to pem.h */ +#ifndef NO_DSA #define PEM_read_bio_DSAPublicKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ (char *(*)())d2i_DSAPublicKey,PEM_STRING_DSA_PUBLIC,bp,(char **)x,cb,u) #define PEM_write_bio_DSAPublicKey(bp,x) \ PEM_ASN1_write_bio((int (*)())i2d_DSAPublicKey,\ PEM_STRING_DSA_PUBLIC,\ bp,(char *)x,NULL,NULL,0,NULL,NULL) +#endif /* to x509.h */ +#ifndef NO_DSA #define DSAPrivateKey_dup(dsa) (DSA *)ASN1_dup((int (*)())i2d_DSAPrivateKey, \ (char *(*)())d2i_DSAPrivateKey,(char *)dsa) #define DSAPublicKey_dup(dsa) (DSA *)ASN1_dup((int (*)())i2d_DSAPublicKey, \ (char *(*)())d2i_DSAPublicKey,(char *)dsa) +#endif /* to pkcs7.h */ #define PKCS7_SIGNER_INFO_dup(si) (PKCS7_SIGNER_INFO *)ASN1_dup((int (*)())i2d_PKCS7_SIGNER_INFO, \ @@ -19,6 +19,23 @@ void ossl_check_type(VALUE obj, VALUE klass) } } +/* + * Debug prints +#ifdef OSSL_DEBUG +inline char *ossl_error() { + char *ret = NULL, *err = NULL; + int err_len = NULL; + + err = ERR_error_string(ERR_get_error(), NULL); + ret = malloc(strlen(err)+strlen(__FILE__)+(sizeof(__LINE__)*3)+5); + sprintf(ret, "%s [%s:%d]", err, __FILE__, __LINE__); + + return ret; +} +#else +#define ossl_error() ERR_error_string(ERR_get_error(), NULL) +#endif + */ char *ossl_error(void) { return ERR_error_string(ERR_get_error(), NULL); @@ -42,8 +59,8 @@ VALUE asn1time_to_time(ASN1_UTCTIME *time) default: rb_raise(rb_eTypeError, "unknown time format"); } - - return rb_time_new(mktime(&tm), 0); + /*return rb_time_new(mktime(gmtime(mktime(&tm))), 0); /* Is this correct? */ + return rb_time_new(mktime(&tm), 0); /* or this one? */ } /* diff --git a/ossl_cipher.c b/ossl_cipher.c index 4ec3b71..33b3260 100644 --- a/ossl_cipher.c +++ b/ossl_cipher.c @@ -19,6 +19,7 @@ } #define DefCipherConst(x) rb_define_const(mCipher, #x, INT2FIX(##x)) + /* * Constants */ diff --git a/ossl_pkcs7.c b/ossl_pkcs7.c index 320550b..1a9f7c9 100644 --- a/ossl_pkcs7.c +++ b/ossl_pkcs7.c @@ -608,7 +608,7 @@ void Init_PKCS7(VALUE mPKCS7) rb_define_singleton_method(cPKCS7, "new", ossl_pkcs7_s_new, -1); rb_define_method(cPKCS7, "initialize", ossl_pkcs7_initialize, -1); rb_define_method(cPKCS7, "add_signer", ossl_pkcs7_add_signer, 2); - rb_define_method(cPKCS7, "signer", ossl_pkcs7_get_signer, 0); + rb_define_method(cPKCS7, "signers", ossl_pkcs7_get_signer, 0); rb_define_method(cPKCS7, "cipher=", ossl_pkcs7_set_cipher, 1); rb_define_method(cPKCS7, "add_recipient", ossl_pkcs7_add_recipient, 1); rb_define_method(cPKCS7, "add_certificate", ossl_pkcs7_add_certificate, 1); diff --git a/ossl_pkey_dsa.c b/ossl_pkey_dsa.c index deb672e..bfb35cc 100644 --- a/ossl_pkey_dsa.c +++ b/ossl_pkey_dsa.c @@ -154,6 +154,7 @@ static VALUE ossl_dsa_initialize(int argc, VALUE *argv, VALUE self) unsigned long h = 0; BIO *in = NULL; char *passwd = NULL; + void (*cb)() = NULL; VALUE buffer, pass; GetDSA_unsafe(self, dsap); @@ -169,7 +170,9 @@ static VALUE ossl_dsa_initialize(int argc, VALUE *argv, VALUE self) if (!RAND_bytes(seed, seed_len)) { rb_raise(eDSAError, "%s", ossl_error()); } - if (!(dsa = DSA_generate_parameters(FIX2INT(buffer), seed, seed_len, &counter, &h, ossl_dsa_generate_cb, NULL))) { /* arg to cb = NULL */ + if (rb_block_given_p()) + cb = ossl_dsa_generate_cb; + if (!(dsa = DSA_generate_parameters(FIX2INT(buffer), seed, seed_len, &counter, &h, cb, NULL))) { /* arg to cb = NULL */ rb_raise(eDSAError, "%s", ossl_error()); } if (!DSA_generate_key(dsa)) { diff --git a/ossl_pkey_rsa.c b/ossl_pkey_rsa.c index 9184c71..c8d9937 100644 --- a/ossl_pkey_rsa.c +++ b/ossl_pkey_rsa.c @@ -152,6 +152,7 @@ static VALUE ossl_rsa_initialize(int argc, VALUE *argv, VALUE self) int type = 0; BIO *in = NULL; char *passwd = NULL; + void (*cb)() = NULL; VALUE buffer, pass; GetRSA_unsafe(self, rsap); @@ -164,7 +165,9 @@ static VALUE ossl_rsa_initialize(int argc, VALUE *argv, VALUE self) } } else switch (TYPE(buffer)) { case T_FIXNUM: - if (!(rsa = RSA_generate_key(FIX2INT(buffer), RSA_F4, ossl_rsa_generate_cb, NULL))) { /* arg to cb = NULL */ + if (rb_block_given_p()) + cb = ossl_rsa_generate_cb; + if (!(rsa = RSA_generate_key(FIX2INT(buffer), RSA_F4, cb, NULL))) { /* arg to cb = NULL */ rb_raise(eRSAError, "%s", ossl_error()); } break; |