summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl.c
diff options
context:
space:
mode:
authormichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-12 13:46:48 +0000
committermichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-12 13:46:48 +0000
commitbd96b4c8ccbfbaf68c6996d74515fd603b2aea63 (patch)
tree7585c4dabc044459b4cfb92230bdff20fb882087 /ext/openssl/ossl.c
parentecf0c48d5a8308500f2331287fe88c88d6c43b70 (diff)
OpenSSL update
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl.c')
-rw-r--r--ext/openssl/ossl.c182
1 files changed, 0 insertions, 182 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 9e476cb5af..b90ea10780 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -11,142 +11,6 @@
#include "ossl.h"
#include <stdarg.h> /* for ossl_raise */
-#if defined(HAVE_SYS_TIME_H)
-# include <sys/time.h>
-#elif !defined(NT) && !defined(_WIN32)
-struct timeval {
- long tv_sec; /* seconds */
- long tv_usec; /* and microseconds */
-};
-#endif
-
-/*
- * DATE conversion
- */
-VALUE
-asn1time_to_time(ASN1_TIME *time)
-{
- struct tm tm;
- VALUE argv[6];
-
- if (!time) {
- ossl_raise(rb_eTypeError, "ASN1_TIME is NULL!");
- }
- memset(&tm, 0, sizeof(struct tm));
-
- switch (time->type) {
- case V_ASN1_UTCTIME:
- if (sscanf(time->data, "%2d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
- &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
- ossl_raise(rb_eTypeError, "bad UTCTIME format");
- }
- if (tm.tm_year < 69) {
- tm.tm_year += 2000;
- } else {
- tm.tm_year += 1900;
- }
- tm.tm_mon -= 1;
- break;
- case V_ASN1_GENERALIZEDTIME:
- if (sscanf(time->data, "%4d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
- &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
- ossl_raise(rb_eTypeError, "bad GENERALIZEDTIME format" );
- }
- tm.tm_mon -= 1;
- break;
- default:
- rb_warning("unknown time format");
- return Qnil;
- }
- argv[0] = INT2NUM(tm.tm_year);
- argv[1] = INT2NUM(tm.tm_mon+1);
- argv[2] = INT2NUM(tm.tm_mday);
- argv[3] = INT2NUM(tm.tm_hour);
- argv[4] = INT2NUM(tm.tm_min);
- argv[5] = INT2NUM(tm.tm_sec);
-
- return rb_funcall2(rb_cTime, rb_intern("utc"), 6, argv);
-}
-
-/*
- * This function is not exported in Ruby's *.h
- */
-extern struct timeval rb_time_timeval(VALUE);
-
-time_t
-time_to_time_t(VALUE time)
-{
- struct timeval t = rb_time_timeval(time);
- return t.tv_sec;
-}
-
-/*
- * ASN1_INTEGER conversions
- * TODO: Make a decision what's the right way to do this.
- */
-#define DO_IT_VIA_RUBY 0
-VALUE
-asn1integer_to_num(ASN1_INTEGER *ai)
-{
- BIGNUM *bn;
-#if DO_IT_VIA_RUBY
- char *txt;
-#endif
- VALUE num;
-
- if (!ai) {
- ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
- }
- if (!(bn = ASN1_INTEGER_to_BN(ai, NULL))) {
- ossl_raise(eOSSLError, NULL);
- }
-#if DO_IT_VIA_RUBY
- if (!(txt = BN_bn2dec(bn))) {
- BN_free(bn);
- ossl_raise(eOSSLError, NULL);
- }
- num = rb_cstr_to_inum(txt, 10, Qtrue);
- OPENSSL_free(txt);
-#else
- num = ossl_bn_new(bn);
-#endif
- BN_free(bn);
-
- return num;
-}
-
-#if DO_IT_VIA_RUBY
-ASN1_INTEGER *num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
-{
- BIGNUM *bn = NULL;
-
- if (RTEST(rb_obj_is_kind_of(obj, cBN))) {
- bn = GetBNPtr(obj);
- } else {
- obj = rb_String(obj);
- if (!BN_dec2bn(&bn, StringValuePtr(obj))) {
- ossl_raise(eOSSLError, NULL);
- }
- }
- if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) {
- BN_free(bn);
- ossl_raise(eOSSLError, NULL);
- }
- BN_free(bn);
- return ai;
-}
-#else
-ASN1_INTEGER *num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
-{
- BIGNUM *bn = GetBNPtr(obj);
-
- if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) {
- ossl_raise(eOSSLError, NULL);
- }
- return ai;
-}
-#endif
-
/*
* String to HEXString conversion
*/
@@ -183,52 +47,6 @@ string2hex(char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
/*
* Data Conversion
*/
-BIO *
-ossl_obj2bio(VALUE obj)
-{
- BIO *bio;
-
- if (TYPE(obj) == T_FILE) {
- OpenFile *fptr;
- GetOpenFile(obj, fptr);
- rb_io_check_readable(fptr);
- bio = BIO_new_fp(fptr->f, BIO_NOCLOSE);
- }
- else {
- StringValue(obj);
- bio = BIO_new_mem_buf(RSTRING(obj)->ptr, RSTRING(obj)->len);
- }
- if (!bio) ossl_raise(eOSSLError, NULL);
-
- return bio;
-}
-
-BIO *
-ossl_protect_obj2bio(VALUE obj, int *status)
-{
- BIO *ret = NULL;
- ret = (BIO*)rb_protect((VALUE(*)_((VALUE)))ossl_obj2bio, obj, status);
- return ret;
-}
-
-VALUE
-ossl_membio2str(BIO *bio)
-{
- VALUE ret;
- BUF_MEM *buf;
-
- BIO_get_mem_ptr(bio, &buf);
- ret = rb_str_new(buf->data, buf->length);
-
- return ret;
-}
-
-VALUE
-ossl_protect_membio2str(BIO *bio, int *status)
-{
- return rb_protect((VALUE(*)_((VALUE)))ossl_membio2str, (VALUE)bio, status);
-}
-
STACK_OF(X509) *
ossl_x509_ary2sk(VALUE ary)
{