redcar 0.3.2dev → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +49 -2
- data/README.md +2 -7
- data/ROADMAP.md +8 -9
- data/Rakefile +29 -44
- data/bin/redcar +11 -2
- data/lib/openssl/History.txt +75 -0
- data/lib/openssl/License.txt +30 -0
- data/lib/openssl/Manifest.txt +99 -0
- data/lib/openssl/README.txt +24 -0
- data/lib/openssl/Rakefile +71 -0
- data/lib/openssl/build.properties.SAMPLE +7 -0
- data/lib/openssl/build.xml +57 -0
- data/lib/openssl/lib/jopenssl/version.rb +5 -0
- data/lib/openssl/lib/openssl.rb +24 -0
- data/lib/openssl/lib/openssl/bn.rb +33 -0
- data/lib/openssl/lib/openssl/buffering.rb +239 -0
- data/lib/openssl/lib/openssl/cipher.rb +56 -0
- data/lib/openssl/lib/openssl/digest.rb +46 -0
- data/lib/openssl/lib/openssl/dummy.rb +34 -0
- data/lib/openssl/lib/openssl/dummyssl.rb +13 -0
- data/lib/openssl/lib/openssl/ssl.rb +135 -0
- data/lib/openssl/lib/openssl/x509.rb +154 -0
- data/lib/openssl/mocha/COPYING +3 -0
- data/lib/openssl/mocha/MIT-LICENSE +7 -0
- data/lib/openssl/mocha/README +35 -0
- data/lib/openssl/mocha/RELEASE +171 -0
- data/lib/openssl/mocha/Rakefile +147 -0
- data/lib/openssl/mocha/TODO +48 -0
- data/lib/openssl/mocha/examples/misc.rb +36 -0
- data/lib/openssl/mocha/examples/mocha.rb +26 -0
- data/lib/openssl/mocha/examples/stubba.rb +65 -0
- data/lib/openssl/mocha/init.rb +3 -0
- data/lib/openssl/mocha/lib/mocha.rb +19 -0
- data/lib/openssl/mocha/lib/mocha/any_instance_method.rb +35 -0
- data/lib/openssl/mocha/lib/mocha/auto_verify.rb +111 -0
- data/lib/openssl/mocha/lib/mocha/central.rb +35 -0
- data/lib/openssl/mocha/lib/mocha/class_method.rb +62 -0
- data/lib/openssl/mocha/lib/mocha/deprecation.rb +22 -0
- data/lib/openssl/mocha/lib/mocha/exception_raiser.rb +17 -0
- data/lib/openssl/mocha/lib/mocha/expectation.rb +382 -0
- data/lib/openssl/mocha/lib/mocha/expectation_error.rb +6 -0
- data/lib/openssl/mocha/lib/mocha/expectation_list.rb +45 -0
- data/lib/openssl/mocha/lib/mocha/infinite_range.rb +25 -0
- data/lib/openssl/mocha/lib/mocha/inspect.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/instance_method.rb +8 -0
- data/lib/openssl/mocha/lib/mocha/is_a.rb +9 -0
- data/lib/openssl/mocha/lib/mocha/metaclass.rb +7 -0
- data/lib/openssl/mocha/lib/mocha/missing_expectation.rb +27 -0
- data/lib/openssl/mocha/lib/mocha/mock.rb +200 -0
- data/lib/openssl/mocha/lib/mocha/multiple_yields.rb +20 -0
- data/lib/openssl/mocha/lib/mocha/no_yields.rb +11 -0
- data/lib/openssl/mocha/lib/mocha/object.rb +110 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers.rb +9 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/all_of.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/any_of.rb +44 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/anything.rb +30 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_entry.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_key.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_value.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/includes.rb +37 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb +39 -0
- data/lib/openssl/mocha/lib/mocha/pretty_parameters.rb +28 -0
- data/lib/openssl/mocha/lib/mocha/return_values.rb +31 -0
- data/lib/openssl/mocha/lib/mocha/setup_and_teardown.rb +23 -0
- data/lib/openssl/mocha/lib/mocha/single_return_value.rb +24 -0
- data/lib/openssl/mocha/lib/mocha/single_yield.rb +18 -0
- data/lib/openssl/mocha/lib/mocha/standalone.rb +32 -0
- data/lib/openssl/mocha/lib/mocha/stub.rb +18 -0
- data/lib/openssl/mocha/lib/mocha/test_case_adapter.rb +49 -0
- data/lib/openssl/mocha/lib/mocha/yield_parameters.rb +31 -0
- data/lib/openssl/mocha/lib/mocha_standalone.rb +2 -0
- data/lib/openssl/mocha/lib/stubba.rb +2 -0
- data/lib/openssl/mocha/templates/html_with_google_analytics.rb +742 -0
- data/lib/openssl/mocha/test/acceptance/expected_invocation_count_acceptance_test.rb +187 -0
- data/lib/openssl/mocha/test/acceptance/mocha_acceptance_test.rb +98 -0
- data/lib/openssl/mocha/test/acceptance/mocked_methods_dispatch_acceptance_test.rb +71 -0
- data/lib/openssl/mocha/test/acceptance/parameter_matcher_acceptance_test.rb +63 -0
- data/lib/openssl/mocha/test/acceptance/standalone_acceptance_test.rb +131 -0
- data/lib/openssl/mocha/test/acceptance/stubba_acceptance_test.rb +102 -0
- data/lib/openssl/mocha/test/active_record_test_case.rb +36 -0
- data/lib/openssl/mocha/test/deprecation_disabler.rb +15 -0
- data/lib/openssl/mocha/test/execution_point.rb +34 -0
- data/lib/openssl/mocha/test/integration/mocha_test_result_integration_test.rb +105 -0
- data/lib/openssl/mocha/test/integration/stubba_integration_test.rb +89 -0
- data/lib/openssl/mocha/test/integration/stubba_test_result_integration_test.rb +85 -0
- data/lib/openssl/mocha/test/method_definer.rb +18 -0
- data/lib/openssl/mocha/test/test_helper.rb +12 -0
- data/lib/openssl/mocha/test/test_runner.rb +31 -0
- data/lib/openssl/mocha/test/unit/any_instance_method_test.rb +124 -0
- data/lib/openssl/mocha/test/unit/array_inspect_test.rb +16 -0
- data/lib/openssl/mocha/test/unit/auto_verify_test.rb +122 -0
- data/lib/openssl/mocha/test/unit/central_test.rb +124 -0
- data/lib/openssl/mocha/test/unit/class_method_test.rb +196 -0
- data/lib/openssl/mocha/test/unit/date_time_inspect_test.rb +21 -0
- data/lib/openssl/mocha/test/unit/expectation_list_test.rb +69 -0
- data/lib/openssl/mocha/test/unit/expectation_raiser_test.rb +28 -0
- data/lib/openssl/mocha/test/unit/expectation_test.rb +399 -0
- data/lib/openssl/mocha/test/unit/hash_inspect_test.rb +16 -0
- data/lib/openssl/mocha/test/unit/infinite_range_test.rb +53 -0
- data/lib/openssl/mocha/test/unit/metaclass_test.rb +22 -0
- data/lib/openssl/mocha/test/unit/missing_expectation_test.rb +45 -0
- data/lib/openssl/mocha/test/unit/mock_test.rb +316 -0
- data/lib/openssl/mocha/test/unit/multiple_yields_test.rb +18 -0
- data/lib/openssl/mocha/test/unit/no_yield_test.rb +18 -0
- data/lib/openssl/mocha/test/unit/object_inspect_test.rb +35 -0
- data/lib/openssl/mocha/test/unit/object_test.rb +165 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/all_of_test.rb +26 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/any_of_test.rb +26 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/anything_test.rb +21 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/has_entry_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/has_key_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/has_value_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/includes_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/instance_of_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/kind_of_test.rb +25 -0
- data/lib/openssl/mocha/test/unit/parameter_matchers/stub_matcher.rb +22 -0
- data/lib/openssl/mocha/test/unit/pretty_parameters_test.rb +32 -0
- data/lib/openssl/mocha/test/unit/return_values_test.rb +63 -0
- data/lib/openssl/mocha/test/unit/setup_and_teardown_test.rb +76 -0
- data/lib/openssl/mocha/test/unit/single_return_value_test.rb +33 -0
- data/lib/openssl/mocha/test/unit/single_yield_test.rb +18 -0
- data/lib/openssl/mocha/test/unit/string_inspect_test.rb +11 -0
- data/lib/openssl/mocha/test/unit/stub_test.rb +24 -0
- data/lib/openssl/mocha/test/unit/yield_parameters_test.rb +93 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/FOLDERS +53 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/LICENSE +340 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/README +117 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/bin/coderay +77 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/bin/coderay_stylesheet +4 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay.rb +319 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/duo.rb +29 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoder.rb +173 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/_map.rb +8 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/count.rb +21 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/debug.rb +46 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/div.rb +20 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html.rb +260 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/classes.rb +77 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/css.rb +65 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/numerization.rb +122 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/output.rb +195 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/null.rb +26 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/page.rb +21 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/span.rb +20 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/statistic.rb +81 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/text.rb +33 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/tokens.rb +44 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/xml.rb +71 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/yaml.rb +22 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/file_type.rb +182 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/gzip_simple.rb +122 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/plugin.rb +326 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/word_list.rb +119 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanner.rb +238 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/_map.rb +15 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/c.rb +163 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/debug.rb +60 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/delphi.rb +149 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/html.rb +177 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/nitro_xhtml.rb +133 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/plaintext.rb +16 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/rhtml.rb +73 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/ruby.rb +367 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/ruby/patterns.rb +230 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/xml.rb +18 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/style.rb +20 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/_map.rb +7 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/cycnus.rb +125 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/murphy.rb +119 -0
- data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/tokens.rb +368 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/CHANGES +295 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/MIT-LICENSE +21 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/README +129 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/Rakefile +152 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project.rb +19 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/open_uri.rb +22 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/pathname.rb +36 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/string.rb +5 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/http/multipart.rb +32 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/patois.rb +1 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/patois/parser.rb +99 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project.rb +4 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/base.rb +9 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/codehaus.rb +1 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/codehaus/codehaus_project_svn.rb +31 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/trac.rb +1 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/trac/trac_project.rb +54 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge.rb +5 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/ruby_forge.rb +47 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/session.rb +177 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/source_forge.rb +50 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/xfile.rb +45 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/xforge_base.rb +85 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project_analyzer.rb +36 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/release/freshmeat.rb +267 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/release/raa.rb +572 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web.rb +2 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web/browser.rb +112 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web/pathname.rb +89 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker.rb +6 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/base.rb +24 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/digit_issues.rb +34 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/issue.rb +57 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira.rb +2 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira/jira_issues.rb +35 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira/jira_tracker.rb +149 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/trac.rb +1 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/trac/trac_tracker.rb +33 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge.rb +3 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/ruby_forge_tracker.rb +17 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/source_forge_tracker.rb +17 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/xforge_tracker.rb +191 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/version_parser.rb +52 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge.rb +3 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/base.rb +64 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/news_publisher.rb +97 -0
- data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/release.rb +134 -0
- data/lib/openssl/nbproject/genfiles.properties +5 -0
- data/lib/openssl/nbproject/jdk.xml +157 -0
- data/lib/openssl/nbproject/nbjdk.properties +1 -0
- data/lib/openssl/nbproject/nbjdk.xml +16 -0
- data/lib/openssl/nbproject/project.xml +117 -0
- data/lib/openssl/src/java/JopensslService.java +41 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/ASN1.java +930 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Attribute.java +132 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/BN.java +769 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/BouncyCastlePEMHandler.java +69 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Callable.java +10 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Cipher.java +661 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/CipherStrings.java +1827 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Config.java +49 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/DefaultPEMHandler.java +44 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Digest.java +207 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/HMAC.java +183 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/NetscapeSPKI.java +212 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/OpenSSLImpl.java +341 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/OpenSSLReal.java +113 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PEMHandler.java +40 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKCS10CertificationRequestExt.java +159 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKCS7.java +642 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKey.java +154 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyDH.java +401 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyDSA.java +419 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyRSA.java +762 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Random.java +103 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Request.java +336 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/SSL.java +71 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/SSLContext.java +358 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/SSLSocket.java +561 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/SimpleSecretKey.java +53 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/Utils.java +60 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509.java +108 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509CRL.java +446 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Cert.java +520 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Extensions.java +751 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Name.java +405 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Revoked.java +111 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509Store.java +282 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/X509StoreCtx.java +206 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/ASN1Registry.java +5135 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Attribute.java +79 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/BIO.java +345 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/BIOFilter.java +38 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Base64BIOFilter.java +84 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/CipherBIOFilter.java +157 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Digest.java +126 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/EVP.java +136 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/EncContent.java +178 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Encrypt.java +77 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Envelope.java +169 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/IssuerAndSerial.java +35 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MemBIO.java +117 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MessageDigestBIOFilter.java +76 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Mime.java +245 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MimeHeader.java +103 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MimeParam.java +69 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/NotVerifiedPKCS7Exception.java +38 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/NullSinkBIO.java +52 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7.java +1276 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7Data.java +168 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataData.java +88 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataDigest.java +64 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataEncrypted.java +61 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataEnveloped.java +85 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataSigned.java +127 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataSignedAndEnveloped.java +91 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7Exception.java +68 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/RecipInfo.java +244 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SMIME.java +281 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SignEnvelope.java +202 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Signed.java +345 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SignerInfoWithPkey.java +365 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/TypeDiscriminating.java +34 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/impl/utils/Base64.java +1809 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/util/Base64Coder.java +103 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CRL.java +59 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Certificate.java +57 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CertificateFile.java +46 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CertificateHashDir.java +46 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function0.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function1.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function2.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function3.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function4.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function5.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Lookup.java +560 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/LookupMethod.java +84 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Name.java +85 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PEMInputOutput.java +1210 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PKey.java +41 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PolicyTree.java +36 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Purpose.java +475 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Store.java +377 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/StoreContext.java +1356 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Trust.java +279 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/VerifyParameter.java +324 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Aux.java +43 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509AuxCertificate.java +170 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Error.java +70 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Object.java +88 -0
- data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Utils.java +541 -0
- data/lib/openssl/test/cert_with_ec_pk.cer +27 -0
- data/lib/openssl/test/fixture/ca_path/72fa7371.0 +19 -0
- data/lib/openssl/test/fixture/ca_path/verisign.pem +19 -0
- data/lib/openssl/test/fixture/cacert.pem +23 -0
- data/lib/openssl/test/fixture/cert_localhost.pem +19 -0
- data/lib/openssl/test/fixture/common.pem +48 -0
- data/lib/openssl/test/fixture/localhost_keypair.pem +18 -0
- data/lib/openssl/test/fixture/max.pem +29 -0
- data/lib/openssl/test/fixture/purpose/b70a5bc1.0 +24 -0
- data/lib/openssl/test/fixture/purpose/ca/PASSWD_OF_CA_KEY_IS_1234 +0 -0
- data/lib/openssl/test/fixture/purpose/ca/ca_config.rb +37 -0
- data/lib/openssl/test/fixture/purpose/ca/cacert.pem +24 -0
- data/lib/openssl/test/fixture/purpose/ca/newcerts/2_cert.pem +19 -0
- data/lib/openssl/test/fixture/purpose/ca/newcerts/3_cert.pem +19 -0
- data/lib/openssl/test/fixture/purpose/ca/private/cakeypair.pem +30 -0
- data/lib/openssl/test/fixture/purpose/ca/serial +1 -0
- data/lib/openssl/test/fixture/purpose/cacert.pem +24 -0
- data/lib/openssl/test/fixture/purpose/scripts/gen_cert.rb +127 -0
- data/lib/openssl/test/fixture/purpose/scripts/gen_csr.rb +50 -0
- data/lib/openssl/test/fixture/purpose/scripts/init_ca.rb +66 -0
- data/lib/openssl/test/fixture/purpose/sslclient.pem +19 -0
- data/lib/openssl/test/fixture/purpose/sslclient/csr.pem +10 -0
- data/lib/openssl/test/fixture/purpose/sslclient/keypair.pem +15 -0
- data/lib/openssl/test/fixture/purpose/sslclient/sslclient.pem +19 -0
- data/lib/openssl/test/fixture/purpose/sslserver.pem +19 -0
- data/lib/openssl/test/fixture/purpose/sslserver/csr.pem +10 -0
- data/lib/openssl/test/fixture/purpose/sslserver/keypair.pem +15 -0
- data/lib/openssl/test/fixture/purpose/sslserver/sslserver.pem +19 -0
- data/lib/openssl/test/fixture/verisign.pem +19 -0
- data/lib/openssl/test/fixture/verisign_c3.pem +14 -0
- data/lib/openssl/test/openssl/ssl_server.rb +99 -0
- data/lib/openssl/test/openssl/test_asn1.rb +199 -0
- data/lib/openssl/test/openssl/test_cipher.rb +196 -0
- data/lib/openssl/test/openssl/test_digest.rb +88 -0
- data/lib/openssl/test/openssl/test_hmac.rb +44 -0
- data/lib/openssl/test/openssl/test_ns_spki.rb +69 -0
- data/lib/openssl/test/openssl/test_pair.rb +149 -0
- data/lib/openssl/test/openssl/test_pkcs7.rb +160 -0
- data/lib/openssl/test/openssl/test_pkey_rsa.rb +49 -0
- data/lib/openssl/test/openssl/test_ssl.rb +413 -0
- data/lib/openssl/test/openssl/test_x509cert.rb +236 -0
- data/lib/openssl/test/openssl/test_x509crl.rb +234 -0
- data/lib/openssl/test/openssl/test_x509ext.rb +95 -0
- data/lib/openssl/test/openssl/test_x509name.rb +281 -0
- data/lib/openssl/test/openssl/test_x509req.rb +178 -0
- data/lib/openssl/test/openssl/test_x509store.rb +245 -0
- data/lib/openssl/test/openssl/utils.rb +135 -0
- data/lib/openssl/test/pkcs7_mime_enveloped.message +19 -0
- data/lib/openssl/test/pkcs7_mime_signed.message +30 -0
- data/lib/openssl/test/pkcs7_multipart_signed.message +45 -0
- data/lib/openssl/test/ref/compile.rb +8 -0
- data/lib/openssl/test/ref/pkcs1 +0 -0
- data/lib/openssl/test/ref/pkcs1.c +21 -0
- data/lib/openssl/test/test_cipher.rb +95 -0
- data/lib/openssl/test/test_integration.rb +139 -0
- data/lib/openssl/test/test_java.rb +98 -0
- data/lib/openssl/test/test_java_attribute.rb +25 -0
- data/lib/openssl/test/test_java_bio.rb +42 -0
- data/lib/openssl/test/test_java_mime.rb +173 -0
- data/lib/openssl/test/test_java_pkcs7.rb +769 -0
- data/lib/openssl/test/test_java_smime.rb +177 -0
- data/lib/openssl/test/test_openssl.rb +34 -0
- data/lib/openssl/test/test_openssl_x509.rb +34 -0
- data/lib/openssl/test/test_parse_certificate.rb +20 -0
- data/lib/openssl/test/test_pkey.rb +46 -0
- data/lib/openssl/test/test_x509store.rb +155 -0
- data/lib/openssl/test/ut_eof.rb +128 -0
- data/lib/redcar.rb +134 -8
- data/lib/redcar/installer.rb +46 -11
- data/lib/redcar/runner.rb +2 -1
- data/lib/redcar/usage.rb +12 -5
- data/lib/redcar_quick_start.rb +37 -0
- data/plugins/application/features/support/env.rb +9 -1
- data/plugins/application/icons/redcar_icon_beta.png +0 -0
- data/plugins/application/lib/application.rb +113 -43
- data/plugins/application/lib/application/clipboard.rb +28 -4
- data/plugins/application/lib/application/command.rb +4 -12
- data/plugins/application/lib/application/command/executor.rb +2 -2
- data/plugins/application/lib/application/keymap.rb +39 -0
- data/plugins/application/lib/application/keymap/builder.rb +19 -0
- data/plugins/application/lib/application/speedbar.rb +33 -24
- data/plugins/application/lib/application/tab.rb +15 -0
- data/plugins/application/lib/application/window.rb +28 -5
- data/plugins/application/spec/application/clipboard_spec.rb +20 -1
- data/plugins/application/spec/application/command/executor_spec.rb +7 -2
- data/plugins/application/spec/application/command_spec.rb +0 -5
- data/plugins/application/spec/application/keymap/builder_spec.rb +17 -0
- data/plugins/application/spec/application/menu_spec.rb +30 -0
- data/plugins/application/spec/application/speedbar_spec.rb +30 -6
- data/plugins/application/spec/application/window_spec.rb +2 -2
- data/plugins/application/spec/spec_helper.rb +1 -1
- data/plugins/application_swt/lib/application_swt.rb +3 -0
- data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +10 -1
- data/plugins/application_swt/lib/application_swt/html_tab.rb +1 -0
- data/plugins/application_swt/lib/application_swt/menu.rb +4 -3
- data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +12 -4
- data/plugins/application_swt/lib/application_swt/speedbar.rb +105 -19
- data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +2 -0
- data/plugins/application_swt/lib/application_swt/window.rb +55 -23
- data/plugins/application_swt/spec/spec_helper.rb +0 -1
- data/plugins/auto_completer/lib/auto_completer.rb +57 -3
- data/plugins/auto_indenter/lib/auto_indenter.rb +1 -1
- data/plugins/core/lib/core.rb +5 -3
- data/plugins/core/lib/core/interface.rb +73 -0
- data/plugins/core/lib/core/model.rb +2 -0
- data/plugins/core/lib/core/observable.rb +12 -1
- data/plugins/core/lib/core/observable_struct.rb +34 -0
- data/plugins/core/lib/core/plugin/storage.rb +16 -3
- data/plugins/core/lib/core/reentry_helpers.rb +13 -0
- data/plugins/core/spec/core/observable_spec.rb +13 -0
- data/plugins/core/spec/core/storage_spec.rb +18 -0
- data/plugins/core/spec/spec_helper.rb +1 -0
- data/plugins/edit_view/features/cut_and_paste.feature +4 -2
- data/plugins/edit_view/features/soft_tabs.feature +243 -0
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +91 -2
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
- data/plugins/edit_view/features/tabs.feature +146 -0
- data/plugins/edit_view/lib/edit_view.rb +197 -8
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +121 -0
- data/plugins/edit_view/lib/edit_view/actions/deletion.rb +30 -0
- data/plugins/edit_view/lib/edit_view/actions/tab.rb +66 -0
- data/plugins/edit_view/lib/edit_view/command.rb +0 -2
- data/plugins/edit_view/lib/edit_view/document.rb +62 -27
- data/plugins/edit_view/lib/edit_view/document/command.rb +11 -0
- data/plugins/edit_view/lib/edit_view/edit_tab.rb +2 -1
- data/plugins/edit_view/lib/edit_view/info_speedbar.rb +69 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +40 -0
- data/plugins/edit_view/spec/edit_view/document_spec.rb +26 -0
- data/plugins/edit_view/spec/spec_helper.rb +0 -1
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +57 -69
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +24 -3
- data/plugins/edit_view_swt/lib/edit_view_swt/edit_tab.rb +23 -6
- data/plugins/edit_view_swt/spec/spec_helper.rb +0 -1
- data/plugins/edit_view_swt/vendor/java-mateview.rb +19 -2
- data/plugins/encryption/encryption.rb +38 -0
- data/plugins/encryption/ezcrypto.rb +652 -0
- data/plugins/encryption/jarmor-1.1.jar +0 -0
- data/plugins/encryption/plugin.rb +9 -0
- data/plugins/execute_current_tab/lib/execute_current_tab.rb +56 -0
- data/plugins/execute_current_tab/plugin.rb +8 -0
- data/plugins/html_view/lib/html_view.rb +16 -11
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +2 -1
- data/plugins/plugin_manager_ui/views/index.html.erb +22 -4
- data/plugins/project/lib/project.rb +140 -26
- data/plugins/project/lib/project/drb_service.rb +75 -0
- data/plugins/project/lib/project/file_mirror.rb +5 -5
- data/plugins/project/lib/project/find_file_dialog.rb +123 -32
- data/plugins/project/spec/project/file_mirror_spec.rb +10 -1
- data/plugins/project/spec/spec_helper.rb +0 -1
- data/plugins/redcar/plugin.rb +1 -1
- data/plugins/redcar/redcar.rb +204 -109
- data/plugins/redcar/spec/redcar/redcar_spec.rb +70 -0
- data/plugins/redcar/spec/spec_helper.rb +4 -0
- data/plugins/repl/lib/repl.rb +14 -7
- data/plugins/repl/lib/repl/internal_mirror.rb +43 -22
- data/plugins/repl/spec/repl/internal_mirror_spec.rb +34 -7
- data/plugins/repl/spec/spec_helper.rb +0 -1
- data/plugins/tree/spec/spec_helper.rb +0 -1
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +1 -1
- data/textmate/Bundles/RedcarRepl.tmbundle/Syntaxes/InternalRuby.plist +2 -18
- data/textmate/Bundles/asciidoc.tmbundle/Syntaxes/AsciiDoc.tmLanguage +428 -0
- metadata +790 -371
- data/lib/redcar/boot.rb +0 -108
@@ -0,0 +1,69 @@
|
|
1
|
+
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Version: CPL 1.0/GPL 2.0/LGPL 2.1
|
3
|
+
*
|
4
|
+
* The contents of this file are subject to the Common Public
|
5
|
+
* License Version 1.0 (the "License"); you may not use this file
|
6
|
+
* except in compliance with the License. You may obtain a copy of
|
7
|
+
* the License at http://www.eclipse.org/legal/cpl-v10.html
|
8
|
+
*
|
9
|
+
* Software distributed under the License is distributed on an "AS
|
10
|
+
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
11
|
+
* implied. See the License for the specific language governing
|
12
|
+
* rights and limitations under the License.
|
13
|
+
*
|
14
|
+
* Copyright (C) 2008 Ola Bini <ola.bini@gmail.com>
|
15
|
+
*
|
16
|
+
* Alternatively, the contents of this file may be used under the terms of
|
17
|
+
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
18
|
+
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
19
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
20
|
+
* of those above. If you wish to allow use of your version of this file only
|
21
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
22
|
+
* use your version of this file under the terms of the CPL, indicate your
|
23
|
+
* decision by deleting the provisions above and replace them with the notice
|
24
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
25
|
+
* the provisions above, a recipient may use your version of this file under
|
26
|
+
* the terms of any one of the CPL, the GPL or the LGPL.
|
27
|
+
***** END LICENSE BLOCK *****/
|
28
|
+
package org.jruby.ext.openssl.impl;
|
29
|
+
|
30
|
+
/** MIME_PARAM
|
31
|
+
*
|
32
|
+
* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
|
33
|
+
*/
|
34
|
+
public class MimeParam {
|
35
|
+
private String paramName;
|
36
|
+
private String paramValue;
|
37
|
+
|
38
|
+
public MimeParam(String name, String value) {
|
39
|
+
this.paramName = (name == null) ?
|
40
|
+
null :
|
41
|
+
name.toLowerCase();
|
42
|
+
this.paramValue = value;
|
43
|
+
}
|
44
|
+
|
45
|
+
public String getParamName() {
|
46
|
+
return this.paramName;
|
47
|
+
}
|
48
|
+
|
49
|
+
public String getParamValue() {
|
50
|
+
return this.paramValue;
|
51
|
+
}
|
52
|
+
|
53
|
+
@Override
|
54
|
+
public boolean equals(Object other) {
|
55
|
+
boolean ret = this == other;
|
56
|
+
if(!ret && (other instanceof MimeParam)) {
|
57
|
+
MimeParam mh = (MimeParam)other;
|
58
|
+
ret =
|
59
|
+
((this.paramName == null) ? mh.paramName == null : this.paramName.equals(mh.paramName)) &&
|
60
|
+
((this.paramValue == null) ? mh.paramValue == null : this.paramValue.equals(mh.paramValue));
|
61
|
+
}
|
62
|
+
return ret;
|
63
|
+
}
|
64
|
+
|
65
|
+
@Override
|
66
|
+
public String toString() {
|
67
|
+
return "#<Param " + paramName + "="+paramValue+">";
|
68
|
+
}
|
69
|
+
}// MimeParam
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Version: CPL 1.0/GPL 2.0/LGPL 2.1
|
3
|
+
*
|
4
|
+
* The contents of this file are subject to the Common Public
|
5
|
+
* License Version 1.0 (the "License"); you may not use this file
|
6
|
+
* except in compliance with the License. You may obtain a copy of
|
7
|
+
* the License at http://www.eclipse.org/legal/cpl-v10.html
|
8
|
+
*
|
9
|
+
* Software distributed under the License is distributed on an "AS
|
10
|
+
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
11
|
+
* implied. See the License for the specific language governing
|
12
|
+
* rights and limitations under the License.
|
13
|
+
*
|
14
|
+
* Copyright (C) 2008 Ola Bini <ola.bini@gmail.com>
|
15
|
+
*
|
16
|
+
* Alternatively, the contents of this file may be used under the terms of
|
17
|
+
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
18
|
+
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
19
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
20
|
+
* of those above. If you wish to allow use of your version of this file only
|
21
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
22
|
+
* use your version of this file under the terms of the CPL, indicate your
|
23
|
+
* decision by deleting the provisions above and replace them with the notice
|
24
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
25
|
+
* the provisions above, a recipient may use your version of this file under
|
26
|
+
* the terms of any one of the CPL, the GPL or the LGPL.
|
27
|
+
***** END LICENSE BLOCK *****/
|
28
|
+
package org.jruby.ext.openssl.impl;
|
29
|
+
|
30
|
+
/**
|
31
|
+
*
|
32
|
+
* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
|
33
|
+
*/
|
34
|
+
public class NotVerifiedPKCS7Exception extends PKCS7Exception {
|
35
|
+
public NotVerifiedPKCS7Exception() {
|
36
|
+
super(-1, -1);
|
37
|
+
}
|
38
|
+
}// NotVerifiedPKCS7Exception
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Version: CPL 1.0/GPL 2.0/LGPL 2.1
|
3
|
+
*
|
4
|
+
* The contents of this file are subject to the Common Public
|
5
|
+
* License Version 1.0 (the "License"); you may not use this file
|
6
|
+
* except in compliance with the License. You may obtain a copy of
|
7
|
+
* the License at http://www.eclipse.org/legal/cpl-v10.html
|
8
|
+
*
|
9
|
+
* Software distributed under the License is distributed on an "AS
|
10
|
+
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
11
|
+
* implied. See the License for the specific language governing
|
12
|
+
* rights and limitations under the License.
|
13
|
+
*
|
14
|
+
* Copyright (C) 2008 Ola Bini <ola.bini@gmail.com>
|
15
|
+
*
|
16
|
+
* Alternatively, the contents of this file may be used under the terms of
|
17
|
+
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
18
|
+
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
19
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
20
|
+
* of those above. If you wish to allow use of your version of this file only
|
21
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
22
|
+
* use your version of this file under the terms of the CPL, indicate your
|
23
|
+
* decision by deleting the provisions above and replace them with the notice
|
24
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
25
|
+
* the provisions above, a recipient may use your version of this file under
|
26
|
+
* the terms of any one of the CPL, the GPL or the LGPL.
|
27
|
+
***** END LICENSE BLOCK *****/
|
28
|
+
package org.jruby.ext.openssl.impl;
|
29
|
+
|
30
|
+
import java.io.IOException;
|
31
|
+
|
32
|
+
/**
|
33
|
+
*
|
34
|
+
* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
|
35
|
+
*/
|
36
|
+
public class NullSinkBIO extends BIO {
|
37
|
+
public int gets(byte[] in, int len) throws IOException {
|
38
|
+
return 0;
|
39
|
+
}
|
40
|
+
|
41
|
+
public int write(byte[] out, int offset, int len) throws IOException {
|
42
|
+
return len;
|
43
|
+
}
|
44
|
+
|
45
|
+
public int read(byte[] into, int offset, int len) throws IOException {
|
46
|
+
return 0;
|
47
|
+
}
|
48
|
+
|
49
|
+
public int getType() {
|
50
|
+
return TYPE_NULL;
|
51
|
+
}
|
52
|
+
}// NullSinkBIO
|
@@ -0,0 +1,1276 @@
|
|
1
|
+
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Version: CPL 1.0/GPL 2.0/LGPL 2.1
|
3
|
+
*
|
4
|
+
* The contents of this file are subject to the Common Public
|
5
|
+
* License Version 1.0 (the "License"); you may not use this file
|
6
|
+
* except in compliance with the License. You may obtain a copy of
|
7
|
+
* the License at http://www.eclipse.org/legal/cpl-v10.html
|
8
|
+
*
|
9
|
+
* Software distributed under the License is distributed on an "AS
|
10
|
+
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
11
|
+
* implied. See the License for the specific language governing
|
12
|
+
* rights and limitations under the License.
|
13
|
+
*
|
14
|
+
* Copyright (C) 2008 Ola Bini <ola.bini@gmail.com>
|
15
|
+
*
|
16
|
+
* Alternatively, the contents of this file may be used under the terms of
|
17
|
+
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
18
|
+
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
19
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
20
|
+
* of those above. If you wish to allow use of your version of this file only
|
21
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
22
|
+
* use your version of this file under the terms of the CPL, indicate your
|
23
|
+
* decision by deleting the provisions above and replace them with the notice
|
24
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
25
|
+
* the provisions above, a recipient may use your version of this file under
|
26
|
+
* the terms of any one of the CPL, the GPL or the LGPL.
|
27
|
+
***** END LICENSE BLOCK *****/
|
28
|
+
package org.jruby.ext.openssl.impl;
|
29
|
+
|
30
|
+
import java.io.IOException;
|
31
|
+
import java.math.BigInteger;
|
32
|
+
import java.security.MessageDigest;
|
33
|
+
import java.security.PrivateKey;
|
34
|
+
import java.security.PublicKey;
|
35
|
+
import java.security.SecureRandom;
|
36
|
+
import java.security.Signature;
|
37
|
+
import java.security.cert.X509CRL;
|
38
|
+
import java.util.ArrayList;
|
39
|
+
import java.util.Arrays;
|
40
|
+
import java.util.Calendar;
|
41
|
+
import java.util.Collection;
|
42
|
+
import java.util.Iterator;
|
43
|
+
import java.util.List;
|
44
|
+
import java.util.TimeZone;
|
45
|
+
import javax.crypto.Cipher;
|
46
|
+
import javax.crypto.KeyGenerator;
|
47
|
+
import javax.crypto.SecretKey;
|
48
|
+
import javax.crypto.spec.IvParameterSpec;
|
49
|
+
import javax.crypto.spec.SecretKeySpec;
|
50
|
+
import org.bouncycastle.asn1.ASN1Encodable;
|
51
|
+
import org.bouncycastle.asn1.ASN1EncodableVector;
|
52
|
+
import org.bouncycastle.asn1.ASN1InputStream;
|
53
|
+
import org.bouncycastle.asn1.ASN1OctetString;
|
54
|
+
import org.bouncycastle.asn1.ASN1Sequence;
|
55
|
+
import org.bouncycastle.asn1.ASN1Set;
|
56
|
+
import org.bouncycastle.asn1.DEREncodable;
|
57
|
+
import org.bouncycastle.asn1.DERInteger;
|
58
|
+
import org.bouncycastle.asn1.DERObject;
|
59
|
+
import org.bouncycastle.asn1.DERObjectIdentifier;
|
60
|
+
import org.bouncycastle.asn1.DEROctetString;
|
61
|
+
import org.bouncycastle.asn1.DERSequence;
|
62
|
+
import org.bouncycastle.asn1.DERTaggedObject;
|
63
|
+
import org.bouncycastle.asn1.DERUTCTime;
|
64
|
+
import org.bouncycastle.asn1.pkcs.Attribute;
|
65
|
+
import org.bouncycastle.asn1.pkcs.IssuerAndSerialNumber;
|
66
|
+
import org.bouncycastle.asn1.pkcs.SignerInfo;
|
67
|
+
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
68
|
+
import org.bouncycastle.asn1.x509.X509Name;
|
69
|
+
import org.jruby.ext.openssl.OpenSSLReal;
|
70
|
+
import org.jruby.ext.openssl.x509store.Name;
|
71
|
+
import org.jruby.ext.openssl.x509store.Store;
|
72
|
+
import org.jruby.ext.openssl.x509store.StoreContext;
|
73
|
+
import org.jruby.ext.openssl.x509store.X509AuxCertificate;
|
74
|
+
import org.jruby.ext.openssl.x509store.X509Utils;
|
75
|
+
|
76
|
+
/** c: PKCS7
|
77
|
+
*
|
78
|
+
* Basically equivalent of the ContentInfo structures in PKCS#7.
|
79
|
+
*
|
80
|
+
* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
|
81
|
+
*/
|
82
|
+
public class PKCS7 {
|
83
|
+
// Used during processing
|
84
|
+
private int state;
|
85
|
+
|
86
|
+
/* content as defined by the type */
|
87
|
+
/* all encryption/message digests are applied to the 'contents',
|
88
|
+
* leaving out the 'type' field. */
|
89
|
+
|
90
|
+
private PKCS7Data data;
|
91
|
+
|
92
|
+
public Object ctrl(int cmd, Object v, Object ignored) {
|
93
|
+
return this.data.ctrl(cmd, v, ignored);
|
94
|
+
}
|
95
|
+
|
96
|
+
public void setDetached(int v) {
|
97
|
+
ctrl(OP_SET_DETACHED_SIGNATURE, Integer.valueOf(v), null);
|
98
|
+
}
|
99
|
+
|
100
|
+
public int getDetached() {
|
101
|
+
return ((Integer)ctrl(OP_GET_DETACHED_SIGNATURE, null, null)).intValue();
|
102
|
+
}
|
103
|
+
|
104
|
+
public boolean isDetached() {
|
105
|
+
return isSigned() && getDetached() != 0;
|
106
|
+
}
|
107
|
+
|
108
|
+
private static void printDER(String moniker, DEREncodable object) {
|
109
|
+
System.err.println(moniker + " " + object + "{" + object.getClass().getName() + "}");
|
110
|
+
}
|
111
|
+
|
112
|
+
private void initiateWith(Integer nid, DEREncodable content) {
|
113
|
+
this.data = PKCS7Data.fromASN1(nid, content);
|
114
|
+
}
|
115
|
+
|
116
|
+
/**
|
117
|
+
* ContentInfo ::= SEQUENCE {
|
118
|
+
* contentType ContentType,
|
119
|
+
* content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
|
120
|
+
*
|
121
|
+
* ContentType ::= OBJECT IDENTIFIER
|
122
|
+
*/
|
123
|
+
public static PKCS7 fromASN1(DEREncodable obj) {
|
124
|
+
int size = ((ASN1Sequence)obj).size();
|
125
|
+
if(size == 0) {
|
126
|
+
return new PKCS7();
|
127
|
+
}
|
128
|
+
|
129
|
+
DERObjectIdentifier contentType = (DERObjectIdentifier)(((ASN1Sequence)obj).getObjectAt(0));
|
130
|
+
int nid = ASN1Registry.obj2nid(contentType);
|
131
|
+
|
132
|
+
DEREncodable content = size == 1 ? (DEREncodable)null : ((ASN1Sequence)obj).getObjectAt(1);
|
133
|
+
|
134
|
+
if(content != null && content instanceof DERTaggedObject && ((DERTaggedObject)content).getTagNo() == 0) {
|
135
|
+
content = ((DERTaggedObject)content).getObject();
|
136
|
+
}
|
137
|
+
|
138
|
+
PKCS7 p7 = new PKCS7();
|
139
|
+
p7.initiateWith(nid, content);
|
140
|
+
return p7;
|
141
|
+
}
|
142
|
+
|
143
|
+
/* c: d2i_PKCS7_bio
|
144
|
+
*
|
145
|
+
*/
|
146
|
+
public static PKCS7 fromASN1(BIO bio) throws IOException {
|
147
|
+
ASN1InputStream ais = new ASN1InputStream(BIO.asInputStream(bio));
|
148
|
+
return fromASN1(ais.readObject());
|
149
|
+
}
|
150
|
+
|
151
|
+
public ASN1Encodable asASN1() {
|
152
|
+
ASN1EncodableVector vector = new ASN1EncodableVector();
|
153
|
+
DERObjectIdentifier contentType = ASN1Registry.nid2obj(getType());
|
154
|
+
vector.add(contentType);
|
155
|
+
vector.add(data.asASN1());
|
156
|
+
|
157
|
+
return new DERSequence(vector);
|
158
|
+
}
|
159
|
+
|
160
|
+
/* c: i2d_PKCS7
|
161
|
+
*
|
162
|
+
*/
|
163
|
+
public byte[] toASN1() throws IOException {
|
164
|
+
return asASN1().getEncoded();
|
165
|
+
}
|
166
|
+
|
167
|
+
/* c: PKCS7_add_signature
|
168
|
+
*
|
169
|
+
*/
|
170
|
+
public SignerInfoWithPkey addSignature(X509AuxCertificate x509, PrivateKey pkey, MessageDigest dgst) {
|
171
|
+
SignerInfoWithPkey si = new SignerInfoWithPkey();
|
172
|
+
si.set(x509, pkey, dgst);
|
173
|
+
addSigner(si);
|
174
|
+
return si;
|
175
|
+
}
|
176
|
+
|
177
|
+
/* c: X509_find_by_issuer_and_serial
|
178
|
+
*
|
179
|
+
*/
|
180
|
+
public static X509AuxCertificate findByIssuerAndSerial(Collection<X509AuxCertificate> certs, X509Name issuer, BigInteger serial) {
|
181
|
+
Name name = new Name(issuer);
|
182
|
+
for(X509AuxCertificate cert : certs) {
|
183
|
+
if(name.isEqual(cert.getIssuerX500Principal()) && serial.equals(cert.getSerialNumber())) {
|
184
|
+
return cert;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
return null;
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
/* c: PKCS7_get0_signers
|
192
|
+
*
|
193
|
+
*/
|
194
|
+
public List<X509AuxCertificate> getSigners(Collection<X509AuxCertificate> certs, List<SignerInfoWithPkey> sinfos, int flags) {
|
195
|
+
List<X509AuxCertificate> signers = new ArrayList<X509AuxCertificate>();
|
196
|
+
|
197
|
+
if(!isSigned()) {
|
198
|
+
throw new PKCS7Exception(F_PKCS7_GET0_SIGNERS,R_WRONG_CONTENT_TYPE);
|
199
|
+
}
|
200
|
+
|
201
|
+
if(sinfos.size() == 0) {
|
202
|
+
throw new PKCS7Exception(F_PKCS7_GET0_SIGNERS,R_NO_SIGNERS);
|
203
|
+
}
|
204
|
+
|
205
|
+
for(SignerInfoWithPkey si : sinfos) {
|
206
|
+
IssuerAndSerialNumber ias = si.getIssuerAndSerialNumber();
|
207
|
+
X509AuxCertificate signer = null;
|
208
|
+
// System.err.println("looking for: " + ias.getName() + " and " + ias.getCertificateSerialNumber());
|
209
|
+
// System.err.println(" in: " + certs);
|
210
|
+
// System.err.println(" in: " + getSign().getCert());
|
211
|
+
if(certs != null) {
|
212
|
+
signer = findByIssuerAndSerial(certs, ias.getName(), ias.getCertificateSerialNumber().getValue());
|
213
|
+
}
|
214
|
+
if(signer == null && (flags & NOINTERN) == 0 && getSign().getCert() != null) {
|
215
|
+
signer = findByIssuerAndSerial(getSign().getCert(), ias.getName(), ias.getCertificateSerialNumber().getValue());
|
216
|
+
}
|
217
|
+
if(signer == null) {
|
218
|
+
throw new PKCS7Exception(F_PKCS7_GET0_SIGNERS,R_SIGNER_CERTIFICATE_NOT_FOUND);
|
219
|
+
}
|
220
|
+
signers.add(signer);
|
221
|
+
}
|
222
|
+
return signers;
|
223
|
+
}
|
224
|
+
|
225
|
+
/* c: PKCS7_digest_from_attributes
|
226
|
+
*
|
227
|
+
*/
|
228
|
+
public ASN1OctetString digestFromAttributes(ASN1Set attributes) {
|
229
|
+
return (ASN1OctetString)SignerInfoWithPkey.getAttribute(attributes, ASN1Registry.NID_pkcs9_messageDigest);
|
230
|
+
}
|
231
|
+
|
232
|
+
/* c: PKCS7_signatureVerify
|
233
|
+
*
|
234
|
+
*/
|
235
|
+
public void signatureVerify(BIO bio, SignerInfoWithPkey si, X509AuxCertificate x509) {
|
236
|
+
if(!isSigned() && !isSignedAndEnveloped()) {
|
237
|
+
throw new PKCS7Exception(F_PKCS7_SIGNATUREVERIFY, R_WRONG_PKCS7_TYPE);
|
238
|
+
}
|
239
|
+
|
240
|
+
int md_type = ASN1Registry.obj2nid(si.getDigestAlgorithm().getObjectId());
|
241
|
+
BIO btmp = bio;
|
242
|
+
MessageDigest mdc = null;
|
243
|
+
|
244
|
+
for(;;) {
|
245
|
+
if(btmp == null || (btmp = bio.findType(BIO.TYPE_MD)) == null) {
|
246
|
+
throw new PKCS7Exception(F_PKCS7_SIGNATUREVERIFY, R_UNABLE_TO_FIND_MESSAGE_DIGEST);
|
247
|
+
}
|
248
|
+
|
249
|
+
mdc = ((MessageDigestBIOFilter)btmp).getMessageDigest();
|
250
|
+
if(null == mdc) {
|
251
|
+
throw new PKCS7Exception(F_PKCS7_SIGNATUREVERIFY, -1);
|
252
|
+
}
|
253
|
+
|
254
|
+
if(EVP.type(mdc) == md_type) {
|
255
|
+
break;
|
256
|
+
}
|
257
|
+
|
258
|
+
btmp = btmp.next();
|
259
|
+
}
|
260
|
+
|
261
|
+
MessageDigest mdc_tmp = null;
|
262
|
+
try {
|
263
|
+
mdc_tmp = (MessageDigest)mdc.clone();
|
264
|
+
} catch(Exception e) {}
|
265
|
+
|
266
|
+
byte[] currentData = new byte[0];
|
267
|
+
|
268
|
+
ASN1Set sk = si.getAuthenticatedAttributes();
|
269
|
+
try {
|
270
|
+
if(sk != null && sk.size() > 0) {
|
271
|
+
byte[] md_dat = mdc_tmp.digest();
|
272
|
+
ASN1OctetString message_digest = digestFromAttributes(sk);
|
273
|
+
if(message_digest == null) {
|
274
|
+
throw new PKCS7Exception(F_PKCS7_SIGNATUREVERIFY, R_UNABLE_TO_FIND_MESSAGE_DIGEST);
|
275
|
+
}
|
276
|
+
if(!Arrays.equals(md_dat, message_digest.getOctets())) {
|
277
|
+
throw new NotVerifiedPKCS7Exception();
|
278
|
+
}
|
279
|
+
|
280
|
+
currentData = sk.getEncoded();
|
281
|
+
}
|
282
|
+
|
283
|
+
ASN1OctetString os = si.getEncryptedDigest();
|
284
|
+
PublicKey pkey = x509.getPublicKey();
|
285
|
+
|
286
|
+
Signature sign = Signature.getInstance(EVP.signatureAlgorithm(mdc_tmp, pkey));
|
287
|
+
sign.initVerify(pkey);
|
288
|
+
if(currentData.length > 0) {
|
289
|
+
sign.update(currentData);
|
290
|
+
}
|
291
|
+
if(!sign.verify(os.getOctets())) {
|
292
|
+
throw new NotVerifiedPKCS7Exception();
|
293
|
+
}
|
294
|
+
} catch(NotVerifiedPKCS7Exception e) {
|
295
|
+
throw e;
|
296
|
+
} catch(Exception e) {
|
297
|
+
System.err.println("Other exception");
|
298
|
+
e.printStackTrace();
|
299
|
+
throw new NotVerifiedPKCS7Exception();
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
/* c: PKCS7_verify
|
304
|
+
*
|
305
|
+
*/
|
306
|
+
public void verify(Collection<X509AuxCertificate> certs, Store store, BIO indata, BIO out, int flags) {
|
307
|
+
if(!isSigned()) {
|
308
|
+
throw new PKCS7Exception(F_PKCS7_VERIFY, R_WRONG_CONTENT_TYPE);
|
309
|
+
}
|
310
|
+
|
311
|
+
if(getDetached() != 0 && indata == null) {
|
312
|
+
throw new PKCS7Exception(F_PKCS7_VERIFY, R_NO_CONTENT);
|
313
|
+
}
|
314
|
+
|
315
|
+
List<SignerInfoWithPkey> sinfos = new ArrayList<SignerInfoWithPkey>(getSignerInfo());
|
316
|
+
if(sinfos == null || sinfos.size() == 0) {
|
317
|
+
throw new PKCS7Exception(F_PKCS7_VERIFY, R_NO_SIGNATURES_ON_DATA);
|
318
|
+
}
|
319
|
+
|
320
|
+
List<X509AuxCertificate> signers = getSigners(certs, sinfos, flags);
|
321
|
+
if(signers == null) {
|
322
|
+
throw new NotVerifiedPKCS7Exception();
|
323
|
+
}
|
324
|
+
|
325
|
+
/* Now verify the certificates */
|
326
|
+
if((flags & NOVERIFY) == 0) {
|
327
|
+
for(X509AuxCertificate signer : signers) {
|
328
|
+
StoreContext cert_ctx = new StoreContext();
|
329
|
+
if((flags & NOCHAIN) == 0) {
|
330
|
+
if(cert_ctx.init(store, signer, new ArrayList<X509AuxCertificate>(getSign().getCert())) == 0) {
|
331
|
+
throw new PKCS7Exception(F_PKCS7_VERIFY, -1);
|
332
|
+
}
|
333
|
+
cert_ctx.setPurpose(X509Utils.X509_PURPOSE_SMIME_SIGN);
|
334
|
+
} else if(cert_ctx.init(store, signer, null) == 0) {
|
335
|
+
throw new PKCS7Exception(F_PKCS7_VERIFY, -1);
|
336
|
+
}
|
337
|
+
if((flags & NOCRL) == 0) {
|
338
|
+
cert_ctx.setCRLs((List<X509CRL>)getSign().getCrl());
|
339
|
+
}
|
340
|
+
try {
|
341
|
+
int i = cert_ctx.verifyCertificate();
|
342
|
+
int j = 0;
|
343
|
+
if(i <= 0) {
|
344
|
+
j = cert_ctx.getError();
|
345
|
+
}
|
346
|
+
cert_ctx.cleanup();
|
347
|
+
if(i <= 0) {
|
348
|
+
throw new PKCS7Exception(F_PKCS7_VERIFY, R_CERTIFICATE_VERIFY_ERROR, "Verify error:" + X509Utils.verifyCertificateErrorString(j));
|
349
|
+
}
|
350
|
+
} catch(PKCS7Exception e) {
|
351
|
+
throw e;
|
352
|
+
} catch(Exception e) {
|
353
|
+
throw new PKCS7Exception(F_PKCS7_VERIFY, R_CERTIFICATE_VERIFY_ERROR, e);
|
354
|
+
}
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
BIO tmpin = indata;
|
359
|
+
BIO p7bio = dataInit(tmpin);
|
360
|
+
BIO tmpout = null;
|
361
|
+
if((flags & TEXT) != 0) {
|
362
|
+
tmpout = BIO.mem();
|
363
|
+
} else {
|
364
|
+
tmpout = out;
|
365
|
+
}
|
366
|
+
|
367
|
+
byte[] buf = new byte[4096];
|
368
|
+
for(;;) {
|
369
|
+
try {
|
370
|
+
int i = p7bio.read(buf, 0, buf.length);
|
371
|
+
if(i <= 0) {
|
372
|
+
break;
|
373
|
+
}
|
374
|
+
if(tmpout != null) {
|
375
|
+
tmpout.write(buf, 0, i);
|
376
|
+
}
|
377
|
+
} catch(IOException e) {
|
378
|
+
throw new PKCS7Exception(F_PKCS7_VERIFY, -1, e);
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
if((flags & TEXT) != 0) {
|
383
|
+
new SMIME(Mime.DEFAULT).text(tmpout, out);
|
384
|
+
}
|
385
|
+
|
386
|
+
if((flags & NOSIGS) == 0) {
|
387
|
+
for(int i=0; i<sinfos.size(); i++) {
|
388
|
+
SignerInfoWithPkey si = sinfos.get(i);
|
389
|
+
X509AuxCertificate signer = signers.get(i);
|
390
|
+
signatureVerify(p7bio, si, signer);
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
if(tmpin == indata) {
|
395
|
+
if(indata != null) {
|
396
|
+
p7bio.pop();
|
397
|
+
}
|
398
|
+
}
|
399
|
+
}
|
400
|
+
|
401
|
+
/* c: PKCS7_sign
|
402
|
+
*
|
403
|
+
*/
|
404
|
+
public static PKCS7 sign(X509AuxCertificate signcert, PrivateKey pkey, Collection<X509AuxCertificate> certs, BIO data, int flags) {
|
405
|
+
PKCS7 p7 = new PKCS7();
|
406
|
+
p7.setType(ASN1Registry.NID_pkcs7_signed);
|
407
|
+
p7.contentNew(ASN1Registry.NID_pkcs7_data);
|
408
|
+
SignerInfoWithPkey si = p7.addSignature(signcert, pkey, EVP.sha1());
|
409
|
+
if((flags & NOCERTS) == 0) {
|
410
|
+
p7.addCertificate(signcert);
|
411
|
+
if(certs != null) {
|
412
|
+
for(X509AuxCertificate c : certs) {
|
413
|
+
p7.addCertificate(c);
|
414
|
+
}
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
418
|
+
if((flags & NOATTR) == 0) {
|
419
|
+
si.addSignedAttribute(ASN1Registry.NID_pkcs9_contentType, ASN1Registry.nid2obj(ASN1Registry.NID_pkcs7_data));
|
420
|
+
if((flags & NOSMIMECAP) == 0) {
|
421
|
+
ASN1EncodableVector smcap = new ASN1EncodableVector();
|
422
|
+
smcap.add(new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_des_ede3_cbc)));
|
423
|
+
smcap.add(new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_rc2_cbc), new DERInteger(128)));
|
424
|
+
smcap.add(new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_rc2_cbc), new DERInteger(64)));
|
425
|
+
smcap.add(new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_rc2_cbc), new DERInteger(40)));
|
426
|
+
smcap.add(new AlgorithmIdentifier(ASN1Registry.nid2obj(ASN1Registry.NID_des_cbc)));
|
427
|
+
si.addSignedAttribute(ASN1Registry.NID_SMIMECapabilities, new DERSequence(smcap));
|
428
|
+
}
|
429
|
+
}
|
430
|
+
|
431
|
+
if((flags & STREAM) != 0) {
|
432
|
+
return p7;
|
433
|
+
}
|
434
|
+
|
435
|
+
BIO p7bio = p7.dataInit(null);
|
436
|
+
|
437
|
+
try {
|
438
|
+
data.crlfCopy(p7bio, flags);
|
439
|
+
} catch(IOException e) {
|
440
|
+
throw new PKCS7Exception(F_PKCS7_SIGN, R_PKCS7_DATAFINAL_ERROR, e.toString());
|
441
|
+
}
|
442
|
+
|
443
|
+
if((flags & DETACHED) != 0) {
|
444
|
+
p7.setDetached(1);
|
445
|
+
}
|
446
|
+
|
447
|
+
p7.dataFinal(p7bio);
|
448
|
+
|
449
|
+
return p7;
|
450
|
+
}
|
451
|
+
|
452
|
+
/* c: PKCS7_encrypt
|
453
|
+
*
|
454
|
+
*/
|
455
|
+
public static PKCS7 encrypt(Collection<X509AuxCertificate> certs, byte[] in, Cipher cipher, int flags) {
|
456
|
+
PKCS7 p7 = new PKCS7();
|
457
|
+
|
458
|
+
p7.setType(ASN1Registry.NID_pkcs7_enveloped);
|
459
|
+
|
460
|
+
try {
|
461
|
+
p7.setCipher(cipher);
|
462
|
+
|
463
|
+
for(X509AuxCertificate x509 : certs) {
|
464
|
+
p7.addRecipient(x509);
|
465
|
+
}
|
466
|
+
|
467
|
+
BIO p7bio = p7.dataInit(null);
|
468
|
+
|
469
|
+
BIO.memBuf(in).crlfCopy(p7bio, flags);
|
470
|
+
p7bio.flush();
|
471
|
+
p7.dataFinal(p7bio);
|
472
|
+
|
473
|
+
return p7;
|
474
|
+
} catch(IOException e) {
|
475
|
+
throw new PKCS7Exception(F_PKCS7_ENCRYPT, R_PKCS7_DATAFINAL_ERROR, e.toString());
|
476
|
+
}
|
477
|
+
}
|
478
|
+
|
479
|
+
/* c: PKCS7_decrypt
|
480
|
+
*
|
481
|
+
*/
|
482
|
+
public void decrypt(PrivateKey pkey, X509AuxCertificate cert, BIO data, int flags) {
|
483
|
+
if(!isEnveloped()) {
|
484
|
+
throw new PKCS7Exception(F_PKCS7_DECRYPT, R_WRONG_CONTENT_TYPE);
|
485
|
+
}
|
486
|
+
try {
|
487
|
+
BIO tmpmem = dataDecode(pkey, null, cert);
|
488
|
+
if((flags & TEXT) == TEXT) {
|
489
|
+
BIO tmpbuf = BIO.buffered();
|
490
|
+
BIO bread = tmpbuf.push(tmpmem);
|
491
|
+
new SMIME(Mime.DEFAULT).text(bread, data);
|
492
|
+
} else {
|
493
|
+
int i;
|
494
|
+
byte[] buf = new byte[4096];
|
495
|
+
while((i = tmpmem.read(buf, 0, 4096)) > 0) {
|
496
|
+
data.write(buf, 0, i);
|
497
|
+
}
|
498
|
+
}
|
499
|
+
} catch(IOException e) {
|
500
|
+
throw new PKCS7Exception(F_PKCS7_DECRYPT, R_DECRYPT_ERROR, e.toString());
|
501
|
+
}
|
502
|
+
}
|
503
|
+
|
504
|
+
/** c: PKCS7_set_type
|
505
|
+
*
|
506
|
+
*/
|
507
|
+
public void setType(int type) {
|
508
|
+
switch(type) {
|
509
|
+
case ASN1Registry.NID_pkcs7_signed:
|
510
|
+
this.data = new PKCS7DataSigned();
|
511
|
+
break;
|
512
|
+
case ASN1Registry.NID_pkcs7_data:
|
513
|
+
this.data = new PKCS7DataData();
|
514
|
+
break;
|
515
|
+
case ASN1Registry.NID_pkcs7_signedAndEnveloped:
|
516
|
+
this.data = new PKCS7DataSignedAndEnveloped();
|
517
|
+
break;
|
518
|
+
case ASN1Registry.NID_pkcs7_enveloped:
|
519
|
+
this.data = new PKCS7DataEnveloped();
|
520
|
+
break;
|
521
|
+
case ASN1Registry.NID_pkcs7_encrypted:
|
522
|
+
this.data = new PKCS7DataEncrypted();
|
523
|
+
break;
|
524
|
+
case ASN1Registry.NID_pkcs7_digest:
|
525
|
+
this.data = new PKCS7DataDigest();
|
526
|
+
break;
|
527
|
+
default:
|
528
|
+
throw new PKCS7Exception(F_PKCS7_SET_TYPE,R_UNSUPPORTED_CONTENT_TYPE);
|
529
|
+
}
|
530
|
+
}
|
531
|
+
|
532
|
+
/** c: PKCS7_set_cipher
|
533
|
+
*
|
534
|
+
*/
|
535
|
+
public void setCipher(Cipher cipher) {
|
536
|
+
this.data.setCipher(cipher);
|
537
|
+
}
|
538
|
+
|
539
|
+
/** c: PKCS7_add_recipient
|
540
|
+
*
|
541
|
+
*/
|
542
|
+
public RecipInfo addRecipient(X509AuxCertificate recip) {
|
543
|
+
RecipInfo ri = new RecipInfo();
|
544
|
+
ri.set(recip);
|
545
|
+
addRecipientInfo(ri);
|
546
|
+
return ri;
|
547
|
+
}
|
548
|
+
|
549
|
+
/** c: PKCS7_content_new
|
550
|
+
*
|
551
|
+
*/
|
552
|
+
public void contentNew(int nid) {
|
553
|
+
PKCS7 ret = new PKCS7();
|
554
|
+
ret.setType(nid);
|
555
|
+
this.setContent(ret);
|
556
|
+
}
|
557
|
+
|
558
|
+
/** c: PKCS7_add_signer
|
559
|
+
*
|
560
|
+
*/
|
561
|
+
public void addSigner(SignerInfoWithPkey psi) {
|
562
|
+
this.data.addSigner(psi);
|
563
|
+
}
|
564
|
+
|
565
|
+
/** c: PKCS7_add_certificate
|
566
|
+
*
|
567
|
+
*/
|
568
|
+
public void addCertificate(X509AuxCertificate cert) {
|
569
|
+
this.data.addCertificate(cert);
|
570
|
+
}
|
571
|
+
|
572
|
+
/** c: PKCS7_add_crl
|
573
|
+
*
|
574
|
+
*/
|
575
|
+
public void addCRL(X509CRL crl) {
|
576
|
+
this.data.addCRL(crl);
|
577
|
+
}
|
578
|
+
|
579
|
+
/** c: PKCS7_add_recipient_info
|
580
|
+
*
|
581
|
+
*/
|
582
|
+
public void addRecipientInfo(RecipInfo ri) {
|
583
|
+
this.data.addRecipientInfo(ri);
|
584
|
+
}
|
585
|
+
|
586
|
+
/** c: PKCS7_set_content
|
587
|
+
*
|
588
|
+
*/
|
589
|
+
public void setContent(PKCS7 p7) {
|
590
|
+
this.data.setContent(p7);
|
591
|
+
}
|
592
|
+
|
593
|
+
/** c: PKCS7_get_signer_info
|
594
|
+
*
|
595
|
+
*/
|
596
|
+
public Collection<SignerInfoWithPkey> getSignerInfo() {
|
597
|
+
return this.data.getSignerInfo();
|
598
|
+
}
|
599
|
+
|
600
|
+
private final static int EVP_MAX_KEY_LENGTH = 32;
|
601
|
+
private final static int EVP_MAX_IV_LENGTH = 16;
|
602
|
+
private final static int EVP_MAX_BLOCK_LENGTH = 32;
|
603
|
+
|
604
|
+
private final static byte[] PEM_STRING_PKCS7_START = "-----BEGIN PKCS7-----".getBytes();
|
605
|
+
|
606
|
+
/** c: PEM_read_bio_PKCS7
|
607
|
+
*
|
608
|
+
*/
|
609
|
+
public static PKCS7 readPEM(BIO input) {
|
610
|
+
try {
|
611
|
+
byte[] buffer = new byte[SMIME.MAX_SMLEN];
|
612
|
+
int read = -1;
|
613
|
+
read = input.gets(buffer, SMIME.MAX_SMLEN);
|
614
|
+
if(read > PEM_STRING_PKCS7_START.length) {
|
615
|
+
byte[] tmp = new byte[PEM_STRING_PKCS7_START.length];
|
616
|
+
System.arraycopy(buffer, 0, tmp, 0, tmp.length);
|
617
|
+
if(Arrays.equals(PEM_STRING_PKCS7_START, tmp)) {
|
618
|
+
return fromASN1(BIO.base64Filter(input));
|
619
|
+
} else {
|
620
|
+
return null;
|
621
|
+
}
|
622
|
+
} else {
|
623
|
+
return null;
|
624
|
+
}
|
625
|
+
} catch(IOException e) {
|
626
|
+
return null;
|
627
|
+
}
|
628
|
+
}
|
629
|
+
|
630
|
+
/** c: stati PKCS7_bio_add_digest
|
631
|
+
*
|
632
|
+
*/
|
633
|
+
public BIO bioAddDigest(BIO pbio, AlgorithmIdentifier alg) {
|
634
|
+
try {
|
635
|
+
MessageDigest md = EVP.getDigest(alg.getObjectId());
|
636
|
+
BIO btmp = BIO.mdFilter(md);
|
637
|
+
if(pbio == null) {
|
638
|
+
return btmp;
|
639
|
+
} else {
|
640
|
+
pbio.push(btmp);
|
641
|
+
return pbio;
|
642
|
+
}
|
643
|
+
} catch(Exception e) {
|
644
|
+
throw new PKCS7Exception(F_PKCS7_BIO_ADD_DIGEST, R_UNKNOWN_DIGEST_TYPE, e);
|
645
|
+
}
|
646
|
+
}
|
647
|
+
|
648
|
+
/** c: PKCS7_dataDecode
|
649
|
+
*
|
650
|
+
*/
|
651
|
+
public BIO dataDecode(PrivateKey pkey, BIO inBio, X509AuxCertificate pcert) {
|
652
|
+
BIO out = null;
|
653
|
+
BIO btmp = null;
|
654
|
+
BIO etmp = null;
|
655
|
+
BIO bio = null;
|
656
|
+
byte[] dataBody = null;
|
657
|
+
Collection<AlgorithmIdentifier> mdSk = null;
|
658
|
+
Collection<RecipInfo> rsk = null;
|
659
|
+
AlgorithmIdentifier encAlg = null;
|
660
|
+
AlgorithmIdentifier xalg = null;
|
661
|
+
Cipher evpCipher = null;
|
662
|
+
RecipInfo ri = null;
|
663
|
+
|
664
|
+
int i = getType();
|
665
|
+
state = S_HEADER;
|
666
|
+
|
667
|
+
|
668
|
+
switch(i) {
|
669
|
+
case ASN1Registry.NID_pkcs7_signed:
|
670
|
+
dataBody = getSign().getContents().getOctetString().getOctets();
|
671
|
+
mdSk = getSign().getMdAlgs();
|
672
|
+
break;
|
673
|
+
case ASN1Registry.NID_pkcs7_signedAndEnveloped:
|
674
|
+
rsk = getSignedAndEnveloped().getRecipientInfo();
|
675
|
+
mdSk = getSignedAndEnveloped().getMdAlgs();
|
676
|
+
dataBody = getSignedAndEnveloped().getEncData().getEncData().getOctets();
|
677
|
+
encAlg = getSignedAndEnveloped().getEncData().getAlgorithm();
|
678
|
+
try {
|
679
|
+
evpCipher = EVP.getCipher(encAlg.getObjectId());
|
680
|
+
} catch(Exception e) {
|
681
|
+
throw new PKCS7Exception(F_PKCS7_DATADECODE, R_UNSUPPORTED_CIPHER_TYPE);
|
682
|
+
}
|
683
|
+
xalg = getSignedAndEnveloped().getEncData().getAlgorithm();
|
684
|
+
break;
|
685
|
+
case ASN1Registry.NID_pkcs7_enveloped:
|
686
|
+
rsk = getEnveloped().getRecipientInfo();
|
687
|
+
dataBody = getEnveloped().getEncData().getEncData().getOctets();
|
688
|
+
encAlg = getEnveloped().getEncData().getAlgorithm();
|
689
|
+
try {
|
690
|
+
evpCipher = EVP.getCipher(encAlg.getObjectId());
|
691
|
+
} catch(Exception e) {
|
692
|
+
throw new PKCS7Exception(F_PKCS7_DATADECODE, R_UNSUPPORTED_CIPHER_TYPE);
|
693
|
+
}
|
694
|
+
xalg = getEnveloped().getEncData().getAlgorithm();
|
695
|
+
break;
|
696
|
+
default:
|
697
|
+
throw new PKCS7Exception(F_PKCS7_DATADECODE, R_UNSUPPORTED_CONTENT_TYPE);
|
698
|
+
}
|
699
|
+
|
700
|
+
/* We will be checking the signature */
|
701
|
+
if(mdSk != null) {
|
702
|
+
for(AlgorithmIdentifier xa : mdSk) {
|
703
|
+
try {
|
704
|
+
MessageDigest evpMd = EVP.getDigest(xa.getObjectId());
|
705
|
+
btmp = BIO.mdFilter(evpMd);
|
706
|
+
if(out == null) {
|
707
|
+
out = btmp;
|
708
|
+
} else {
|
709
|
+
out.push(btmp);
|
710
|
+
}
|
711
|
+
btmp = null;
|
712
|
+
} catch(Exception e) {
|
713
|
+
throw new PKCS7Exception(F_PKCS7_DATADECODE, R_UNKNOWN_DIGEST_TYPE);
|
714
|
+
}
|
715
|
+
}
|
716
|
+
}
|
717
|
+
|
718
|
+
|
719
|
+
if(evpCipher != null) {
|
720
|
+
|
721
|
+
/* It was encrypted, we need to decrypt the secret key
|
722
|
+
* with the private key */
|
723
|
+
|
724
|
+
/* Find the recipientInfo which matches the passed certificate
|
725
|
+
* (if any)
|
726
|
+
*/
|
727
|
+
if(pcert != null) {
|
728
|
+
for(Iterator<RecipInfo> iter = rsk.iterator(); iter.hasNext();) {
|
729
|
+
ri = iter.next();
|
730
|
+
if(ri.compare(pcert)) {
|
731
|
+
break;
|
732
|
+
}
|
733
|
+
ri = null;
|
734
|
+
}
|
735
|
+
if(null == ri) {
|
736
|
+
throw new PKCS7Exception(F_PKCS7_DATADECODE, R_NO_RECIPIENT_MATCHES_CERTIFICATE);
|
737
|
+
}
|
738
|
+
}
|
739
|
+
|
740
|
+
byte[] tmp = null;
|
741
|
+
/* If we haven't got a certificate try each ri in turn */
|
742
|
+
if(null == pcert) {
|
743
|
+
for(Iterator<RecipInfo> iter = rsk.iterator(); iter.hasNext();) {
|
744
|
+
ri = iter.next();
|
745
|
+
try {
|
746
|
+
tmp = EVP.decrypt(ri.getEncKey().getOctets(), pkey);
|
747
|
+
if(tmp != null) {
|
748
|
+
break;
|
749
|
+
}
|
750
|
+
} catch(Exception e) {
|
751
|
+
tmp = null;
|
752
|
+
}
|
753
|
+
ri = null;
|
754
|
+
}
|
755
|
+
if(ri == null) {
|
756
|
+
throw new PKCS7Exception(F_PKCS7_DATADECODE, R_NO_RECIPIENT_MATCHES_KEY);
|
757
|
+
}
|
758
|
+
} else {
|
759
|
+
try {
|
760
|
+
tmp = EVP.decrypt(ri.getEncKey().getOctets(), pkey);
|
761
|
+
} catch(Exception e) {
|
762
|
+
throw new PKCS7Exception(F_PKCS7_DATADECODE, -1, e.toString());
|
763
|
+
}
|
764
|
+
}
|
765
|
+
|
766
|
+
DEREncodable params = encAlg.getParameters();
|
767
|
+
try {
|
768
|
+
if(params != null && params instanceof ASN1OctetString) {
|
769
|
+
evpCipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(tmp, evpCipher.getAlgorithm()), new IvParameterSpec(((ASN1OctetString)params).getOctets()));
|
770
|
+
} else {
|
771
|
+
evpCipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(tmp, evpCipher.getAlgorithm()));
|
772
|
+
}
|
773
|
+
} catch(Exception e) {
|
774
|
+
throw new PKCS7Exception(F_PKCS7_DATADECODE, -1, e.toString());
|
775
|
+
}
|
776
|
+
|
777
|
+
etmp = BIO.cipherFilter(evpCipher);
|
778
|
+
if(out == null) {
|
779
|
+
out = etmp;
|
780
|
+
} else {
|
781
|
+
out.push(etmp);
|
782
|
+
}
|
783
|
+
etmp = null;
|
784
|
+
}
|
785
|
+
|
786
|
+
if(isDetached() || inBio != null) {
|
787
|
+
bio = inBio;
|
788
|
+
} else {
|
789
|
+
if(dataBody != null && dataBody.length > 0) {
|
790
|
+
bio = BIO.memBuf(dataBody);
|
791
|
+
} else {
|
792
|
+
bio = BIO.mem();
|
793
|
+
}
|
794
|
+
}
|
795
|
+
out.push(bio);
|
796
|
+
bio = null;
|
797
|
+
return out;
|
798
|
+
}
|
799
|
+
|
800
|
+
/** c: PKCS7_dataInit
|
801
|
+
*
|
802
|
+
*/
|
803
|
+
public BIO dataInit(BIO bio) {
|
804
|
+
Collection<AlgorithmIdentifier> mdSk = null;
|
805
|
+
ASN1OctetString os = null;
|
806
|
+
int i = this.data.getType();
|
807
|
+
state = S_HEADER;
|
808
|
+
Collection<RecipInfo> rsk = null;
|
809
|
+
AlgorithmIdentifier xa = null;
|
810
|
+
Cipher evpCipher = null;
|
811
|
+
BIO out = null;
|
812
|
+
BIO btmp = null;
|
813
|
+
EncContent enc = null;
|
814
|
+
|
815
|
+
switch(i) {
|
816
|
+
case ASN1Registry.NID_pkcs7_signed:
|
817
|
+
mdSk = getSign().getMdAlgs();
|
818
|
+
os = getSign().getContents().getOctetString();
|
819
|
+
break;
|
820
|
+
case ASN1Registry.NID_pkcs7_signedAndEnveloped:
|
821
|
+
rsk = getSignedAndEnveloped().getRecipientInfo();
|
822
|
+
mdSk = getSignedAndEnveloped().getMdAlgs();
|
823
|
+
enc = getSignedAndEnveloped().getEncData();
|
824
|
+
evpCipher = getSignedAndEnveloped().getEncData().getCipher();
|
825
|
+
if(null == evpCipher) {
|
826
|
+
throw new PKCS7Exception(F_PKCS7_DATAINIT, R_CIPHER_NOT_INITIALIZED);
|
827
|
+
}
|
828
|
+
break;
|
829
|
+
case ASN1Registry.NID_pkcs7_enveloped:
|
830
|
+
rsk = getEnveloped().getRecipientInfo();
|
831
|
+
enc = getEnveloped().getEncData();
|
832
|
+
evpCipher = getEnveloped().getEncData().getCipher();
|
833
|
+
if(null == evpCipher) {
|
834
|
+
throw new PKCS7Exception(F_PKCS7_DATAINIT, R_CIPHER_NOT_INITIALIZED);
|
835
|
+
}
|
836
|
+
break;
|
837
|
+
case ASN1Registry.NID_pkcs7_digest:
|
838
|
+
xa = getDigest().getMd();
|
839
|
+
os = getDigest().getContents().getOctetString();
|
840
|
+
break;
|
841
|
+
default:
|
842
|
+
throw new PKCS7Exception(F_PKCS7_DATAINIT, R_UNSUPPORTED_CONTENT_TYPE);
|
843
|
+
}
|
844
|
+
|
845
|
+
if(mdSk != null) {
|
846
|
+
for(AlgorithmIdentifier ai : mdSk) {
|
847
|
+
if((out = bioAddDigest(out, ai)) == null) {
|
848
|
+
return null;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
}
|
852
|
+
|
853
|
+
if(xa != null && (out = bioAddDigest(out, xa)) == null) {
|
854
|
+
return null;
|
855
|
+
}
|
856
|
+
|
857
|
+
if(evpCipher != null) {
|
858
|
+
byte[] tmp;
|
859
|
+
String algorithm = evpCipher.getAlgorithm();
|
860
|
+
btmp = BIO.cipherFilter(evpCipher);
|
861
|
+
|
862
|
+
int klen = -1;
|
863
|
+
|
864
|
+
String algoBase = evpCipher.getAlgorithm();
|
865
|
+
if(algoBase.indexOf('/') != -1) {
|
866
|
+
algoBase = algoBase.split("/")[0];
|
867
|
+
}
|
868
|
+
|
869
|
+
try {
|
870
|
+
KeyGenerator gen = KeyGenerator.getInstance(algoBase, OpenSSLReal.PROVIDER);
|
871
|
+
gen.init(new SecureRandom());
|
872
|
+
SecretKey key = gen.generateKey();
|
873
|
+
klen = ((SecretKeySpec)key).getEncoded().length*8;
|
874
|
+
evpCipher.init(Cipher.ENCRYPT_MODE, key);
|
875
|
+
|
876
|
+
if(null != rsk) {
|
877
|
+
for(RecipInfo ri : rsk) {
|
878
|
+
PublicKey pkey = ri.getCert().getPublicKey();
|
879
|
+
Cipher cipher = Cipher.getInstance(pkey.getAlgorithm(), OpenSSLReal.PROVIDER);
|
880
|
+
cipher.init(Cipher.ENCRYPT_MODE, pkey);
|
881
|
+
tmp = cipher.doFinal(((SecretKeySpec)key).getEncoded());
|
882
|
+
ri.setEncKey(new DEROctetString(tmp));
|
883
|
+
}
|
884
|
+
}
|
885
|
+
} catch(Exception e) {
|
886
|
+
e.printStackTrace();
|
887
|
+
}
|
888
|
+
|
889
|
+
DERObjectIdentifier encAlgo = ASN1Registry.sym2oid(algorithm);
|
890
|
+
if(encAlgo == null) {
|
891
|
+
String name = algorithm;
|
892
|
+
String block = "CBC";
|
893
|
+
if(name.indexOf('/') != -1) {
|
894
|
+
String[] nameParts = name.split("/");
|
895
|
+
name = nameParts[0];
|
896
|
+
block = nameParts[1];
|
897
|
+
}
|
898
|
+
encAlgo = ASN1Registry.sym2oid(name + "-" + klen + "-" + block);
|
899
|
+
if(null == encAlgo) {
|
900
|
+
throw new PKCS7Exception(-1, -1, "Couldn't find algorithm " + algorithm + ". Tried: " + (name + "-" + klen + "-" + block));
|
901
|
+
}
|
902
|
+
}
|
903
|
+
|
904
|
+
if(evpCipher.getIV() != null) {
|
905
|
+
enc.setAlgorithm(new AlgorithmIdentifier(encAlgo, new DEROctetString(evpCipher.getIV())));
|
906
|
+
} else {
|
907
|
+
enc.setAlgorithm(new AlgorithmIdentifier(encAlgo));
|
908
|
+
}
|
909
|
+
|
910
|
+
if(out == null) {
|
911
|
+
out = btmp;
|
912
|
+
} else {
|
913
|
+
out.push(btmp);
|
914
|
+
}
|
915
|
+
btmp = null;
|
916
|
+
}
|
917
|
+
|
918
|
+
if(bio == null) {
|
919
|
+
if(isDetached()) {
|
920
|
+
bio = BIO.nullSink();
|
921
|
+
} else if(os != null && os.getOctets().length > 0) {
|
922
|
+
bio = BIO.memBuf(os.getOctets());
|
923
|
+
}
|
924
|
+
if(bio == null) {
|
925
|
+
bio = BIO.mem();
|
926
|
+
bio.setMemEofReturn(0);
|
927
|
+
}
|
928
|
+
}
|
929
|
+
out.push(bio);
|
930
|
+
bio = null;
|
931
|
+
return out;
|
932
|
+
}
|
933
|
+
|
934
|
+
/** c: static PKCS7_find_digest
|
935
|
+
*
|
936
|
+
*/
|
937
|
+
public BIO findDigest(MessageDigest[] pmd, BIO bio, int nid) {
|
938
|
+
while(true) {
|
939
|
+
bio = bio.findType(BIO.TYPE_MD);
|
940
|
+
if(bio == null) {
|
941
|
+
throw new PKCS7Exception(F_PKCS7_FIND_DIGEST, R_UNABLE_TO_FIND_MESSAGE_DIGEST);
|
942
|
+
}
|
943
|
+
pmd[0] = ((MessageDigestBIOFilter)bio).getMessageDigest();
|
944
|
+
if(pmd[0] == null) {
|
945
|
+
throw new PKCS7Exception(F_PKCS7_FIND_DIGEST, -1);
|
946
|
+
}
|
947
|
+
|
948
|
+
if(nid == EVP.type(pmd[0])) {
|
949
|
+
return bio;
|
950
|
+
}
|
951
|
+
|
952
|
+
bio = bio.next();
|
953
|
+
}
|
954
|
+
}
|
955
|
+
|
956
|
+
/** c: PKCS7_dataFinal
|
957
|
+
*
|
958
|
+
*/
|
959
|
+
public int dataFinal(BIO bio) {
|
960
|
+
Collection<SignerInfoWithPkey> siSk = null;
|
961
|
+
state = S_HEADER;
|
962
|
+
BIO btmp;
|
963
|
+
int bufLen;
|
964
|
+
byte[] buf;
|
965
|
+
MessageDigest mdc = null;
|
966
|
+
MessageDigest ctx_tmp = null;
|
967
|
+
ASN1Set sk;
|
968
|
+
|
969
|
+
int i = this.data.getType();
|
970
|
+
|
971
|
+
switch(i) {
|
972
|
+
case ASN1Registry.NID_pkcs7_signedAndEnveloped:
|
973
|
+
siSk = getSignedAndEnveloped().getSignerInfo();
|
974
|
+
break;
|
975
|
+
case ASN1Registry.NID_pkcs7_signed:
|
976
|
+
siSk = getSign().getSignerInfo();
|
977
|
+
break;
|
978
|
+
case ASN1Registry.NID_pkcs7_digest:
|
979
|
+
break;
|
980
|
+
default:
|
981
|
+
break;
|
982
|
+
}
|
983
|
+
|
984
|
+
if(siSk != null) {
|
985
|
+
for(SignerInfoWithPkey si : siSk) {
|
986
|
+
if(si.getPkey() == null) {
|
987
|
+
continue;
|
988
|
+
}
|
989
|
+
int j = ASN1Registry.obj2nid(si.getDigestAlgorithm().getObjectId());
|
990
|
+
btmp = bio;
|
991
|
+
MessageDigest[] _mdc = new MessageDigest[] {mdc};
|
992
|
+
btmp = findDigest(_mdc, btmp, j);
|
993
|
+
mdc = _mdc[0];
|
994
|
+
if(btmp == null) {
|
995
|
+
return 0;
|
996
|
+
}
|
997
|
+
|
998
|
+
try {
|
999
|
+
ctx_tmp = (MessageDigest)mdc.clone();
|
1000
|
+
} catch(CloneNotSupportedException e) {
|
1001
|
+
throw new RuntimeException(e);
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
sk = si.getAuthenticatedAttributes();
|
1005
|
+
|
1006
|
+
Signature sign = null;
|
1007
|
+
|
1008
|
+
try {
|
1009
|
+
if(sk != null && sk.size() > 0) {
|
1010
|
+
/* Add signing time if not already present */
|
1011
|
+
if(null == si.getSignedAttribute(ASN1Registry.NID_pkcs9_signingTime)) {
|
1012
|
+
DERUTCTime signTime = new DERUTCTime(Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime());
|
1013
|
+
si.addSignedAttribute(ASN1Registry.NID_pkcs9_signingTime, signTime);
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
byte[] md_data = ctx_tmp.digest();
|
1017
|
+
ASN1OctetString digest = new DEROctetString(md_data);
|
1018
|
+
si.addSignedAttribute(ASN1Registry.NID_pkcs9_messageDigest, digest);
|
1019
|
+
|
1020
|
+
sk = si.getAuthenticatedAttributes();
|
1021
|
+
sign = Signature.getInstance(EVP.signatureAlgorithm(ctx_tmp, si.getPkey()), OpenSSLReal.PROVIDER);
|
1022
|
+
sign.initSign(si.getPkey());
|
1023
|
+
|
1024
|
+
byte[] abuf = sk.getEncoded();
|
1025
|
+
sign.update(abuf);
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
if(sign != null) {
|
1029
|
+
byte[] out = sign.sign();
|
1030
|
+
si.setEncryptedDigest(new DEROctetString(out));
|
1031
|
+
}
|
1032
|
+
} catch(Exception e) {
|
1033
|
+
throw new PKCS7Exception(F_PKCS7_DATAFINAL,-1,e.toString());
|
1034
|
+
}
|
1035
|
+
}
|
1036
|
+
} else if(i == ASN1Registry.NID_pkcs7_digest) {
|
1037
|
+
int nid = ASN1Registry.obj2nid(getDigest().getMd().getObjectId());
|
1038
|
+
MessageDigest[] _mdc = new MessageDigest[] {mdc};
|
1039
|
+
bio = findDigest(_mdc, bio, nid);
|
1040
|
+
mdc = _mdc[0];
|
1041
|
+
byte[] md_data = mdc.digest();
|
1042
|
+
ASN1OctetString digest = new DEROctetString(md_data);
|
1043
|
+
getDigest().setDigest(digest);
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
if(!isDetached()) {
|
1047
|
+
btmp = bio.findType(BIO.TYPE_MEM);
|
1048
|
+
if(null == btmp) {
|
1049
|
+
throw new PKCS7Exception(F_PKCS7_DATAFINAL, R_UNABLE_TO_FIND_MEM_BIO);
|
1050
|
+
}
|
1051
|
+
buf = ((MemBIO)btmp).getMemCopy();
|
1052
|
+
switch(i) {
|
1053
|
+
case ASN1Registry.NID_pkcs7_signedAndEnveloped:
|
1054
|
+
getSignedAndEnveloped().getEncData().setEncData(new DEROctetString(buf));
|
1055
|
+
break;
|
1056
|
+
case ASN1Registry.NID_pkcs7_enveloped:
|
1057
|
+
getEnveloped().getEncData().setEncData(new DEROctetString(buf));
|
1058
|
+
break;
|
1059
|
+
case ASN1Registry.NID_pkcs7_signed:
|
1060
|
+
if(getSign().getContents().isData() && getDetached() != 0) {
|
1061
|
+
getSign().getContents().setData(null);
|
1062
|
+
} else {
|
1063
|
+
getSign().getContents().setData(new DEROctetString(buf));
|
1064
|
+
}
|
1065
|
+
break;
|
1066
|
+
case ASN1Registry.NID_pkcs7_digest:
|
1067
|
+
if(getDigest().getContents().isData() && getDetached() != 0) {
|
1068
|
+
getDigest().getContents().setData(null);
|
1069
|
+
} else {
|
1070
|
+
getDigest().getContents().setData(new DEROctetString(buf));
|
1071
|
+
}
|
1072
|
+
break;
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
return 1;
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
@Override
|
1080
|
+
public String toString() {
|
1081
|
+
return "#<PKCS7 " + this.data + ">";
|
1082
|
+
}
|
1083
|
+
|
1084
|
+
public static final int S_HEADER = 0;
|
1085
|
+
public static final int S_BODY = 1;
|
1086
|
+
public static final int S_TAIL = 2;
|
1087
|
+
|
1088
|
+
public static final int OP_SET_DETACHED_SIGNATURE = 1;
|
1089
|
+
public static final int OP_GET_DETACHED_SIGNATURE = 2;
|
1090
|
+
|
1091
|
+
/* S/MIME related flags */
|
1092
|
+
public static final int TEXT = 0x1;
|
1093
|
+
public static final int NOCERTS = 0x2;
|
1094
|
+
public static final int NOSIGS = 0x4;
|
1095
|
+
public static final int NOCHAIN = 0x8;
|
1096
|
+
public static final int NOINTERN = 0x10;
|
1097
|
+
public static final int NOVERIFY = 0x20;
|
1098
|
+
public static final int DETACHED = 0x40;
|
1099
|
+
public static final int BINARY = 0x80;
|
1100
|
+
public static final int NOATTR = 0x100;
|
1101
|
+
public static final int NOSMIMECAP = 0x200;
|
1102
|
+
public static final int NOOLDMIMETYPE = 0x400;
|
1103
|
+
public static final int CRLFEOL = 0x800;
|
1104
|
+
public static final int STREAM = 0x1000;
|
1105
|
+
public static final int NOCRL = 0x2000;
|
1106
|
+
|
1107
|
+
/* Flags: for compatibility with older code */
|
1108
|
+
public static final int SMIME_TEXT = TEXT;
|
1109
|
+
public static final int SMIME_NOCERTS = NOCERTS;
|
1110
|
+
public static final int SMIME_NOSIGS = NOSIGS;
|
1111
|
+
public static final int SMIME_NOCHAIN = NOCHAIN;
|
1112
|
+
public static final int SMIME_NOINTERN = NOINTERN;
|
1113
|
+
public static final int SMIME_NOVERIFY = NOVERIFY;
|
1114
|
+
public static final int SMIME_DETACHED = DETACHED;
|
1115
|
+
public static final int SMIME_BINARY = BINARY;
|
1116
|
+
public static final int SMIME_NOATTR = NOATTR;
|
1117
|
+
|
1118
|
+
/* Function codes. */
|
1119
|
+
public static final int F_B64_READ_PKCS7 = 120;
|
1120
|
+
public static final int F_B64_WRITE_PKCS7 = 121;
|
1121
|
+
public static final int F_PKCS7_ADD_ATTRIB_SMIMECAP = 118;
|
1122
|
+
public static final int F_PKCS7_ADD_CERTIFICATE = 100;
|
1123
|
+
public static final int F_PKCS7_ADD_CRL = 101;
|
1124
|
+
public static final int F_PKCS7_ADD_RECIPIENT_INFO = 102;
|
1125
|
+
public static final int F_PKCS7_ADD_SIGNER = 103;
|
1126
|
+
public static final int F_PKCS7_BIO_ADD_DIGEST = 125;
|
1127
|
+
public static final int F_PKCS7_CTRL = 104;
|
1128
|
+
public static final int F_PKCS7_DATADECODE = 112;
|
1129
|
+
public static final int F_PKCS7_DATAFINAL = 128;
|
1130
|
+
public static final int F_PKCS7_DATAINIT = 105;
|
1131
|
+
public static final int F_PKCS7_DATASIGN = 106;
|
1132
|
+
public static final int F_PKCS7_DATAVERIFY = 107;
|
1133
|
+
public static final int F_PKCS7_DECRYPT = 114;
|
1134
|
+
public static final int F_PKCS7_ENCRYPT = 115;
|
1135
|
+
public static final int F_PKCS7_FIND_DIGEST = 127;
|
1136
|
+
public static final int F_PKCS7_GET0_SIGNERS = 124;
|
1137
|
+
public static final int F_PKCS7_SET_CIPHER = 108;
|
1138
|
+
public static final int F_PKCS7_SET_CONTENT = 109;
|
1139
|
+
public static final int F_PKCS7_SET_DIGEST = 126;
|
1140
|
+
public static final int F_PKCS7_SET_TYPE = 110;
|
1141
|
+
public static final int F_PKCS7_SIGN = 116;
|
1142
|
+
public static final int F_PKCS7_SIGNATUREVERIFY = 113;
|
1143
|
+
public static final int F_PKCS7_SIMPLE_SMIMECAP = 119;
|
1144
|
+
public static final int F_PKCS7_VERIFY = 117;
|
1145
|
+
public static final int F_SMIME_READ_PKCS7 = 122;
|
1146
|
+
public static final int F_SMIME_TEXT = 123;
|
1147
|
+
|
1148
|
+
/* Reason codes. */
|
1149
|
+
public static final int R_CERTIFICATE_VERIFY_ERROR = 117;
|
1150
|
+
public static final int R_CIPHER_HAS_NO_OBJECT_IDENTIFIER = 144;
|
1151
|
+
public static final int R_CIPHER_NOT_INITIALIZED = 116;
|
1152
|
+
public static final int R_CONTENT_AND_DATA_PRESENT = 118;
|
1153
|
+
public static final int R_DECODE_ERROR = 130;
|
1154
|
+
public static final int R_DECRYPTED_KEY_IS_WRONG_LENGTH = 100;
|
1155
|
+
public static final int R_DECRYPT_ERROR = 119;
|
1156
|
+
public static final int R_DIGEST_FAILURE = 101;
|
1157
|
+
public static final int R_ERROR_ADDING_RECIPIENT = 120;
|
1158
|
+
public static final int R_ERROR_SETTING_CIPHER = 121;
|
1159
|
+
public static final int R_INVALID_MIME_TYPE = 131;
|
1160
|
+
public static final int R_INVALID_NULL_POINTER = 143;
|
1161
|
+
public static final int R_MIME_NO_CONTENT_TYPE = 132;
|
1162
|
+
public static final int R_MIME_PARSE_ERROR = 133;
|
1163
|
+
public static final int R_MIME_SIG_PARSE_ERROR = 134;
|
1164
|
+
public static final int R_MISSING_CERIPEND_INFO = 103;
|
1165
|
+
public static final int R_NO_CONTENT = 122;
|
1166
|
+
public static final int R_NO_CONTENT_TYPE = 135;
|
1167
|
+
public static final int R_NO_MULTIPART_BODY_FAILURE = 136;
|
1168
|
+
public static final int R_NO_MULTIPART_BOUNDARY = 137;
|
1169
|
+
public static final int R_NO_RECIPIENT_MATCHES_CERTIFICATE = 115;
|
1170
|
+
public static final int R_NO_RECIPIENT_MATCHES_KEY = 146;
|
1171
|
+
public static final int R_NO_SIGNATURES_ON_DATA = 123;
|
1172
|
+
public static final int R_NO_SIGNERS = 142;
|
1173
|
+
public static final int R_NO_SIG_CONTENT_TYPE = 138;
|
1174
|
+
public static final int R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE = 104;
|
1175
|
+
public static final int R_PKCS7_ADD_SIGNATURE_ERROR = 124;
|
1176
|
+
public static final int R_PKCS7_DATAFINAL = 126;
|
1177
|
+
public static final int R_PKCS7_DATAFINAL_ERROR = 125;
|
1178
|
+
public static final int R_PKCS7_DATASIGN = 145;
|
1179
|
+
public static final int R_PKCS7_PARSE_ERROR = 139;
|
1180
|
+
public static final int R_PKCS7_SIG_PARSE_ERROR = 140;
|
1181
|
+
public static final int R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE = 127;
|
1182
|
+
public static final int R_SIGNATURE_FAILURE = 105;
|
1183
|
+
public static final int R_SIGNER_CERTIFICATE_NOT_FOUND = 128;
|
1184
|
+
public static final int R_SIG_INVALID_MIME_TYPE = 141;
|
1185
|
+
public static final int R_SMIME_TEXT_ERROR = 129;
|
1186
|
+
public static final int R_UNABLE_TO_FIND_CERTIFICATE = 106;
|
1187
|
+
public static final int R_UNABLE_TO_FIND_MEM_BIO = 107;
|
1188
|
+
public static final int R_UNABLE_TO_FIND_MESSAGE_DIGEST = 108;
|
1189
|
+
public static final int R_UNKNOWN_DIGEST_TYPE = 109;
|
1190
|
+
public static final int R_UNKNOWN_OPERATION = 110;
|
1191
|
+
public static final int R_UNSUPPORTED_CIPHER_TYPE = 111;
|
1192
|
+
public static final int R_UNSUPPORTED_CONTENT_TYPE = 112;
|
1193
|
+
public static final int R_WRONG_CONTENT_TYPE = 113;
|
1194
|
+
public static final int R_WRONG_PKCS7_TYPE = 114;
|
1195
|
+
|
1196
|
+
public Envelope getEnveloped() {
|
1197
|
+
return this.data.getEnveloped();
|
1198
|
+
}
|
1199
|
+
|
1200
|
+
public SignEnvelope getSignedAndEnveloped() {
|
1201
|
+
return this.data.getSignedAndEnveloped();
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
public Digest getDigest() {
|
1205
|
+
return this.data.getDigest();
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
public Encrypt getEncrypted() {
|
1209
|
+
return this.data.getEncrypted();
|
1210
|
+
}
|
1211
|
+
|
1212
|
+
public ASN1Encodable getOther() {
|
1213
|
+
return this.data.getOther();
|
1214
|
+
}
|
1215
|
+
|
1216
|
+
public void setSign(Signed sign) {
|
1217
|
+
this.data.setSign(sign);
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
public Signed getSign() {
|
1221
|
+
return this.data.getSign();
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
public void setData(ASN1OctetString data) {
|
1225
|
+
this.data.setData(data);
|
1226
|
+
}
|
1227
|
+
|
1228
|
+
public ASN1OctetString getData() {
|
1229
|
+
return this.data.getData();
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
public boolean isSigned() {
|
1233
|
+
return this.data.isSigned();
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
public boolean isEncrypted() {
|
1237
|
+
return this.data.isEncrypted();
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
public boolean isEnveloped() {
|
1241
|
+
return this.data.isEnveloped();
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
public boolean isSignedAndEnveloped() {
|
1245
|
+
return this.data.isSignedAndEnveloped();
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
public boolean isData() {
|
1249
|
+
return this.data.isData();
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
public boolean isDigest() {
|
1253
|
+
return this.data.isDigest();
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
public boolean isOther() {
|
1257
|
+
return this.data.isOther();
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
public int getType() {
|
1261
|
+
return this.data.getType();
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
/* c: static PKCS7_get_octet_string
|
1265
|
+
*
|
1266
|
+
*/
|
1267
|
+
public ASN1OctetString getOctetString() {
|
1268
|
+
if(isData()) {
|
1269
|
+
return getData();
|
1270
|
+
} else if(isOther() && getOther() != null && getOther() instanceof ASN1OctetString) {
|
1271
|
+
return (ASN1OctetString)getOther();
|
1272
|
+
}
|
1273
|
+
return null;
|
1274
|
+
}
|
1275
|
+
}// PKCS7
|
1276
|
+
|