redcar 0.3.2dev → 0.3.3
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.
- 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) 2006 Ola Bini <ola@ologix.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;
|
|
29
|
+
|
|
30
|
+
import java.io.Reader;
|
|
31
|
+
import java.io.Writer;
|
|
32
|
+
|
|
33
|
+
import org.bouncycastle.openssl.PEMReader;
|
|
34
|
+
import org.bouncycastle.openssl.PEMWriter;
|
|
35
|
+
import org.bouncycastle.openssl.PasswordFinder;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
|
|
39
|
+
*/
|
|
40
|
+
public class BouncyCastlePEMHandler implements PEMHandler {
|
|
41
|
+
public Object readPEM(Reader read, String password) throws Exception {
|
|
42
|
+
return new PEMReader(read,new BasicPasswordFinder(password)).readObject();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public void writePEM(Writer writ, Object obj, String algorithm, char[] password) throws Exception {
|
|
46
|
+
PEMWriter p = new PEMWriter(writ);
|
|
47
|
+
p.writeObject(obj,algorithm,password,null);
|
|
48
|
+
p.flush();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void writePEM(Writer writ, Object obj) throws Exception {
|
|
52
|
+
PEMWriter p = new PEMWriter(writ);
|
|
53
|
+
p.writeObject(obj);
|
|
54
|
+
p.flush();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private static class BasicPasswordFinder implements PasswordFinder {
|
|
58
|
+
private char[] pwd;
|
|
59
|
+
BasicPasswordFinder(String pwd) {
|
|
60
|
+
if(pwd != null) {
|
|
61
|
+
this.pwd = pwd.toCharArray();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public char[] getPassword() {
|
|
66
|
+
return pwd;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}// BouncyCastlePEMHandler
|
|
@@ -0,0 +1,661 @@
|
|
|
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) 2006, 2007 Ola Bini <ola@ologix.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;
|
|
29
|
+
|
|
30
|
+
import java.security.MessageDigest;
|
|
31
|
+
import java.security.NoSuchAlgorithmException;
|
|
32
|
+
import java.security.NoSuchProviderException;
|
|
33
|
+
import java.util.ArrayList;
|
|
34
|
+
import java.util.HashSet;
|
|
35
|
+
import java.util.List;
|
|
36
|
+
import java.util.Set;
|
|
37
|
+
|
|
38
|
+
import javax.crypto.spec.IvParameterSpec;
|
|
39
|
+
|
|
40
|
+
import javax.crypto.spec.RC2ParameterSpec;
|
|
41
|
+
import org.jruby.Ruby;
|
|
42
|
+
import org.jruby.RubyClass;
|
|
43
|
+
import org.jruby.RubyModule;
|
|
44
|
+
import org.jruby.RubyNumeric;
|
|
45
|
+
import org.jruby.RubyObject;
|
|
46
|
+
import org.jruby.RubyString;
|
|
47
|
+
import org.jruby.common.IRubyWarnings;
|
|
48
|
+
import org.jruby.common.IRubyWarnings.ID;
|
|
49
|
+
import org.jruby.anno.JRubyMethod;
|
|
50
|
+
import org.jruby.anno.JRubyModule;
|
|
51
|
+
import org.jruby.exceptions.RaiseException;
|
|
52
|
+
import org.jruby.runtime.ObjectAllocator;
|
|
53
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
|
54
|
+
import org.jruby.util.ByteList;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
|
|
58
|
+
*/
|
|
59
|
+
public class Cipher extends RubyObject {
|
|
60
|
+
// set to enable debug output
|
|
61
|
+
private static final boolean DEBUG = false;
|
|
62
|
+
private static ObjectAllocator CIPHER_ALLOCATOR = new ObjectAllocator() {
|
|
63
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
|
64
|
+
return new Cipher(runtime, klass);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
public static void createCipher(Ruby runtime, RubyModule ossl) {
|
|
69
|
+
RubyModule mCipher = ossl.defineModuleUnder("Cipher");
|
|
70
|
+
RubyClass cCipher = mCipher.defineClassUnder("Cipher",runtime.getObject(), CIPHER_ALLOCATOR);
|
|
71
|
+
|
|
72
|
+
RubyClass openSSLError = ossl.getClass("OpenSSLError");
|
|
73
|
+
mCipher.defineClassUnder("CipherError",openSSLError,openSSLError.getAllocator());
|
|
74
|
+
ossl.defineClassUnder("CipherError",openSSLError,openSSLError.getAllocator());
|
|
75
|
+
|
|
76
|
+
cCipher.defineAnnotatedMethods(Cipher.class);
|
|
77
|
+
mCipher.defineAnnotatedMethods(CipherModule.class);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@JRubyModule(name="OpenSSL::Cipher")
|
|
81
|
+
public static class CipherModule {
|
|
82
|
+
@JRubyMethod(meta = true)
|
|
83
|
+
public static IRubyObject ciphers(IRubyObject recv) {
|
|
84
|
+
List<IRubyObject> ciphers = new ArrayList<IRubyObject>();
|
|
85
|
+
String[] other = {"AES128","AES192","AES256","BLOWFISH", "RC2-40-CBC", "RC2-64-CBC","RC4","RC4-40", "CAST","CAST-CBC"};
|
|
86
|
+
String[] bases = {"AES-128","AES-192","AES-256","BF", "DES", "DES-EDE","DES-EDE3", "RC2","CAST5"};
|
|
87
|
+
String[] suffixes = {"","-CBC","-CFB","-CFB1","-CFB8","-ECB","-OFB"};
|
|
88
|
+
for(int i=0,j=bases.length;i<j;i++) {
|
|
89
|
+
for(int k=0,l=suffixes.length;k<l;k++) {
|
|
90
|
+
String val = bases[i]+suffixes[k];
|
|
91
|
+
if(tryCipher(val)) {
|
|
92
|
+
ciphers.add(recv.getRuntime().newString(val));
|
|
93
|
+
ciphers.add(recv.getRuntime().newString((val).toLowerCase()));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
for(int i=0,j=other.length;i<j;i++) {
|
|
98
|
+
if(tryCipher(other[i])) {
|
|
99
|
+
ciphers.add(recv.getRuntime().newString(other[i]));
|
|
100
|
+
ciphers.add(recv.getRuntime().newString(other[i].toLowerCase()));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return recv.getRuntime().newArray(ciphers);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private static final Set<String> BLOCK_MODES = new HashSet<String>();
|
|
108
|
+
static {
|
|
109
|
+
BLOCK_MODES.add("CBC");
|
|
110
|
+
BLOCK_MODES.add("CFB");
|
|
111
|
+
BLOCK_MODES.add("CFB1");
|
|
112
|
+
BLOCK_MODES.add("CFB8");
|
|
113
|
+
BLOCK_MODES.add("ECB");
|
|
114
|
+
BLOCK_MODES.add("OFB");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private static String[] rubyToJavaCipher(String inName, String padding) {
|
|
118
|
+
String[] split = inName.split("-");
|
|
119
|
+
String cryptoBase = split[0];
|
|
120
|
+
String cryptoVersion = null;
|
|
121
|
+
String cryptoMode = null;
|
|
122
|
+
String realName = null;
|
|
123
|
+
|
|
124
|
+
String padding_type;
|
|
125
|
+
if (padding == null || padding.equalsIgnoreCase("PKCS5Padding")) {
|
|
126
|
+
padding_type = "PKCS5Padding";
|
|
127
|
+
} else if (padding.equals("0") || padding.equalsIgnoreCase("NoPadding")) {
|
|
128
|
+
padding_type = "NoPadding";
|
|
129
|
+
} else if (padding.equalsIgnoreCase("ISO10126Padding")) {
|
|
130
|
+
padding_type = "ISO10126Padding";
|
|
131
|
+
} else {
|
|
132
|
+
padding_type = "PKCS5Padding";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if("bf".equalsIgnoreCase(cryptoBase)) {
|
|
136
|
+
cryptoBase = "Blowfish";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if(split.length == 3) {
|
|
140
|
+
cryptoVersion = split[1];
|
|
141
|
+
cryptoMode = split[2];
|
|
142
|
+
} else {
|
|
143
|
+
if(split.length == 2) {
|
|
144
|
+
cryptoMode = split[1];
|
|
145
|
+
} else {
|
|
146
|
+
cryptoMode = "CBC";
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if(cryptoBase.equalsIgnoreCase("DES") && "EDE3".equalsIgnoreCase(cryptoVersion)) {
|
|
151
|
+
realName = "DESede";
|
|
152
|
+
} else {
|
|
153
|
+
realName = cryptoBase;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if(!BLOCK_MODES.contains(cryptoMode.toUpperCase())) {
|
|
157
|
+
cryptoVersion = cryptoMode;
|
|
158
|
+
cryptoMode = "CBC";
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
realName = realName + "/" + cryptoMode + "/" + padding_type;
|
|
162
|
+
|
|
163
|
+
return new String[]{cryptoBase,cryptoVersion,cryptoMode,realName,padding_type};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private static boolean tryCipher(final String rubyName) {
|
|
167
|
+
return ((Boolean) (OpenSSLReal.getWithBCProvider(new Callable() {
|
|
168
|
+
public Object call() {
|
|
169
|
+
try {
|
|
170
|
+
javax.crypto.Cipher.getInstance(rubyToJavaCipher(rubyName, null)[3], OpenSSLReal.PROVIDER);
|
|
171
|
+
return Boolean.TRUE;
|
|
172
|
+
} catch (Exception e) {
|
|
173
|
+
return Boolean.FALSE;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
}))).booleanValue();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
private RubyClass ciphErr;
|
|
182
|
+
public Cipher(Ruby runtime, RubyClass type) {
|
|
183
|
+
super(runtime,type);
|
|
184
|
+
ciphErr = (RubyClass)(((RubyModule)(getRuntime().getModule("OpenSSL").getConstant("Cipher"))).getConstant("CipherError"));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private javax.crypto.Cipher ciph;
|
|
188
|
+
private String name;
|
|
189
|
+
private String cryptoBase;
|
|
190
|
+
private String cryptoVersion;
|
|
191
|
+
private String cryptoMode;
|
|
192
|
+
private String padding_type;
|
|
193
|
+
private String realName;
|
|
194
|
+
private int keyLen = -1;
|
|
195
|
+
private int ivLen = -1;
|
|
196
|
+
private boolean encryptMode = true;
|
|
197
|
+
//private IRubyObject[] modeParams;
|
|
198
|
+
private boolean ciphInited = false;
|
|
199
|
+
private byte[] key;
|
|
200
|
+
private byte[] realIV;
|
|
201
|
+
private byte[] orgIV;
|
|
202
|
+
private String padding;
|
|
203
|
+
|
|
204
|
+
void dumpVars() {
|
|
205
|
+
System.out.println("***** Cipher instance vars ****");
|
|
206
|
+
System.out.println("name = " + name);
|
|
207
|
+
System.out.println("cryptoBase = " + cryptoBase);
|
|
208
|
+
System.out.println("cryptoVersion = " + cryptoVersion);
|
|
209
|
+
System.out.println("cryptoMode = " + cryptoMode);
|
|
210
|
+
System.out.println("padding_type = " + padding_type);
|
|
211
|
+
System.out.println("realName = " + realName);
|
|
212
|
+
System.out.println("keyLen = " + keyLen);
|
|
213
|
+
System.out.println("ivLen = " + ivLen);
|
|
214
|
+
System.out.println("ciph block size = " + ciph.getBlockSize());
|
|
215
|
+
System.out.println("encryptMode = " + encryptMode);
|
|
216
|
+
System.out.println("ciphInited = " + ciphInited);
|
|
217
|
+
System.out.println("key.length = " + (key == null ? 0 : key.length));
|
|
218
|
+
System.out.println("iv.length = " + (this.realIV == null ? 0 : this.realIV.length));
|
|
219
|
+
System.out.println("padding = " + padding);
|
|
220
|
+
System.out.println("ciphAlgo = " + ciph.getAlgorithm());
|
|
221
|
+
System.out.println("*******************************");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@JRubyMethod(required=1)
|
|
225
|
+
public IRubyObject initialize(IRubyObject str) {
|
|
226
|
+
name = str.toString();
|
|
227
|
+
String[] values = rubyToJavaCipher(name, padding);
|
|
228
|
+
cryptoBase = values[0];
|
|
229
|
+
cryptoVersion = values[1];
|
|
230
|
+
cryptoMode = values[2];
|
|
231
|
+
realName = values[3];
|
|
232
|
+
padding_type = values[4];
|
|
233
|
+
ciph = getCipher();
|
|
234
|
+
|
|
235
|
+
if(hasLen() && null != cryptoVersion) {
|
|
236
|
+
try {
|
|
237
|
+
keyLen = Integer.parseInt(cryptoVersion) / 8;
|
|
238
|
+
} catch(NumberFormatException e) {
|
|
239
|
+
keyLen = -1;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if(keyLen == -1) {
|
|
243
|
+
if("DES".equalsIgnoreCase(cryptoBase)) {
|
|
244
|
+
ivLen = 8;
|
|
245
|
+
if("EDE3".equalsIgnoreCase(cryptoVersion)) {
|
|
246
|
+
keyLen = 24;
|
|
247
|
+
} else {
|
|
248
|
+
keyLen = 8;
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
keyLen = 16;
|
|
252
|
+
try {
|
|
253
|
+
if ((javax.crypto.Cipher.getMaxAllowedKeyLength(name) / 8) < keyLen) {
|
|
254
|
+
keyLen = javax.crypto.Cipher.getMaxAllowedKeyLength(name) / 8;
|
|
255
|
+
}
|
|
256
|
+
} catch (Exception e) {
|
|
257
|
+
// I hate checked exceptions
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if(ivLen == -1) {
|
|
263
|
+
if("AES".equalsIgnoreCase(cryptoBase)) {
|
|
264
|
+
ivLen = 16;
|
|
265
|
+
} else {
|
|
266
|
+
ivLen = 8;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
@JRubyMethod(required=1)
|
|
274
|
+
public IRubyObject initialize_copy(IRubyObject obj) {
|
|
275
|
+
if(this == obj) {
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
checkFrozen();
|
|
280
|
+
|
|
281
|
+
cryptoBase = ((Cipher)obj).cryptoBase;
|
|
282
|
+
cryptoVersion = ((Cipher)obj).cryptoVersion;
|
|
283
|
+
cryptoMode = ((Cipher)obj).cryptoMode;
|
|
284
|
+
padding_type = ((Cipher)obj).padding_type;
|
|
285
|
+
realName = ((Cipher)obj).realName;
|
|
286
|
+
name = ((Cipher)obj).name;
|
|
287
|
+
keyLen = ((Cipher)obj).keyLen;
|
|
288
|
+
ivLen = ((Cipher)obj).ivLen;
|
|
289
|
+
encryptMode = ((Cipher)obj).encryptMode;
|
|
290
|
+
ciphInited = false;
|
|
291
|
+
if(((Cipher)obj).key != null) {
|
|
292
|
+
key = new byte[((Cipher)obj).key.length];
|
|
293
|
+
System.arraycopy(((Cipher)obj).key,0,key,0,key.length);
|
|
294
|
+
} else {
|
|
295
|
+
key = null;
|
|
296
|
+
}
|
|
297
|
+
if(((Cipher)obj).realIV != null) {
|
|
298
|
+
this.realIV = new byte[((Cipher)obj).realIV.length];
|
|
299
|
+
System.arraycopy(((Cipher)obj).realIV,0,this.realIV,0,this.realIV.length);
|
|
300
|
+
} else {
|
|
301
|
+
this.realIV = null;
|
|
302
|
+
}
|
|
303
|
+
this.orgIV = this.realIV;
|
|
304
|
+
padding = ((Cipher)obj).padding;
|
|
305
|
+
|
|
306
|
+
ciph = getCipher();
|
|
307
|
+
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
@JRubyMethod
|
|
312
|
+
public IRubyObject name() {
|
|
313
|
+
return getRuntime().newString(name);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@JRubyMethod
|
|
317
|
+
public IRubyObject key_len() {
|
|
318
|
+
return getRuntime().newFixnum(keyLen);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@JRubyMethod
|
|
322
|
+
public IRubyObject iv_len() {
|
|
323
|
+
return getRuntime().newFixnum(ivLen);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@JRubyMethod(name="key_len=", required=1)
|
|
327
|
+
public IRubyObject set_key_len(IRubyObject len) {
|
|
328
|
+
this.keyLen = RubyNumeric.fix2int(len);
|
|
329
|
+
return len;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
@JRubyMethod(name="key=", required=1)
|
|
333
|
+
public IRubyObject set_key(IRubyObject key) {
|
|
334
|
+
byte[] keyBytes;
|
|
335
|
+
try {
|
|
336
|
+
keyBytes = key.convertToString().getBytes();
|
|
337
|
+
} catch(Exception e) {
|
|
338
|
+
e.printStackTrace();
|
|
339
|
+
throw new RaiseException(getRuntime(), ciphErr, null, true);
|
|
340
|
+
}
|
|
341
|
+
if(keyBytes.length < keyLen) {
|
|
342
|
+
throw new RaiseException(getRuntime(), ciphErr, "key length to short", true);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if(keyBytes.length > keyLen) {
|
|
346
|
+
byte[] keys = new byte[keyLen];
|
|
347
|
+
System.arraycopy(keyBytes, 0, keys, 0, keyLen);
|
|
348
|
+
keyBytes = keys;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
this.key = keyBytes;
|
|
352
|
+
return key;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
@JRubyMethod(name="iv=", required=1)
|
|
356
|
+
public IRubyObject set_iv(IRubyObject iv) {
|
|
357
|
+
byte[] ivBytes;
|
|
358
|
+
try {
|
|
359
|
+
ivBytes = iv.convertToString().getBytes();
|
|
360
|
+
} catch(Exception e) {
|
|
361
|
+
e.printStackTrace();
|
|
362
|
+
throw new RaiseException(getRuntime(), ciphErr, null, true);
|
|
363
|
+
}
|
|
364
|
+
if(ivBytes.length < ivLen) {
|
|
365
|
+
throw new RaiseException(getRuntime(), ciphErr, "iv length to short", true);
|
|
366
|
+
}
|
|
367
|
+
this.realIV = ivBytes;
|
|
368
|
+
this.orgIV = this.realIV;
|
|
369
|
+
ciphInited = false;
|
|
370
|
+
return iv;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
@JRubyMethod
|
|
374
|
+
public IRubyObject block_size() {
|
|
375
|
+
return getRuntime().newFixnum(ciph.getBlockSize());
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
protected void init(IRubyObject[] args, boolean encrypt) {
|
|
379
|
+
org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,0,2);
|
|
380
|
+
|
|
381
|
+
encryptMode = encrypt;
|
|
382
|
+
ciphInited = false;
|
|
383
|
+
|
|
384
|
+
if(args.length > 0) {
|
|
385
|
+
/*
|
|
386
|
+
* oops. this code mistakes salt for IV.
|
|
387
|
+
* We deprecated the arguments for this method, but we decided
|
|
388
|
+
* keeping this behaviour for backward compatibility.
|
|
389
|
+
*/
|
|
390
|
+
byte[] pass = args[0].convertToString().getBytes();
|
|
391
|
+
byte[] iv = null;
|
|
392
|
+
try {
|
|
393
|
+
iv = "OpenSSL for Ruby rulez!".getBytes("ISO8859-1");
|
|
394
|
+
byte[] iv2 = new byte[this.ivLen];
|
|
395
|
+
System.arraycopy(iv, 0, iv2, 0, this.ivLen);
|
|
396
|
+
iv = iv2;
|
|
397
|
+
} catch(Exception e) {}
|
|
398
|
+
|
|
399
|
+
if(args.length > 1 && !args[1].isNil()) {
|
|
400
|
+
getRuntime().getWarnings().warning(ID.MISCELLANEOUS, "key derivation by " + getMetaClass().getRealClass().getName() + "#encrypt is deprecated; use " + getMetaClass().getRealClass().getName() + "::pkcs5_keyivgen instead");
|
|
401
|
+
iv = args[1].convertToString().getBytes();
|
|
402
|
+
if(iv.length > this.ivLen) {
|
|
403
|
+
byte[] iv2 = new byte[this.ivLen];
|
|
404
|
+
System.arraycopy(iv, 0, iv2, 0, this.ivLen);
|
|
405
|
+
iv = iv2;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
MessageDigest digest = (MessageDigest)OpenSSLReal.getWithBCProvider(new Callable() {
|
|
410
|
+
public Object call() {
|
|
411
|
+
try {
|
|
412
|
+
return MessageDigest.getInstance("MD5", "BC");
|
|
413
|
+
} catch (Exception e) {
|
|
414
|
+
throw new RaiseException(getRuntime(), ciphErr, e.getMessage(), true);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
OpenSSLImpl.KeyAndIv result = OpenSSLImpl.EVP_BytesToKey(keyLen,ivLen,digest,iv,pass,2048);
|
|
420
|
+
this.key = result.getKey();
|
|
421
|
+
this.realIV = iv;
|
|
422
|
+
this.orgIV = this.realIV;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
@JRubyMethod(optional=2)
|
|
427
|
+
public IRubyObject encrypt(IRubyObject[] args) {
|
|
428
|
+
this.realIV = orgIV;
|
|
429
|
+
init(args, true);
|
|
430
|
+
return this;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
@JRubyMethod(optional=2)
|
|
434
|
+
public IRubyObject decrypt(IRubyObject[] args) {
|
|
435
|
+
this.realIV = orgIV;
|
|
436
|
+
init(args, false);
|
|
437
|
+
return this;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
@JRubyMethod
|
|
441
|
+
public IRubyObject reset() {
|
|
442
|
+
this.realIV = orgIV;
|
|
443
|
+
doInitialize();
|
|
444
|
+
return this;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
javax.crypto.Cipher getCipher() {
|
|
448
|
+
return (javax.crypto.Cipher) OpenSSLReal.getWithBCProvider(new Callable() {
|
|
449
|
+
public Object call() {
|
|
450
|
+
try {
|
|
451
|
+
return javax.crypto.Cipher.getInstance(realName, "BC");
|
|
452
|
+
} catch (NoSuchAlgorithmException e) {
|
|
453
|
+
throw getRuntime().newLoadError("unsupported cipher algorithm (" + realName + ")");
|
|
454
|
+
} catch (NoSuchProviderException e) {
|
|
455
|
+
throw getRuntime().newLoadError("unsupported cipher algorithm (" + realName + ")");
|
|
456
|
+
} catch (javax.crypto.NoSuchPaddingException e) {
|
|
457
|
+
throw getRuntime().newLoadError("unsupported cipher padding (" + realName + ")");
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
private boolean hasLen() {
|
|
464
|
+
return hasLen(this.cryptoBase);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
private static boolean hasLen(String cryptoBase) {
|
|
468
|
+
return "AES".equalsIgnoreCase(cryptoBase) || "RC2".equalsIgnoreCase(cryptoBase) || "RC4".equalsIgnoreCase(cryptoBase);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
@JRubyMethod(required=1,optional=3)
|
|
472
|
+
public IRubyObject pkcs5_keyivgen(IRubyObject[] args) {
|
|
473
|
+
org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,1,4);
|
|
474
|
+
byte[] pass = args[0].convertToString().getBytes();
|
|
475
|
+
byte[] salt = null;
|
|
476
|
+
int iter = 2048;
|
|
477
|
+
IRubyObject vdigest = getRuntime().getNil();
|
|
478
|
+
MessageDigest digest = null;
|
|
479
|
+
if(args.length>1) {
|
|
480
|
+
if(!args[1].isNil()) {
|
|
481
|
+
salt = args[1].convertToString().getBytes();;
|
|
482
|
+
}
|
|
483
|
+
if(args.length>2) {
|
|
484
|
+
if(!args[2].isNil()) {
|
|
485
|
+
iter = RubyNumeric.fix2int(args[2]);
|
|
486
|
+
}
|
|
487
|
+
if(args.length>3) {
|
|
488
|
+
vdigest = args[3];
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (null != salt) {
|
|
493
|
+
if (salt.length != 8) {
|
|
494
|
+
throw new RaiseException(getRuntime(), ciphErr, "salt must be an 8-octet string", true);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
final String algorithm = vdigest.isNil() ? "MD5" : ((Digest) vdigest).getAlgorithm();
|
|
499
|
+
|
|
500
|
+
digest = (MessageDigest) OpenSSLReal.getWithBCProvider(new Callable() {
|
|
501
|
+
public Object call() {
|
|
502
|
+
try {
|
|
503
|
+
return MessageDigest.getInstance(algorithm, "BC");
|
|
504
|
+
} catch (Exception e) {
|
|
505
|
+
throw new RaiseException(getRuntime(), ciphErr, e.getMessage(), true);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
OpenSSLImpl.KeyAndIv result = OpenSSLImpl.EVP_BytesToKey(keyLen, ivLen, digest, salt, pass, iter);
|
|
511
|
+
this.key = result.getKey();
|
|
512
|
+
this.realIV = result.getIv();
|
|
513
|
+
this.orgIV = this.realIV;
|
|
514
|
+
|
|
515
|
+
doInitialize();
|
|
516
|
+
|
|
517
|
+
return getRuntime().getNil();
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
private void doInitialize() {
|
|
521
|
+
if (DEBUG) {
|
|
522
|
+
System.out.println("*** doInitialize");
|
|
523
|
+
dumpVars();
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
ciphInited = true;
|
|
527
|
+
try {
|
|
528
|
+
assert (key.length * 8 == keyLen) || (key.length == keyLen) : "Key wrong length";
|
|
529
|
+
assert (this.realIV.length * 8 == ivLen) || (this.realIV.length == ivLen) : "IV wrong length";
|
|
530
|
+
if (!"ECB".equalsIgnoreCase(cryptoMode)) {
|
|
531
|
+
if (this.realIV == null) {
|
|
532
|
+
this.realIV = new byte[ivLen];
|
|
533
|
+
System.arraycopy("OpenSSL for JRuby rulez".getBytes(), 0,
|
|
534
|
+
this.realIV, 0, ivLen);
|
|
535
|
+
}
|
|
536
|
+
if ("RC2".equals(cryptoBase)) {
|
|
537
|
+
this.ciph.init(encryptMode ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE, new SimpleSecretKey(this.key), new RC2ParameterSpec(this.key.length * 8, this.realIV));
|
|
538
|
+
} else {
|
|
539
|
+
this.ciph.init(encryptMode ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE, new SimpleSecretKey(this.key), new IvParameterSpec(this.realIV));
|
|
540
|
+
}
|
|
541
|
+
} else {
|
|
542
|
+
this.ciph.init(encryptMode ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE, new SimpleSecretKey(this.key));
|
|
543
|
+
}
|
|
544
|
+
} catch (Exception e) {
|
|
545
|
+
if (DEBUG) e.printStackTrace();
|
|
546
|
+
throw new RaiseException(getRuntime(), ciphErr, e.getMessage(), true);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
private byte[] lastIv = null;
|
|
551
|
+
|
|
552
|
+
@JRubyMethod
|
|
553
|
+
public IRubyObject update(IRubyObject data) {
|
|
554
|
+
if (DEBUG) System.out.println("*** update ["+data+"]");
|
|
555
|
+
|
|
556
|
+
byte[] val = data.convertToString().getBytes();
|
|
557
|
+
if(val.length == 0) {
|
|
558
|
+
throw getRuntime().newArgumentError("data must not be empty");
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if(!ciphInited) {
|
|
562
|
+
if (DEBUG) System.out.println("BEFORE INITING");
|
|
563
|
+
doInitialize();
|
|
564
|
+
if (DEBUG) System.out.println("AFTER INITING");
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
byte[] str = new byte[0];
|
|
568
|
+
try {
|
|
569
|
+
byte[] out = ciph.update(val);
|
|
570
|
+
if(out != null) {
|
|
571
|
+
str = out;
|
|
572
|
+
|
|
573
|
+
if(this.realIV != null) {
|
|
574
|
+
if(lastIv == null) {
|
|
575
|
+
lastIv = new byte[ivLen];
|
|
576
|
+
}
|
|
577
|
+
byte[] tmpIv = encryptMode ? out : val;
|
|
578
|
+
if(tmpIv.length >= ivLen) {
|
|
579
|
+
System.arraycopy(tmpIv, tmpIv.length-ivLen, lastIv, 0, ivLen);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
} catch(Exception e) {
|
|
584
|
+
if (DEBUG) e.printStackTrace();
|
|
585
|
+
throw new RaiseException(getRuntime(), ciphErr, e.getMessage(), true);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return RubyString.newString(getRuntime(), new ByteList(str,false));
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
@JRubyMethod(name="<<")
|
|
592
|
+
public IRubyObject update_deprecated(IRubyObject data) {
|
|
593
|
+
getRuntime().getWarnings().warn(IRubyWarnings.ID.DEPRECATED_METHOD, "" + this.getMetaClass().getRealClass().getName() + "#<< is deprecated; use " + this.getMetaClass().getRealClass().getName() + "#update instead");
|
|
594
|
+
return update(data);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
@JRubyMethod(name="final")
|
|
598
|
+
public IRubyObject _final() {
|
|
599
|
+
if(!ciphInited) {
|
|
600
|
+
doInitialize();
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
ByteList str = new ByteList(ByteList.NULL_ARRAY);
|
|
604
|
+
try {
|
|
605
|
+
byte[] out = ciph.doFinal();
|
|
606
|
+
if(out != null) {
|
|
607
|
+
str = new ByteList(out,false);
|
|
608
|
+
// TODO: Modifying this line appears to fix the issue, but I do
|
|
609
|
+
// not have a good reason for why. Best I can tell, lastIv needs
|
|
610
|
+
// to be set regardless of encryptMode, so we'll go with this
|
|
611
|
+
// for now. JRUBY-3335.
|
|
612
|
+
//if(this.realIV != null && encryptMode) {
|
|
613
|
+
if(this.realIV != null) {
|
|
614
|
+
if(lastIv == null) {
|
|
615
|
+
lastIv = new byte[ivLen];
|
|
616
|
+
}
|
|
617
|
+
byte[] tmpIv = out;
|
|
618
|
+
if(tmpIv.length >= ivLen) {
|
|
619
|
+
System.arraycopy(tmpIv, tmpIv.length-ivLen, lastIv, 0, ivLen);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if(this.realIV != null) {
|
|
625
|
+
this.realIV = lastIv;
|
|
626
|
+
doInitialize();
|
|
627
|
+
}
|
|
628
|
+
} catch(Exception e) {
|
|
629
|
+
throw new RaiseException(getRuntime(), ciphErr, e.getMessage(), true);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
return getRuntime().newString(str);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
@JRubyMethod(name="padding=")
|
|
636
|
+
public IRubyObject set_padding(IRubyObject padding) {
|
|
637
|
+
this.padding = padding.toString();
|
|
638
|
+
initialize(RubyString.newString(getRuntime(), name));
|
|
639
|
+
return padding;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
String getAlgorithm() {
|
|
643
|
+
return this.ciph.getAlgorithm();
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
String getName() {
|
|
647
|
+
return this.name;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
String getCryptoBase() {
|
|
651
|
+
return this.cryptoBase;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
String getCryptoMode() {
|
|
655
|
+
return this.cryptoMode;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
int getKeyLen() {
|
|
659
|
+
return this.keyLen;
|
|
660
|
+
}
|
|
661
|
+
}
|