Merge branch 'org.openembedded.dev' of git@git.openembedded.net:openembedded into...
[vuplus_openembedded] / packages / ruby / files / openssl.patch
1 This patch backports changes from ruby 1.8.7 which only includes the
2 openssl prototypes for functions that are not in the system openssl
3 library.
4
5 diff -u ruby-1.8.5.orig/ext/openssl/extconf.rb ruby-1.8.5/ext/openssl/extconf.rb
6 --- ruby-1.8.5.orig/ext/openssl/openssl_missing.c       2007-02-13 00:01:19.000000000 +0100
7 +++ ruby-1.8.5/ext/openssl/openssl_missing.c    2008-05-19 05:00:52.000000000 +0200
8 @@ -22,17 +22,15 @@
9  #include "openssl_missing.h"
10  
11  #if !defined(HAVE_HMAC_CTX_COPY)
12 -int
13 +void
14  HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
15  {
16 -    if (!out || !in) return 0;
17 +    if (!out || !in) return;
18      memcpy(out, in, sizeof(HMAC_CTX));
19  
20 -    if (!EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx)
21 -           || !EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx)
22 -           || !EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx))
23 -       return 0;
24 -    return 1;
25 +    EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
26 +    EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
27 +    EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
28  }
29  #endif /* HAVE_HMAC_CTX_COPY */
30  #endif /* NO_HMAC */
31 diff -u ruby-1.8.5.orig/ext/openssl/openssl_missing.h ruby-1.8.5/ext/openssl/openssl_missing.h
32 --- ruby-1.8.5.orig/ext/openssl/openssl_missing.h       2008-08-04 06:43:34.000000000 +0200
33 +++ ruby-1.8.5/ext/openssl/openssl_missing.h    2008-08-04 06:44:17.000000000 +0200
34 @@ -60,14 +60,33 @@
35         (char *(*)())d2i_PKCS7_RECIP_INFO, (char *)ri)
36  #endif
37  
38 +#if !defined(HAVE_EVP_MD_CTX_INIT)
39  void HMAC_CTX_init(HMAC_CTX *ctx);
40 -int HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
41 +#endif
42 +
43 +#if !defined(HAVE_HMAC_CTX_COPY)
44 +void HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
45 +#endif
46 +
47 +#if !defined(HAVE_HMAC_CTX_CLEANUP)
48  void HMAC_CTX_cleanup(HMAC_CTX *ctx);
49 +#endif
50  
51 +#if !defined(HAVE_EVP_MD_CTX_CREATE)
52  EVP_MD_CTX *EVP_MD_CTX_create(void);
53 +#endif
54 +
55 +#if !defined(HAVE_EVP_MD_CTX_INIT)
56  void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
57 +#endif
58 +
59 +#if !defined(HAVE_EVP_MD_CTX_CLEANUP)
60  int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
61 +#endif
62 +
63 +#if !defined(HAVE_EVP_MD_CTX_DESTROY)
64  void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
65 +#endif
66  
67  #if !defined(HAVE_EVP_CIPHER_CTX_COPY)
68  int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in);
69 @@ -111,19 +130,54 @@
70  #define OPENSSL_cleanse(p, l) memset(p, 0, l)
71  #endif
72  
73 +#if !defined(HAVE_X509_STORE_SET_EX_DATA)
74  void *X509_STORE_get_ex_data(X509_STORE *str, int idx);
75  int X509_STORE_set_ex_data(X509_STORE *str, int idx, void *data);
76 +#endif
77 +
78 +#if !defined(HAVE_X509_CRL_SET_VERSION)
79  int X509_CRL_set_version(X509_CRL *x, long version);
80 +#endif
81 +
82 +#if !defined(HAVE_X509_CRL_SET_ISSUER_NAME)
83  int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
84 +#endif
85 +
86 +#if !defined(HAVE_X509_CRL_SORT)
87  int X509_CRL_sort(X509_CRL *c);
88 +#endif
89 +
90 +#if !defined(HAVE_X509_CRL_ADD0_REVOKED)
91  int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
92 +#endif
93 +
94 +#if !defined(HAVE_BN_MOD_SQR)
95  int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
96 +#endif
97 +
98 +#if !defined(HAVE_BN_MOD_ADD)
99  int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
100 +#endif
101 +
102 +#if !defined(HAVE_BN_MOD_SUB)
103  int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
104 +#endif
105 +
106 +#if !defined(HAVE_BN_RAND_RANGE)
107  int BN_rand_range(BIGNUM *r, BIGNUM *range);
108 +#endif
109 +
110 +#if !defined(HAVE_BN_PSEUDO_RAND_RANGE)
111  int BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range);
112 +#endif
113 +
114 +#if !defined(HAVE_CONF_GET1_DEFAULT_CONFIG_FILE)
115  char *CONF_get1_default_config_file(void);
116 +#endif
117 +
118 +#if !defined(HAVE_PEM_DEF_CALLBACK)
119  int PEM_def_callback(char *buf, int num, int w, void *key);
120 +#endif
121  
122  #if defined(__cplusplus)
123  }
124 diff -u ruby-1.8.5.orig/ext/openssl/ossl_hmac.c ruby-1.8.5/ext/openssl/ossl_hmac.c
125 --- ruby-1.8.5.orig/ext/openssl/ossl_hmac.c     2007-03-12 05:12:32.000000000 +0100
126 +++ ruby-1.8.5/ext/openssl/ossl_hmac.c  2008-05-19 05:00:52.000000000 +0200
127 @@ -81,12 +87,15 @@
128      GetHMAC(self, ctx1);
129      SafeGetHMAC(other, ctx2);
130  
131 -    if (!HMAC_CTX_copy(ctx1, ctx2)) {
132 -       ossl_raise(eHMACError, NULL);
133 -    }
134 +    HMAC_CTX_copy(ctx1, ctx2);
135      return self;
136  }
137  
138 +/*
139 + *  call-seq:
140 + *     hmac.update(string) -> self
141 + *
142 + */
143  static VALUE
144  ossl_hmac_update(VALUE self, VALUE data)
145  {
146 @@ -104,9 +113,7 @@
147  {
148      HMAC_CTX final;
149  
150 -    if (!HMAC_CTX_copy(&final, ctx)) {
151 -       ossl_raise(eHMACError, NULL);
152 -    }
153 +    HMAC_CTX_copy(&final, ctx);
154      if (!(*buf = OPENSSL_malloc(HMAC_size(&final)))) {
155         HMAC_CTX_cleanup(&final);
156         OSSL_Debug("Allocating %d mem", HMAC_size(&final));