rubysl-openssl 2.4.0 → 2.5.0

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rubysl/openssl/deprecation.rb +1 -0
  3. data/ext/rubysl/openssl/extconf.rb +6 -8
  4. data/ext/rubysl/openssl/openssl_missing.c +1 -3
  5. data/ext/rubysl/openssl/openssl_missing.h +1 -3
  6. data/ext/rubysl/openssl/ossl.c +15 -3
  7. data/ext/rubysl/openssl/ossl.h +5 -4
  8. data/ext/rubysl/openssl/ossl_asn1.c +19 -13
  9. data/ext/rubysl/openssl/ossl_asn1.h +1 -2
  10. data/ext/rubysl/openssl/ossl_bio.c +1 -2
  11. data/ext/rubysl/openssl/ossl_bio.h +1 -3
  12. data/ext/rubysl/openssl/ossl_bn.c +227 -90
  13. data/ext/rubysl/openssl/ossl_bn.h +1 -3
  14. data/ext/rubysl/openssl/ossl_cipher.c +5 -11
  15. data/ext/rubysl/openssl/ossl_cipher.h +1 -3
  16. data/ext/rubysl/openssl/ossl_config.c +1 -2
  17. data/ext/rubysl/openssl/ossl_config.h +1 -3
  18. data/ext/rubysl/openssl/ossl_digest.c +6 -7
  19. data/ext/rubysl/openssl/ossl_digest.h +1 -3
  20. data/ext/rubysl/openssl/ossl_engine.c +11 -7
  21. data/ext/rubysl/openssl/ossl_engine.h +1 -2
  22. data/ext/rubysl/openssl/ossl_hmac.c +1 -2
  23. data/ext/rubysl/openssl/ossl_hmac.h +1 -2
  24. data/ext/rubysl/openssl/ossl_ns_spki.c +7 -6
  25. data/ext/rubysl/openssl/ossl_ns_spki.h +1 -3
  26. data/ext/rubysl/openssl/ossl_ocsp.c +39 -25
  27. data/ext/rubysl/openssl/ossl_ocsp.h +1 -2
  28. data/ext/rubysl/openssl/ossl_pkcs12.c +10 -6
  29. data/ext/rubysl/openssl/ossl_pkcs12.h +1 -3
  30. data/ext/rubysl/openssl/ossl_pkcs5.c +0 -1
  31. data/ext/rubysl/openssl/ossl_pkcs7.c +29 -16
  32. data/ext/rubysl/openssl/ossl_pkcs7.h +1 -3
  33. data/ext/rubysl/openssl/ossl_pkey.c +10 -8
  34. data/ext/rubysl/openssl/ossl_pkey.h +5 -6
  35. data/ext/rubysl/openssl/ossl_pkey_dh.c +5 -74
  36. data/ext/rubysl/openssl/ossl_pkey_dsa.c +7 -6
  37. data/ext/rubysl/openssl/ossl_pkey_ec.c +4 -2
  38. data/ext/rubysl/openssl/ossl_pkey_rsa.c +5 -5
  39. data/ext/rubysl/openssl/ossl_rand.c +13 -5
  40. data/ext/rubysl/openssl/ossl_rand.h +1 -3
  41. data/ext/rubysl/openssl/ossl_ssl.c +334 -265
  42. data/ext/rubysl/openssl/ossl_ssl.h +1 -5
  43. data/ext/rubysl/openssl/ossl_ssl_session.c +5 -1
  44. data/ext/rubysl/openssl/ossl_version.h +1 -2
  45. data/ext/rubysl/openssl/ossl_x509.c +1 -3
  46. data/ext/rubysl/openssl/ossl_x509.h +1 -2
  47. data/ext/rubysl/openssl/ossl_x509attr.c +9 -6
  48. data/ext/rubysl/openssl/ossl_x509cert.c +14 -12
  49. data/ext/rubysl/openssl/ossl_x509crl.c +15 -13
  50. data/ext/rubysl/openssl/ossl_x509ext.c +13 -8
  51. data/ext/rubysl/openssl/ossl_x509name.c +9 -6
  52. data/ext/rubysl/openssl/ossl_x509req.c +12 -10
  53. data/ext/rubysl/openssl/ossl_x509revoked.c +12 -10
  54. data/ext/rubysl/openssl/ossl_x509store.c +17 -10
  55. data/ext/rubysl/openssl/ruby_missing.h +1 -2
  56. data/lib/openssl/bn.rb +2 -8
  57. data/lib/openssl/buffering.rb +3 -7
  58. data/lib/openssl/cipher.rb +3 -9
  59. data/lib/openssl/config.rb +2 -1
  60. data/lib/openssl/digest.rb +3 -10
  61. data/lib/openssl/pkey.rb +37 -0
  62. data/lib/openssl/ssl.rb +128 -17
  63. data/lib/openssl/x509.rb +2 -8
  64. data/lib/rubysl/openssl.rb +4 -7
  65. data/lib/rubysl/openssl/version.rb +1 -1
  66. metadata +12 -11
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_bn.h 25189 2009-10-02 12:04:37Z akr $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #if !defined(_OSSL_BN_H_)
@@ -22,4 +21,3 @@ void Init_ossl_bn(void);
22
21
 
23
22
 
24
23
  #endif /* _OSS_BN_H_ */
25
-
@@ -1,17 +1,16 @@
1
1
  /*
2
- * $Id: ossl_cipher.c 48923 2014-12-23 02:42:16Z nobu $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #include "ossl.h"
12
11
 
13
- #define WrapCipher(obj, klass, ctx) \
14
- (obj) = TypedData_Wrap_Struct((klass), &ossl_cipher_type, (ctx))
12
+ #define NewCipher(klass) \
13
+ TypedData_Wrap_Struct((klass), &ossl_cipher_type, 0)
15
14
  #define MakeCipher(obj, klass, ctx) \
16
15
  (obj) = TypedData_Make_Struct((klass), EVP_CIPHER_CTX, &ossl_cipher_type, (ctx))
17
16
  #define AllocCipher(obj, ctx) \
@@ -92,17 +91,13 @@ static size_t
92
91
  ossl_cipher_memsize(const void *ptr)
93
92
  {
94
93
  const EVP_CIPHER_CTX *ctx = ptr;
95
- return ctx ? sizeof(*ctx) : 0;
94
+ return sizeof(*ctx);
96
95
  }
97
96
 
98
97
  static VALUE
99
98
  ossl_cipher_alloc(VALUE klass)
100
99
  {
101
- VALUE obj;
102
-
103
- WrapCipher(obj, klass, 0);
104
-
105
- return obj;
100
+ return NewCipher(klass);
106
101
  }
107
102
 
108
103
  /*
@@ -1014,4 +1009,3 @@ Init_ossl_cipher(void)
1014
1009
  rb_define_method(cCipher, "block_size", ossl_cipher_block_size, 0);
1015
1010
  rb_define_method(cCipher, "padding=", ossl_cipher_set_padding, 1);
1016
1011
  }
1017
-
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_cipher.h 25189 2009-10-02 12:04:37Z akr $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #if !defined(_OSSL_CIPHER_H_)
@@ -19,4 +18,3 @@ VALUE ossl_cipher_new(const EVP_CIPHER *);
19
18
  void Init_ossl_cipher(void);
20
19
 
21
20
  #endif /* _OSSL_CIPHER_H_ */
22
-
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_config.c 47744 2014-09-30 05:25:32Z nobu $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #include "ossl.h"
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_config.h 25189 2009-10-02 12:04:37Z akr $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #if !defined(_OSSL_CONFIG_H_)
@@ -19,4 +18,3 @@ CONF* DupConfigPtr(VALUE obj);
19
18
  void Init_ossl_config(void);
20
19
 
21
20
  #endif /* _OSSL_CONFIG_H_ */
22
-
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_digest.c 48791 2014-12-12 21:57:44Z nobu $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #include "ossl.h"
@@ -95,13 +94,11 @@ ossl_digest_new(const EVP_MD *md)
95
94
  static VALUE
96
95
  ossl_digest_alloc(VALUE klass)
97
96
  {
98
- EVP_MD_CTX *ctx;
99
- VALUE obj;
100
-
101
- ctx = EVP_MD_CTX_create();
97
+ VALUE obj = TypedData_Wrap_Struct(klass, &ossl_digest_type, 0);
98
+ EVP_MD_CTX *ctx = EVP_MD_CTX_create();
102
99
  if (ctx == NULL)
103
100
  ossl_raise(rb_eRuntimeError, "EVP_MD_CTX_create() failed");
104
- obj = TypedData_Wrap_Struct(klass, &ossl_digest_type, ctx);
101
+ RTYPEDDATA_DATA(obj) = ctx;
105
102
 
106
103
  return obj;
107
104
  }
@@ -310,6 +307,8 @@ ossl_digest_block_length(VALUE self)
310
307
  void
311
308
  Init_ossl_digest(void)
312
309
  {
310
+ rb_require("digest");
311
+
313
312
  #if 0
314
313
  mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
315
314
  #endif
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_digest.h 25189 2009-10-02 12:04:37Z akr $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #if !defined(_OSSL_DIGEST_H_)
@@ -19,4 +18,3 @@ VALUE ossl_digest_new(const EVP_MD *);
19
18
  void Init_ossl_digest(void);
20
19
 
21
20
  #endif /* _OSSL_DIGEST_H_ */
22
-
@@ -1,22 +1,23 @@
1
1
  /*
2
- * $Id: ossl_engine.c 48792 2014-12-12 21:57:49Z nobu $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #include "ossl.h"
12
11
 
13
12
  #if defined(OSSL_ENGINE_ENABLED)
14
13
 
15
- #define WrapEngine(klass, obj, engine) do { \
14
+ #define NewEngine(klass) \
15
+ TypedData_Wrap_Struct((klass), &ossl_engine_type, 0)
16
+ #define SetEngine(obj, engine) do { \
16
17
  if (!(engine)) { \
17
18
  ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
18
19
  } \
19
- (obj) = TypedData_Wrap_Struct((klass), &ossl_engine_type, (engine)); \
20
+ RTYPEDDATA_DATA(obj) = (engine); \
20
21
  } while(0)
21
22
  #define GetEngine(obj, engine) do { \
22
23
  TypedData_Get_Struct((obj), ENGINE, &ossl_engine_type, (engine)); \
@@ -182,11 +183,12 @@ ossl_engine_s_engines(VALUE klass)
182
183
 
183
184
  ary = rb_ary_new();
184
185
  for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){
186
+ obj = NewEngine(klass);
185
187
  /* Need a ref count of two here because of ENGINE_free being
186
188
  * called internally by OpenSSL when moving to the next ENGINE
187
189
  * and by us when releasing the ENGINE reference */
188
190
  ENGINE_up_ref(e);
189
- WrapEngine(klass, obj, e);
191
+ SetEngine(obj, e);
190
192
  rb_ary_push(ary, obj);
191
193
  }
192
194
 
@@ -213,9 +215,10 @@ ossl_engine_s_by_id(VALUE klass, VALUE id)
213
215
 
214
216
  StringValue(id);
215
217
  ossl_engine_s_load(1, &id, klass);
218
+ obj = NewEngine(klass);
216
219
  if(!(e = ENGINE_by_id(RSTRING_PTR(id))))
217
220
  ossl_raise(eEngineError, NULL);
218
- WrapEngine(klass, obj, e);
221
+ SetEngine(obj, e);
219
222
  if(rb_block_given_p()) rb_yield(obj);
220
223
  if(!ENGINE_init(e))
221
224
  ossl_raise(eEngineError, NULL);
@@ -232,10 +235,11 @@ ossl_engine_s_alloc(VALUE klass)
232
235
  ENGINE *e;
233
236
  VALUE obj;
234
237
 
238
+ obj = NewEngine(klass);
235
239
  if (!(e = ENGINE_new())) {
236
240
  ossl_raise(eEngineError, NULL);
237
241
  }
238
- WrapEngine(klass, obj, e);
242
+ SetEngine(obj, e);
239
243
 
240
244
  return obj;
241
245
  }
@@ -1,12 +1,11 @@
1
1
  /*
2
- * $Id: ossl_engine.h 25189 2009-10-02 12:04:37Z akr $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
6
5
  * All rights reserved.
7
6
  */
8
7
  /*
9
- * This program is licenced under the same licence as Ruby.
8
+ * This program is licensed under the same licence as Ruby.
10
9
  * (See the file 'LICENCE'.)
11
10
  */
12
11
  #if !defined(OSSL_ENGINE_H)
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_hmac.c 48793 2014-12-12 21:57:56Z nobu $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #if !defined(OPENSSL_NO_HMAC)
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_hmac.h 25189 2009-10-02 12:04:37Z akr $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #if !defined(_OSSL_HMAC_H_)
@@ -1,20 +1,21 @@
1
1
  /*
2
- * $Id: ossl_ns_spki.c 48794 2014-12-12 21:58:03Z nobu $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #include "ossl.h"
12
11
 
13
- #define WrapSPKI(klass, obj, spki) do { \
12
+ #define NewSPKI(klass) \
13
+ TypedData_Wrap_Struct((klass), &ossl_netscape_spki_type, 0)
14
+ #define SetSPKI(obj, spki) do { \
14
15
  if (!(spki)) { \
15
16
  ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
16
17
  } \
17
- (obj) = TypedData_Wrap_Struct((klass), &ossl_netscape_spki_type, (spki)); \
18
+ RTYPEDDATA_DATA(obj) = (spki); \
18
19
  } while (0)
19
20
  #define GetSPKI(obj, spki) do { \
20
21
  TypedData_Get_Struct((obj), NETSCAPE_SPKI, &ossl_netscape_spki_type, (spki)); \
@@ -58,10 +59,11 @@ ossl_spki_alloc(VALUE klass)
58
59
  NETSCAPE_SPKI *spki;
59
60
  VALUE obj;
60
61
 
62
+ obj = NewSPKI(klass);
61
63
  if (!(spki = NETSCAPE_SPKI_new())) {
62
64
  ossl_raise(eSPKIError, NULL);
63
65
  }
64
- WrapSPKI(klass, obj, spki);
66
+ SetSPKI(obj, spki);
65
67
 
66
68
  return obj;
67
69
  }
@@ -401,4 +403,3 @@ Init_ossl_ns_spki(void)
401
403
  rb_define_method(cSPKI, "challenge", ossl_spki_get_challenge, 0);
402
404
  rb_define_method(cSPKI, "challenge=", ossl_spki_set_challenge, 1);
403
405
  }
404
-
@@ -1,11 +1,10 @@
1
1
  /*
2
- * $Id: ossl_ns_spki.h 25189 2009-10-02 12:04:37Z akr $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * All rights reserved.
6
5
  */
7
6
  /*
8
- * This program is licenced under the same licence as Ruby.
7
+ * This program is licensed under the same licence as Ruby.
9
8
  * (See the file 'LICENCE'.)
10
9
  */
11
10
  #if !defined(_OSSL_NS_SPKI_H_)
@@ -18,4 +17,3 @@ extern VALUE eSPKIError;
18
17
  void Init_ossl_ns_spki(void);
19
18
 
20
19
  #endif /* _OSSL_NS_SPKI_H_ */
21
-
@@ -1,21 +1,22 @@
1
1
  /*
2
- * $Id: ossl_ocsp.c 48798 2014-12-12 21:58:22Z nobu $
3
2
  * 'OpenSSL for Ruby' project
4
3
  * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
5
4
  * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
6
5
  * All rights reserved.
7
6
  */
8
7
  /*
9
- * This program is licenced under the same licence as Ruby.
8
+ * This program is licensed under the same licence as Ruby.
10
9
  * (See the file 'LICENCE'.)
11
10
  */
12
11
  #include "ossl.h"
13
12
 
14
13
  #if defined(OSSL_OCSP_ENABLED)
15
14
 
16
- #define WrapOCSPReq(klass, obj, req) do { \
15
+ #define NewOCSPReq(klass) \
16
+ TypedData_Wrap_Struct((klass), &ossl_ocsp_request_type, 0)
17
+ #define SetOCSPReq(obj, req) do { \
17
18
  if(!(req)) ossl_raise(rb_eRuntimeError, "Request wasn't initialized!"); \
18
- (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_request_type, (req)); \
19
+ RTYPEDDATA_DATA(obj) = (req); \
19
20
  } while (0)
20
21
  #define GetOCSPReq(obj, req) do { \
21
22
  TypedData_Get_Struct((obj), OCSP_REQUEST, &ossl_ocsp_request_type, (req)); \
@@ -26,9 +27,11 @@
26
27
  GetOCSPReq((obj), (req)); \
27
28
  } while (0)
28
29
 
29
- #define WrapOCSPRes(klass, obj, res) do { \
30
+ #define NewOCSPRes(klass) \
31
+ TypedData_Wrap_Struct((klass), &ossl_ocsp_response_type, 0)
32
+ #define SetOCSPRes(obj, res) do { \
30
33
  if(!(res)) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
31
- (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_response_type, (res)); \
34
+ RTYPEDDATA_DATA(obj) = (res); \
32
35
  } while (0)
33
36
  #define GetOCSPRes(obj, res) do { \
34
37
  TypedData_Get_Struct((obj), OCSP_RESPONSE, &ossl_ocsp_response_type, (res)); \
@@ -39,9 +42,11 @@
39
42
  GetOCSPRes((obj), (res)); \
40
43
  } while (0)
41
44
 
42
- #define WrapOCSPBasicRes(klass, obj, res) do { \
45
+ #define NewOCSPBasicRes(klass) \
46
+ TypedData_Wrap_Struct((klass), &ossl_ocsp_basicresp_type, 0)
47
+ #define SetOCSPBasicRes(obj, res) do { \
43
48
  if(!(res)) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
44
- (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_basicresp_type, (res)); \
49
+ RTYPEDDATA_DATA(obj) = (res); \
45
50
  } while (0)
46
51
  #define GetOCSPBasicRes(obj, res) do { \
47
52
  TypedData_Get_Struct((obj), OCSP_BASICRESP, &ossl_ocsp_basicresp_type, (res)); \
@@ -52,9 +57,11 @@
52
57
  GetOCSPBasicRes((obj), (res)); \
53
58
  } while (0)
54
59
 
55
- #define WrapOCSPCertId(klass, obj, cid) do { \
60
+ #define NewOCSPCertId(klass) \
61
+ TypedData_Wrap_Struct((klass), &ossl_ocsp_certid_type, 0)
62
+ #define SetOCSPCertId(obj, cid) do { \
56
63
  if(!(cid)) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \
57
- (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_certid_type, (cid)); \
64
+ RTYPEDDATA_DATA(obj) = (cid); \
58
65
  } while (0)
59
66
  #define GetOCSPCertId(obj, cid) do { \
60
67
  TypedData_Get_Struct((obj), OCSP_CERTID, &ossl_ocsp_certid_type, (cid)); \
@@ -134,8 +141,8 @@ static const rb_data_type_t ossl_ocsp_certid_type = {
134
141
  static VALUE
135
142
  ossl_ocspcertid_new(OCSP_CERTID *cid)
136
143
  {
137
- VALUE obj;
138
- WrapOCSPCertId(cOCSPCertId, obj, cid);
144
+ VALUE obj = NewOCSPCertId(cOCSPCertId);
145
+ SetOCSPCertId(obj, cid);
139
146
  return obj;
140
147
  }
141
148
 
@@ -148,9 +155,10 @@ ossl_ocspreq_alloc(VALUE klass)
148
155
  OCSP_REQUEST *req;
149
156
  VALUE obj;
150
157
 
158
+ obj = NewOCSPReq(klass);
151
159
  if (!(req = OCSP_REQUEST_new()))
152
160
  ossl_raise(eOCSPError, NULL);
153
- WrapOCSPReq(klass, obj, req);
161
+ SetOCSPReq(obj, req);
154
162
 
155
163
  return obj;
156
164
  }
@@ -294,9 +302,10 @@ ossl_ocspreq_get_certid(VALUE self)
294
302
  ary = (count > 0) ? rb_ary_new() : Qnil;
295
303
  for(i = 0; i < count; i++){
296
304
  one = OCSP_request_onereq_get0(req, i);
305
+ tmp = NewOCSPCertId(cOCSPCertId);
297
306
  if(!(id = OCSP_CERTID_dup(OCSP_onereq_get0_id(one))))
298
307
  ossl_raise(eOCSPError, NULL);
299
- WrapOCSPCertId(cOCSPCertId, tmp, id);
308
+ SetOCSPCertId(tmp, id);
300
309
  rb_ary_push(ary, tmp);
301
310
  }
302
311
 
@@ -415,9 +424,10 @@ ossl_ocspres_s_create(VALUE klass, VALUE status, VALUE basic_resp)
415
424
 
416
425
  if(NIL_P(basic_resp)) bs = NULL;
417
426
  else GetOCSPBasicRes(basic_resp, bs); /* NO NEED TO DUP */
427
+ obj = NewOCSPRes(klass);
418
428
  if(!(res = OCSP_response_create(st, bs)))
419
429
  ossl_raise(eOCSPError, NULL);
420
- WrapOCSPRes(klass, obj, res);
430
+ SetOCSPRes(obj, res);
421
431
 
422
432
  return obj;
423
433
  }
@@ -428,9 +438,10 @@ ossl_ocspres_alloc(VALUE klass)
428
438
  OCSP_RESPONSE *res;
429
439
  VALUE obj;
430
440
 
441
+ obj = NewOCSPRes(klass);
431
442
  if(!(res = OCSP_RESPONSE_new()))
432
443
  ossl_raise(eOCSPError, NULL);
433
- WrapOCSPRes(klass, obj, res);
444
+ SetOCSPRes(obj, res);
434
445
 
435
446
  return obj;
436
447
  }
@@ -519,9 +530,10 @@ ossl_ocspres_get_basic(VALUE self)
519
530
  VALUE ret;
520
531
 
521
532
  GetOCSPRes(self, res);
533
+ ret = NewOCSPBasicRes(cOCSPBasicRes);
522
534
  if(!(bs = OCSP_response_get1_basic(res)))
523
535
  return Qnil;
524
- WrapOCSPBasicRes(cOCSPBasicRes, ret, bs);
536
+ SetOCSPBasicRes(ret, bs);
525
537
 
526
538
  return ret;
527
539
  }
@@ -562,9 +574,10 @@ ossl_ocspbres_alloc(VALUE klass)
562
574
  OCSP_BASICRESP *bs;
563
575
  VALUE obj;
564
576
 
577
+ obj = NewOCSPBasicRes(klass);
565
578
  if(!(bs = OCSP_BASICRESP_new()))
566
579
  ossl_raise(eOCSPError, NULL);
567
- WrapOCSPBasicRes(klass, obj, bs);
580
+ SetOCSPBasicRes(obj, bs);
568
581
 
569
582
  return obj;
570
583
  }
@@ -638,7 +651,7 @@ ossl_ocspbres_add_nonce(int argc, VALUE *argv, VALUE self)
638
651
  * call-seq:
639
652
  * basic_response.add_status(certificate_id, status, reason, revocation_time, this_update, next_update, extensions) -> basic_response
640
653
  *
641
- * Adds a validation +status+ (0 for revoked, 1 for success) to this
654
+ * Adds a validation +status+ (0 for good, 1 for revoked, 2 for unknown) to this
642
655
  * response for +certificate_id+. +reason+ describes the reason for the
643
656
  * revocation, if any.
644
657
  *
@@ -658,9 +671,9 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
658
671
  OCSP_BASICRESP *bs;
659
672
  OCSP_SINGLERESP *single;
660
673
  OCSP_CERTID *id;
661
- int st, rsn;
662
674
  ASN1_TIME *ths, *nxt, *rev;
663
- int error, i, rstatus = 0;
675
+ int st, rsn, error, rstatus = 0;
676
+ long i;
664
677
  VALUE tmp;
665
678
 
666
679
  st = NUM2INT(status);
@@ -669,7 +682,7 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
669
682
  /* All ary's members should be X509Extension */
670
683
  Check_Type(ext, T_ARRAY);
671
684
  for (i = 0; i < RARRAY_LEN(ext); i++)
672
- OSSL_Check_Kind(RARRAY_PTR(ext)[i], cX509Ext);
685
+ OSSL_Check_Kind(RARRAY_AREF(ext, i), cX509Ext);
673
686
  }
674
687
 
675
688
  error = 0;
@@ -698,7 +711,7 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
698
711
  sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
699
712
  single->singleExtensions = NULL;
700
713
  for(i = 0; i < RARRAY_LEN(ext); i++){
701
- x509ext = DupX509ExtPtr(RARRAY_PTR(ext)[i]);
714
+ x509ext = DupX509ExtPtr(RARRAY_AREF(ext, i));
702
715
  if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
703
716
  X509_EXTENSION_free(x509ext);
704
717
  error = 1;
@@ -723,7 +736,7 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
723
736
  * basic_response.status -> statuses
724
737
  *
725
738
  * Returns an Array of statuses for this response. Each status contains a
726
- * CertificateId, the status (0 for success, 1 for revoked), the reason for
739
+ * CertificateId, the status (0 for good, 1 for revoked, 2 for unknown), the reason for
727
740
  * the status, the revocation time, the time of this update, the time for the
728
741
  * next update and a list of OpenSSL::X509::Extensions.
729
742
  */
@@ -851,9 +864,10 @@ ossl_ocspcid_alloc(VALUE klass)
851
864
  OCSP_CERTID *id;
852
865
  VALUE obj;
853
866
 
867
+ obj = NewOCSPCertId(klass);
854
868
  if(!(id = OCSP_CERTID_new()))
855
869
  ossl_raise(eOCSPError, NULL);
856
- WrapOCSPCertId(klass, obj, id);
870
+ SetOCSPCertId(obj, id);
857
871
 
858
872
  return obj;
859
873
  }