openssl_rsa_pss_verify 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/openssl_rsa_pss_verify/openssl_rsa_pss_verify_ext.c +54 -26
- data/lib/openssl_rsa_pss_verify/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e663505c105b6385aeef89f9e4aea3ba5a1b708c
         | 
| 4 | 
            +
              data.tar.gz: ee40c100e8ddc9a36c6cdf3da3f91c8bd792e042
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0302ffddae907311bd11cf5512377e3cf58ab63f82c1f9e4fd26872120622844dca6c9977603764911dd22d83b4c3a0153622da465abfee84327a50e3fc9d29b
         | 
| 7 | 
            +
              data.tar.gz: 375d73cd12f52f8ba9f33acafa111d0f539cd4e024232694344b9becc808a9657bff8735fc0b247427ce863b3526d201b64cc476af99180e2ce8f82c3c87f564
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -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 | 
            -
             | 
| 35 | 
            -
               | 
| 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  | 
| 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 | 
            -
                       | 
| 143 | 
            -
                      rb_raise(rb_cRSAError, "An error occurred during validation.\n%s",  | 
| 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 | 
            -
                   | 
| 149 | 
            -
                  rb_raise(rb_eRuntimeError, "OpenSSL was in an error state prior to invoking this verification.\n%s",  | 
| 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 | 
            -
                   | 
| 159 | 
            -
                  rb_raise(rb_cRSAError, "Error parsing public key\n%s",  | 
| 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 | 
            -
                   | 
| 163 | 
            -
                  rb_raise(rb_cRSAError, "Failed to initialize PKEY\n%s",  | 
| 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 | 
            -
                   | 
| 167 | 
            -
                  rb_raise(rb_cRSAError, "Failed to assign RSA object to PKEY\n%s",  | 
| 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 | 
            -
                   | 
| 171 | 
            -
                  rb_raise(rb_cRSAError, "Failed to initialize PKEY context.\n%s",  | 
| 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 | 
            -
                   | 
| 175 | 
            -
                  rb_raise(rb_cRSAError, "Failed to initialize verification process.\n%s",  | 
| 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 | 
            -
                   | 
| 179 | 
            -
                  rb_raise(rb_cRSAError, "Failed to set signature message digest to SHA1.\n%s",  | 
| 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 | 
            -
                   | 
| 183 | 
            -
                  rb_raise(rb_cRSAError, "Failed to set PSS padding.\n%s",  | 
| 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 | 
            -
                   | 
| 187 | 
            -
                  rb_raise(rb_cRSAError, "Failed to set salt length.\n%s",  | 
| 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 | 
            -
                   | 
| 191 | 
            -
                  rb_raise(rb_eRuntimeError, "Something has gone horribly wrong.\n%s",  | 
| 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;
         |