openssl_rsa_pss_verify 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af0176c1dba9f84f2f57ea4eb05049f8fc6bf02b
4
- data.tar.gz: 95b797966ec7f45481703f74d957fd4663be3c5d
3
+ metadata.gz: e663505c105b6385aeef89f9e4aea3ba5a1b708c
4
+ data.tar.gz: ee40c100e8ddc9a36c6cdf3da3f91c8bd792e042
5
5
  SHA512:
6
- metadata.gz: efe83c77ad8ee6469ebce3b77ab1ec5a461b8469c69109cc46ef360f45934b5da9aed9dc92516f641027641c9d147ab043c3ae91470aa70acfdd10ebacc3646b
7
- data.tar.gz: fe05719b3f4ffca9cf1e5249d084de42a4151533aad10e95a83130afcb2a3cfa138ec8edab1e443856e5ed88ff1579bb71cba901dfea3c55c69778637ca044dc
6
+ metadata.gz: 0302ffddae907311bd11cf5512377e3cf58ab63f82c1f9e4fd26872120622844dca6c9977603764911dd22d83b4c3a0153622da465abfee84327a50e3fc9d29b
7
+ data.tar.gz: 375d73cd12f52f8ba9f33acafa111d0f539cd4e024232694344b9becc808a9657bff8735fc0b247427ce863b3526d201b64cc476af99180e2ce8f82c3c87f564
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openssl_rsa_pss_verify (0.1.3)
4
+ openssl_rsa_pss_verify (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -16,6 +16,9 @@ static VALUE rb_mPKey;
16
16
  static VALUE rb_cRSA;
17
17
  static VALUE rb_cRSAError;
18
18
 
19
+ #define ORPV_MAX_ERRS 10
20
+ #define OSSL_ERR_STR_LEN 120
21
+
19
22
  enum ORPV_errors {
20
23
  OK,
21
24
  EXTERNAL,
@@ -31,11 +34,36 @@ enum ORPV_errors {
31
34
  SET_SALTLEN,
32
35
  };
33
36
 
34
- #define BIND_ERR_STR(str_p) \
35
- if (ERR_peek_error()) ERR_error_string(ERR_get_error(), (str_p));
37
+ static void bind_err_strs(char * strs, int max) {
38
+ int i;
39
+ char last_err[OSSL_ERR_STR_LEN] = "";
40
+
41
+ if (! ERR_peek_error()) {
42
+ strcat(strs, "[no internal OpenSSL error was flagged]");
43
+ return;
44
+ }
45
+
46
+ for(i = 0; ERR_peek_error() && i < max - 1; ++i) {
47
+ strncat(strs, ERR_error_string(ERR_get_error(), NULL), OSSL_ERR_STR_LEN);
48
+ strcat(strs, "\n");
49
+ }
50
+
51
+ if (i == (max-1) && ERR_peek_error()) {
52
+ strncat(last_err, ERR_error_string(ERR_get_error(), NULL), OSSL_ERR_STR_LEN);
53
+
54
+ if (ERR_peek_error()) {
55
+ // Still yet another error past max
56
+ strcat(strs, "\n[additional errors truncated]");
57
+ while(ERR_get_error());
58
+ } else {
59
+ strcat(strs, "\n");
60
+ strcat(strs, last_err);
61
+ }
62
+ }
63
+ }
36
64
 
37
65
 
38
- VALUE ORPV__verify_pss_sha1(VALUE self, VALUE vPubKey, VALUE vSig, VALUE vHashData, VALUE vSaltLen) {
66
+ static VALUE ORPV__verify_pss_sha1(VALUE self, VALUE vPubKey, VALUE vSig, VALUE vHashData, VALUE vSaltLen) {
39
67
  enum ORPV_errors err = OK;
40
68
 
41
69
  BIO * pkey_bio = NULL;
@@ -45,7 +73,7 @@ VALUE ORPV__verify_pss_sha1(VALUE self, VALUE vPubKey, VALUE vSig, VALUE vHashDa
45
73
  char * pub_key = NULL;
46
74
 
47
75
  int verify_rval = -1, salt_len;
48
- char ossl_err_str[120] = "[no internal OpenSSL error was flagged]";
76
+ char ossl_err_strs[(OSSL_ERR_STR_LEN + 2) * ORPV_MAX_ERRS] = "";
49
77
 
50
78
  if (ERR_peek_error()) {
51
79
  err = EXTERNAL;
@@ -139,14 +167,14 @@ Cleanup:
139
167
  case 0:
140
168
  return Qfalse;
141
169
  default:
142
- BIND_ERR_STR(ossl_err_str)
143
- rb_raise(rb_cRSAError, "An error occurred during validation.\n%s", ossl_err_str);
170
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
171
+ rb_raise(rb_cRSAError, "An error occurred during validation.\n%s", ossl_err_strs);
144
172
  }
145
173
  break;
146
174
 
147
175
  case EXTERNAL:
148
- BIND_ERR_STR(ossl_err_str);
149
- rb_raise(rb_eRuntimeError, "OpenSSL was in an error state prior to invoking this verification.\n%s", ossl_err_str);
176
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
177
+ rb_raise(rb_eRuntimeError, "OpenSSL was in an error state prior to invoking this verification.\n%s", ossl_err_strs);
150
178
  break;
151
179
  case KEY_OVERFLOW:
152
180
  rb_raise(rb_cRSAError, "Your public key is too big. How is that even possible?");
@@ -155,40 +183,40 @@ Cleanup:
155
183
  rb_raise(rb_const_get_at(rb_mErrno, rb_intern("ENOMEM")), "Insufficient memory to allocate pubkey copy. Woof.");
156
184
  break;
157
185
  case PUBKEY_PARSE:
158
- BIND_ERR_STR(ossl_err_str);
159
- rb_raise(rb_cRSAError, "Error parsing public key\n%s", ossl_err_str);
186
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
187
+ rb_raise(rb_cRSAError, "Error parsing public key\n%s", ossl_err_strs);
160
188
  break;
161
189
  case PKEY_INIT:
162
- BIND_ERR_STR(ossl_err_str);
163
- rb_raise(rb_cRSAError, "Failed to initialize PKEY\n%s", ossl_err_str);
190
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
191
+ rb_raise(rb_cRSAError, "Failed to initialize PKEY\n%s", ossl_err_strs);
164
192
  break;
165
193
  case RSA_ASSIGN:
166
- BIND_ERR_STR(ossl_err_str);
167
- rb_raise(rb_cRSAError, "Failed to assign RSA object to PKEY\n%s", ossl_err_str);
194
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
195
+ rb_raise(rb_cRSAError, "Failed to assign RSA object to PKEY\n%s", ossl_err_strs);
168
196
  break;
169
197
  case PKEY_CTX_INIT:
170
- BIND_ERR_STR(ossl_err_str);
171
- rb_raise(rb_cRSAError, "Failed to initialize PKEY context.\n%s", ossl_err_str);
198
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
199
+ rb_raise(rb_cRSAError, "Failed to initialize PKEY context.\n%s", ossl_err_strs);
172
200
  break;
173
201
  case VERIFY_INIT:
174
- BIND_ERR_STR(ossl_err_str);
175
- rb_raise(rb_cRSAError, "Failed to initialize verification process.\n%s", ossl_err_str);
202
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
203
+ rb_raise(rb_cRSAError, "Failed to initialize verification process.\n%s", ossl_err_strs);
176
204
  break;
177
205
  case SET_SIG_MD:
178
- BIND_ERR_STR(ossl_err_str);
179
- rb_raise(rb_cRSAError, "Failed to set signature message digest to SHA1.\n%s", ossl_err_str);
206
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
207
+ rb_raise(rb_cRSAError, "Failed to set signature message digest to SHA1.\n%s", ossl_err_strs);
180
208
  break;
181
209
  case SET_PADDING:
182
- BIND_ERR_STR(ossl_err_str);
183
- rb_raise(rb_cRSAError, "Failed to set PSS padding.\n%s", ossl_err_str);
210
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
211
+ rb_raise(rb_cRSAError, "Failed to set PSS padding.\n%s", ossl_err_strs);
184
212
  break;
185
213
  case SET_SALTLEN:
186
- BIND_ERR_STR(ossl_err_str);
187
- rb_raise(rb_cRSAError, "Failed to set salt length.\n%s", ossl_err_str);
214
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
215
+ rb_raise(rb_cRSAError, "Failed to set salt length.\n%s", ossl_err_strs);
188
216
  break;
189
217
  default:
190
- BIND_ERR_STR(ossl_err_str);
191
- rb_raise(rb_eRuntimeError, "Something has gone horribly wrong.\n%s", ossl_err_str);
218
+ bind_err_strs(ossl_err_strs, ORPV_MAX_ERRS);
219
+ rb_raise(rb_eRuntimeError, "Something has gone horribly wrong.\n%s", ossl_err_strs);
192
220
  }
193
221
 
194
222
  return Qnil;
@@ -1,3 +1,3 @@
1
1
  module OpenSSL_RSA_PSS_Verify
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openssl_rsa_pss_verify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Distad