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,84 @@
|
|
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.x509store;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* x509_lookup_method_st and X509_LOOKUP_METHOD in x509_vfy.h
|
32
|
+
*
|
33
|
+
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
|
34
|
+
*/
|
35
|
+
public class LookupMethod {
|
36
|
+
public String name;
|
37
|
+
|
38
|
+
public static interface NewItemFunction extends Function1 {}
|
39
|
+
public static interface FreeFunction extends Function1 {}
|
40
|
+
public static interface InitFunction extends Function1 {}
|
41
|
+
public static interface ShutdownFunction extends Function1 {}
|
42
|
+
public static interface ControlFunction extends Function5 {}
|
43
|
+
public static interface BySubjectFunction extends Function4 {}
|
44
|
+
public static interface ByIssuerSerialNumberFunction extends Function5 {}
|
45
|
+
public static interface ByFingerprintFunction extends Function4 {}
|
46
|
+
public static interface ByAliasFunction extends Function4 {}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* c: new_item
|
50
|
+
*/
|
51
|
+
public NewItemFunction newItem;
|
52
|
+
/**
|
53
|
+
* c: free
|
54
|
+
*/
|
55
|
+
public FreeFunction free;
|
56
|
+
/**
|
57
|
+
* c: init
|
58
|
+
*/
|
59
|
+
public InitFunction init;
|
60
|
+
/**
|
61
|
+
* c: shutdown
|
62
|
+
*/
|
63
|
+
public ShutdownFunction shutdown;
|
64
|
+
/**
|
65
|
+
* c: ctrl
|
66
|
+
*/
|
67
|
+
public ControlFunction control;
|
68
|
+
/**
|
69
|
+
* c: get_by_subject
|
70
|
+
*/
|
71
|
+
public BySubjectFunction getBySubject;
|
72
|
+
/**
|
73
|
+
* c: get_by_issuer_serial
|
74
|
+
*/
|
75
|
+
public ByIssuerSerialNumberFunction getByIssuerSerialNumber;
|
76
|
+
/**
|
77
|
+
* c: get_by_fingerprint
|
78
|
+
*/
|
79
|
+
public ByFingerprintFunction getByFingerprint;
|
80
|
+
/**
|
81
|
+
* c: get_by_alias
|
82
|
+
*/
|
83
|
+
public ByAliasFunction getByAlias;
|
84
|
+
}// X509_LOOKUP_METHOD
|
@@ -0,0 +1,85 @@
|
|
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.x509store;
|
29
|
+
|
30
|
+
import java.security.MessageDigest;
|
31
|
+
|
32
|
+
import javax.security.auth.x500.X500Principal;
|
33
|
+
|
34
|
+
import org.bouncycastle.asn1.ASN1InputStream;
|
35
|
+
import org.bouncycastle.asn1.ASN1Sequence;
|
36
|
+
import org.bouncycastle.asn1.x509.X509Name;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* c: X509_NAME
|
40
|
+
*
|
41
|
+
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
|
42
|
+
*/
|
43
|
+
public class Name {
|
44
|
+
public X509Name name;
|
45
|
+
|
46
|
+
public Name(X500Principal nm) {
|
47
|
+
try {
|
48
|
+
this.name = new X509Name((ASN1Sequence)new ASN1InputStream(nm.getEncoded()).readObject());
|
49
|
+
} catch(Exception e) {
|
50
|
+
this.name = null;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
public Name(X509Name nm) {
|
55
|
+
this.name = nm;
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* c: X509_NAME_hash
|
60
|
+
*/
|
61
|
+
public long hash() {
|
62
|
+
try {
|
63
|
+
byte[] bytes = name.getEncoded();
|
64
|
+
byte[] md = null;
|
65
|
+
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
66
|
+
md = md5.digest(bytes);
|
67
|
+
long result = 0;
|
68
|
+
result |= md[3] & 0xff; result <<= 8;
|
69
|
+
result |= md[2] & 0xff; result <<= 8;
|
70
|
+
result |= md[1] & 0xff; result <<= 8;
|
71
|
+
result |= md[0] & 0xff;
|
72
|
+
return result & 0xffffffff;
|
73
|
+
} catch(Exception e) {
|
74
|
+
return 0;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
public boolean isEqual(X500Principal oname) {
|
79
|
+
try {
|
80
|
+
return new X500Principal(name.getEncoded()).equals(oname);
|
81
|
+
} catch(Exception e) {
|
82
|
+
return false;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}// X509_NAME
|
@@ -0,0 +1,1210 @@
|
|
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
|
+
* Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com>
|
16
|
+
*
|
17
|
+
* Alternatively, the contents of this file may be used under the terms of
|
18
|
+
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
19
|
+
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
20
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
21
|
+
* of those above. If you wish to allow use of your version of this file only
|
22
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
23
|
+
* use your version of this file under the terms of the CPL, indicate your
|
24
|
+
* decision by deleting the provisions above and replace them with the notice
|
25
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
26
|
+
* the provisions above, a recipient may use your version of this file under
|
27
|
+
* the terms of any one of the CPL, the GPL or the LGPL.
|
28
|
+
***** END LICENSE BLOCK *****/
|
29
|
+
package org.jruby.ext.openssl.x509store;
|
30
|
+
|
31
|
+
import java.io.IOException;
|
32
|
+
import java.io.Writer;
|
33
|
+
import java.io.BufferedWriter;
|
34
|
+
import java.io.BufferedReader;
|
35
|
+
import java.io.Reader;
|
36
|
+
import java.io.ByteArrayInputStream;
|
37
|
+
import java.io.ByteArrayOutputStream;
|
38
|
+
|
39
|
+
import java.math.BigInteger;
|
40
|
+
|
41
|
+
import java.security.KeyPair;
|
42
|
+
import java.security.SecureRandom;
|
43
|
+
import java.security.cert.X509Certificate;
|
44
|
+
import java.security.cert.X509CRL;
|
45
|
+
import java.security.cert.CertificateEncodingException;
|
46
|
+
import java.security.cert.CRLException;
|
47
|
+
import java.security.interfaces.DSAPublicKey;
|
48
|
+
import java.security.interfaces.DSAPrivateKey;
|
49
|
+
import java.security.interfaces.RSAPublicKey;
|
50
|
+
import java.security.interfaces.RSAPrivateCrtKey;
|
51
|
+
import java.security.spec.InvalidParameterSpecException;
|
52
|
+
|
53
|
+
import java.util.regex.Matcher;
|
54
|
+
import java.util.regex.Pattern;
|
55
|
+
|
56
|
+
import javax.crypto.spec.DHParameterSpec;
|
57
|
+
|
58
|
+
import org.jruby.ext.openssl.OpenSSLReal;
|
59
|
+
import org.jruby.ext.openssl.PKCS10CertificationRequestExt;
|
60
|
+
|
61
|
+
import org.bouncycastle.asn1.ASN1InputStream;
|
62
|
+
import org.bouncycastle.asn1.ASN1OutputStream;
|
63
|
+
import org.bouncycastle.asn1.ASN1EncodableVector;
|
64
|
+
import org.bouncycastle.asn1.ASN1Sequence;
|
65
|
+
import org.bouncycastle.asn1.DERInteger;
|
66
|
+
import org.bouncycastle.asn1.DEROctetString;
|
67
|
+
import org.bouncycastle.asn1.DERUTF8String;
|
68
|
+
import org.bouncycastle.asn1.DERSequence;
|
69
|
+
import org.bouncycastle.asn1.DERTaggedObject;
|
70
|
+
import org.bouncycastle.asn1.DERObjectIdentifier;
|
71
|
+
import org.bouncycastle.asn1.DERObject;
|
72
|
+
import org.bouncycastle.asn1.x509.DSAParameter;
|
73
|
+
import org.bouncycastle.asn1.cms.ContentInfo;
|
74
|
+
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
|
75
|
+
import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure;
|
76
|
+
import org.bouncycastle.asn1.x509.RSAPublicKeyStructure;
|
77
|
+
import org.bouncycastle.crypto.PBEParametersGenerator;
|
78
|
+
import org.bouncycastle.crypto.generators.OpenSSLPBEParametersGenerator;
|
79
|
+
import org.bouncycastle.crypto.params.KeyParameter;
|
80
|
+
import org.bouncycastle.util.encoders.Base64;
|
81
|
+
import org.bouncycastle.util.encoders.Hex;
|
82
|
+
import org.bouncycastle.cms.CMSSignedData;
|
83
|
+
|
84
|
+
import java.security.Key;
|
85
|
+
import java.security.KeyFactory;
|
86
|
+
import java.security.NoSuchAlgorithmException;
|
87
|
+
import java.security.PublicKey;
|
88
|
+
import java.security.cert.CertificateFactory;
|
89
|
+
import java.security.spec.DSAPrivateKeySpec;
|
90
|
+
import java.security.spec.DSAPublicKeySpec;
|
91
|
+
import java.security.spec.InvalidKeySpecException;
|
92
|
+
import java.security.spec.KeySpec;
|
93
|
+
import java.security.spec.RSAPrivateCrtKeySpec;
|
94
|
+
import java.security.spec.RSAPublicKeySpec;
|
95
|
+
import java.security.spec.X509EncodedKeySpec;
|
96
|
+
import java.util.StringTokenizer;
|
97
|
+
|
98
|
+
import javax.crypto.Cipher;
|
99
|
+
import javax.crypto.SecretKey;
|
100
|
+
import javax.crypto.spec.IvParameterSpec;
|
101
|
+
import javax.crypto.spec.SecretKeySpec;
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Helper class to read and write PEM files correctly.
|
105
|
+
*
|
106
|
+
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
|
107
|
+
*/
|
108
|
+
public class PEMInputOutput {
|
109
|
+
public static final String BEF = "-----";
|
110
|
+
public static final String AFT = "-----";
|
111
|
+
public static final String BEF_G = BEF+"BEGIN ";
|
112
|
+
public static final String BEF_E = BEF+"END ";
|
113
|
+
public static final String PEM_STRING_X509_OLD="X509 CERTIFICATE";
|
114
|
+
public static final String PEM_STRING_X509="CERTIFICATE";
|
115
|
+
public static final String PEM_STRING_X509_PAIR="CERTIFICATE PAIR";
|
116
|
+
public static final String PEM_STRING_X509_TRUSTED="TRUSTED CERTIFICATE";
|
117
|
+
public static final String PEM_STRING_X509_REQ_OLD="NEW CERTIFICATE REQUEST";
|
118
|
+
public static final String PEM_STRING_X509_REQ="CERTIFICATE REQUEST";
|
119
|
+
public static final String PEM_STRING_X509_CRL="X509 CRL";
|
120
|
+
public static final String PEM_STRING_EVP_PKEY="ANY PRIVATE KEY";
|
121
|
+
public static final String PEM_STRING_PUBLIC="PUBLIC KEY";
|
122
|
+
public static final String PEM_STRING_RSA="RSA PRIVATE KEY";
|
123
|
+
public static final String PEM_STRING_RSA_PUBLIC="RSA PUBLIC KEY";
|
124
|
+
public static final String PEM_STRING_DSA="DSA PRIVATE KEY";
|
125
|
+
public static final String PEM_STRING_DSA_PUBLIC="DSA PUBLIC KEY";
|
126
|
+
public static final String PEM_STRING_PKCS7="PKCS7";
|
127
|
+
public static final String PEM_STRING_PKCS8="ENCRYPTED PRIVATE KEY";
|
128
|
+
public static final String PEM_STRING_PKCS8INF="PRIVATE KEY";
|
129
|
+
public static final String PEM_STRING_DHPARAMS="DH PARAMETERS";
|
130
|
+
public static final String PEM_STRING_SSL_SESSION="SSL SESSION PARAMETERS";
|
131
|
+
public static final String PEM_STRING_DSAPARAMS="DSA PARAMETERS";
|
132
|
+
public static final String PEM_STRING_ECDSA_PUBLIC="ECDSA PUBLIC KEY";
|
133
|
+
public static final String PEM_STRING_ECPARAMETERS="EC PARAMETERS";
|
134
|
+
public static final String PEM_STRING_ECPRIVATEKEY="EC PRIVATE KEY";
|
135
|
+
|
136
|
+
private static final Pattern DH_PARAM_PATTERN = Pattern.compile(
|
137
|
+
"(-----BEGIN DH PARAMETERS-----)(.*)(-----END DH PARAMETERS-----)",
|
138
|
+
Pattern.MULTILINE);
|
139
|
+
private static final int DH_PARAM_GROUP = 2; // the group above containing encoded params
|
140
|
+
|
141
|
+
private static BufferedReader makeBuffered(Reader in) {
|
142
|
+
if(in instanceof BufferedReader) {
|
143
|
+
return (BufferedReader)in;
|
144
|
+
}
|
145
|
+
return new BufferedReader(in);
|
146
|
+
}
|
147
|
+
|
148
|
+
private static BufferedWriter makeBuffered(Writer out) {
|
149
|
+
if(out instanceof BufferedWriter) {
|
150
|
+
return (BufferedWriter)out;
|
151
|
+
}
|
152
|
+
return new BufferedWriter(out);
|
153
|
+
}
|
154
|
+
|
155
|
+
public static Object readPEM(Reader in,char[] f) throws IOException {
|
156
|
+
BufferedReader _in = makeBuffered(in);
|
157
|
+
String line;
|
158
|
+
while ((line = _in.readLine()) != null) {
|
159
|
+
if(line.indexOf(BEF_G+PEM_STRING_PUBLIC) != -1) {
|
160
|
+
try {
|
161
|
+
return readPublicKey(_in,BEF_E+PEM_STRING_PUBLIC);
|
162
|
+
} catch (Exception e) {
|
163
|
+
throw new IOException("problem creating public key: " + e.toString());
|
164
|
+
}
|
165
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_DSA) != -1) {
|
166
|
+
try {
|
167
|
+
return readKeyPair(_in,f, "DSA", BEF_E+PEM_STRING_DSA);
|
168
|
+
} catch (Exception e) {
|
169
|
+
throw new IOException("problem creating DSA private key: " + e.toString());
|
170
|
+
}
|
171
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_RSA_PUBLIC) != -1) {
|
172
|
+
try {
|
173
|
+
return readPublicKey(_in,BEF_E+PEM_STRING_RSA_PUBLIC);
|
174
|
+
} catch (Exception e) {
|
175
|
+
throw new IOException("problem creating RSA public key: " + e.toString());
|
176
|
+
}
|
177
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_OLD) != -1) {
|
178
|
+
try {
|
179
|
+
return readAuxCertificate(_in,BEF_E+PEM_STRING_X509_OLD);
|
180
|
+
} catch (Exception e) {
|
181
|
+
throw new IOException("problem creating X509 Aux certificate: " + e.toString());
|
182
|
+
}
|
183
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509) != -1) {
|
184
|
+
try {
|
185
|
+
return readAuxCertificate(_in,BEF_E+PEM_STRING_X509);
|
186
|
+
} catch (Exception e) {
|
187
|
+
throw new IOException("problem creating X509 Aux certificate: " + e.toString());
|
188
|
+
}
|
189
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_TRUSTED) != -1) {
|
190
|
+
try {
|
191
|
+
return readAuxCertificate(_in,BEF_E+PEM_STRING_X509_TRUSTED);
|
192
|
+
} catch (Exception e) {
|
193
|
+
throw new IOException("problem creating X509 Aux certificate: " + e.toString());
|
194
|
+
}
|
195
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_CRL) != -1) {
|
196
|
+
try {
|
197
|
+
return readCRL(_in,BEF_E+PEM_STRING_X509_CRL);
|
198
|
+
} catch (Exception e) {
|
199
|
+
throw new IOException("problem creating X509 CRL: " + e.toString());
|
200
|
+
}
|
201
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_REQ) != -1) {
|
202
|
+
try {
|
203
|
+
return readCertificateRequest(_in,BEF_E+PEM_STRING_X509_REQ);
|
204
|
+
} catch (Exception e) {
|
205
|
+
throw new IOException("problem creating X509 REQ: " + e.toString());
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
return null;
|
210
|
+
}
|
211
|
+
|
212
|
+
public static byte[] readPEMToDER(Reader in) throws IOException {
|
213
|
+
BufferedReader _in = makeBuffered(in);
|
214
|
+
String line;
|
215
|
+
while ((line = _in.readLine()) != null) {
|
216
|
+
if(line.indexOf(BEF_G+PEM_STRING_PUBLIC) != -1) {
|
217
|
+
try {
|
218
|
+
return readBytes(_in,BEF_E+PEM_STRING_PUBLIC);
|
219
|
+
} catch (Exception e) {
|
220
|
+
throw new IOException("problem reading PEM public key: " + e.toString());
|
221
|
+
}
|
222
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_DSA) != -1) {
|
223
|
+
try {
|
224
|
+
return readBytes(_in, BEF_E+PEM_STRING_DSA);
|
225
|
+
} catch (Exception e) {
|
226
|
+
throw new IOException("problem reading PEM DSA private key: " + e.toString());
|
227
|
+
}
|
228
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_RSA_PUBLIC) != -1) {
|
229
|
+
try {
|
230
|
+
return readBytes(_in,BEF_E+PEM_STRING_RSA_PUBLIC);
|
231
|
+
} catch (Exception e) {
|
232
|
+
throw new IOException("problem reading PEM RSA public key: " + e.toString());
|
233
|
+
}
|
234
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_OLD) != -1) {
|
235
|
+
try {
|
236
|
+
return readBytes(_in,BEF_E+PEM_STRING_X509_OLD);
|
237
|
+
} catch (Exception e) {
|
238
|
+
throw new IOException("problem reading PEM X509 Aux certificate: " + e.toString());
|
239
|
+
}
|
240
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509) != -1) {
|
241
|
+
try {
|
242
|
+
return readBytes(_in,BEF_E+PEM_STRING_X509);
|
243
|
+
} catch (Exception e) {
|
244
|
+
throw new IOException("problem reading PEM X509 Aux certificate: " + e.toString());
|
245
|
+
}
|
246
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_TRUSTED) != -1) {
|
247
|
+
try {
|
248
|
+
return readBytes(_in,BEF_E+PEM_STRING_X509_TRUSTED);
|
249
|
+
} catch (Exception e) {
|
250
|
+
throw new IOException("problem reading PEM X509 Aux certificate: " + e.toString());
|
251
|
+
}
|
252
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_CRL) != -1) {
|
253
|
+
try {
|
254
|
+
return readBytes(_in,BEF_E+PEM_STRING_X509_CRL);
|
255
|
+
} catch (Exception e) {
|
256
|
+
throw new IOException("problem reading PEM X509 CRL: " + e.toString());
|
257
|
+
}
|
258
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_REQ) != -1) {
|
259
|
+
try {
|
260
|
+
return readBytes(_in,BEF_E+PEM_STRING_X509_REQ);
|
261
|
+
} catch (Exception e) {
|
262
|
+
throw new IOException("problem reading PEM X509 REQ: " + e.toString());
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
266
|
+
return null;
|
267
|
+
}
|
268
|
+
|
269
|
+
public static DSAPublicKey readDSAPubKey(Reader in, char[] f) throws IOException {
|
270
|
+
// System.out.println("WARNING: read_DSA_PUBKEY");
|
271
|
+
return null;
|
272
|
+
}
|
273
|
+
public static DSAPublicKey readDSAPublicKey(Reader in, char[] f) throws IOException {
|
274
|
+
BufferedReader _in = makeBuffered(in);
|
275
|
+
String line;
|
276
|
+
while ((line = _in.readLine()) != null) {
|
277
|
+
if(line.indexOf(BEF_G+PEM_STRING_PUBLIC) != -1) {
|
278
|
+
try {
|
279
|
+
return (DSAPublicKey)readPublicKey(_in,"DSA",BEF_E+PEM_STRING_PUBLIC);
|
280
|
+
} catch (Exception e) {
|
281
|
+
throw new IOException("problem creating DSA public key: " + e.toString());
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
return null;
|
286
|
+
}
|
287
|
+
public static KeyPair readDSAPrivateKey(Reader in, char[] f) throws IOException {
|
288
|
+
BufferedReader _in = makeBuffered(in);
|
289
|
+
String line;
|
290
|
+
while ((line = _in.readLine()) != null) {
|
291
|
+
if(line.indexOf(BEF_G+PEM_STRING_DSA) != -1) {
|
292
|
+
try {
|
293
|
+
return readKeyPair(_in,f, "DSA", BEF_E+PEM_STRING_DSA);
|
294
|
+
} catch (Exception e) {
|
295
|
+
throw new IOException("problem creating DSA private key: " + e.toString());
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
299
|
+
return null;
|
300
|
+
}
|
301
|
+
/** reads an RSA public key encoded in an SubjectPublicKeyInfo RSA structure. */
|
302
|
+
public static RSAPublicKey readRSAPubKey(Reader in, char[] f) throws IOException {
|
303
|
+
BufferedReader _in = makeBuffered(in);
|
304
|
+
String line;
|
305
|
+
while ((line = _in.readLine()) != null) {
|
306
|
+
if(line.indexOf(BEF_G+PEM_STRING_PUBLIC) != -1) {
|
307
|
+
try {
|
308
|
+
return readRSAPublicKey(_in,BEF_E+PEM_STRING_PUBLIC);
|
309
|
+
} catch (Exception e) {
|
310
|
+
throw new IOException("problem creating RSA public key: " + e.toString());
|
311
|
+
}
|
312
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_RSA_PUBLIC) != -1) {
|
313
|
+
try {
|
314
|
+
return readRSAPublicKey(_in,BEF_E+PEM_STRING_RSA_PUBLIC);
|
315
|
+
} catch (Exception e) {
|
316
|
+
throw new IOException("problem creating RSA public key: " + e.toString());
|
317
|
+
}
|
318
|
+
}
|
319
|
+
}
|
320
|
+
return null;
|
321
|
+
}
|
322
|
+
/** reads an RSA public key encoded in an PKCS#1 RSA structure. */
|
323
|
+
public static RSAPublicKey readRSAPublicKey(Reader in, char[] f) throws IOException {
|
324
|
+
BufferedReader _in = makeBuffered(in);
|
325
|
+
String line;
|
326
|
+
while ((line = _in.readLine()) != null) {
|
327
|
+
if(line.indexOf(BEF_G+PEM_STRING_PUBLIC) != -1) {
|
328
|
+
try {
|
329
|
+
return (RSAPublicKey)readPublicKey(_in,"RSA",BEF_E+PEM_STRING_PUBLIC);
|
330
|
+
} catch (Exception e) {
|
331
|
+
throw new IOException("problem creating RSA public key: " + e.toString());
|
332
|
+
}
|
333
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_RSA_PUBLIC) != -1) {
|
334
|
+
try {
|
335
|
+
return (RSAPublicKey)readPublicKey(_in,"RSA",BEF_E+PEM_STRING_RSA_PUBLIC);
|
336
|
+
} catch (Exception e) {
|
337
|
+
throw new IOException("problem creating RSA public key: " + e.toString());
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}
|
341
|
+
return null;
|
342
|
+
}
|
343
|
+
public static KeyPair readRSAPrivateKey(Reader in, char[] f) throws IOException {
|
344
|
+
BufferedReader _in = makeBuffered(in);
|
345
|
+
String line;
|
346
|
+
while ((line = _in.readLine()) != null) {
|
347
|
+
if(line.indexOf(BEF_G+PEM_STRING_RSA) != -1) {
|
348
|
+
try {
|
349
|
+
return readKeyPair(_in,f, "RSA", BEF_E+PEM_STRING_RSA);
|
350
|
+
} catch (Exception e) {
|
351
|
+
throw new IOException("problem creating RSA private key: " + e.toString());
|
352
|
+
}
|
353
|
+
}
|
354
|
+
}
|
355
|
+
return null;
|
356
|
+
}
|
357
|
+
public static CMSSignedData readPKCS7(Reader in, char[] f) throws IOException {
|
358
|
+
BufferedReader _in = makeBuffered(in);
|
359
|
+
String line;
|
360
|
+
while ((line = _in.readLine()) != null) {
|
361
|
+
if(line.indexOf(BEF_G+PEM_STRING_PKCS7) != -1) {
|
362
|
+
try {
|
363
|
+
return readPKCS7(_in,f, BEF_E+PEM_STRING_PKCS7);
|
364
|
+
} catch (Exception e) {
|
365
|
+
throw new IOException("problem creating PKCS7: " + e.toString());
|
366
|
+
}
|
367
|
+
}
|
368
|
+
}
|
369
|
+
return null;
|
370
|
+
}
|
371
|
+
public static X509AuxCertificate readX509Certificate(Reader in, char[] f) throws IOException {
|
372
|
+
BufferedReader _in = makeBuffered(in);
|
373
|
+
String line;
|
374
|
+
while ((line = _in.readLine()) != null) {
|
375
|
+
if(line.indexOf(BEF_G+PEM_STRING_X509_OLD) != -1) {
|
376
|
+
try {
|
377
|
+
return new X509AuxCertificate(readCertificate(_in,BEF_E+PEM_STRING_X509_OLD));
|
378
|
+
} catch (Exception e) {
|
379
|
+
throw new IOException("problem creating X509 certificate: " + e.toString());
|
380
|
+
}
|
381
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509) != -1) {
|
382
|
+
try {
|
383
|
+
return new X509AuxCertificate(readCertificate(_in,BEF_E+PEM_STRING_X509));
|
384
|
+
} catch (Exception e) {
|
385
|
+
throw new IOException("problem creating X509 certificate: " + e.toString());
|
386
|
+
}
|
387
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_TRUSTED) != -1) {
|
388
|
+
try {
|
389
|
+
return new X509AuxCertificate(readCertificate(_in,BEF_E+PEM_STRING_X509_TRUSTED));
|
390
|
+
} catch (Exception e) {
|
391
|
+
throw new IOException("problem creating X509 certificate: " + e.toString());
|
392
|
+
}
|
393
|
+
}
|
394
|
+
}
|
395
|
+
return null;
|
396
|
+
}
|
397
|
+
public static X509AuxCertificate readX509Aux(Reader in, char[] f) throws IOException {
|
398
|
+
BufferedReader _in = makeBuffered(in);
|
399
|
+
String line;
|
400
|
+
while ((line = _in.readLine()) != null) {
|
401
|
+
if(line.indexOf(BEF_G+PEM_STRING_X509_OLD) != -1) {
|
402
|
+
try {
|
403
|
+
return readAuxCertificate(_in,BEF_E+PEM_STRING_X509_OLD);
|
404
|
+
} catch (Exception e) {
|
405
|
+
throw new IOException("problem creating X509 Aux certificate: " + e.toString());
|
406
|
+
}
|
407
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509) != -1) {
|
408
|
+
try {
|
409
|
+
return readAuxCertificate(_in,BEF_E+PEM_STRING_X509);
|
410
|
+
} catch (Exception e) {
|
411
|
+
throw new IOException("problem creating X509 Aux certificate: " + e.toString());
|
412
|
+
}
|
413
|
+
} else if(line.indexOf(BEF_G+PEM_STRING_X509_TRUSTED) != -1) {
|
414
|
+
try {
|
415
|
+
return readAuxCertificate(_in,BEF_E+PEM_STRING_X509_TRUSTED);
|
416
|
+
} catch (Exception e) {
|
417
|
+
throw new IOException("problem creating X509 Aux certificate: " + e.toString());
|
418
|
+
}
|
419
|
+
}
|
420
|
+
}
|
421
|
+
return null;
|
422
|
+
}
|
423
|
+
public static X509CRL readX509CRL(Reader in, char[] f) throws IOException {
|
424
|
+
BufferedReader _in = makeBuffered(in);
|
425
|
+
String line;
|
426
|
+
while ((line = _in.readLine()) != null) {
|
427
|
+
if(line.indexOf(BEF_G+PEM_STRING_X509_CRL) != -1) {
|
428
|
+
try {
|
429
|
+
return readCRL(_in,BEF_E+PEM_STRING_X509_CRL);
|
430
|
+
} catch (Exception e) {
|
431
|
+
throw new IOException("problem creating X509 CRL: " + e.toString());
|
432
|
+
}
|
433
|
+
}
|
434
|
+
}
|
435
|
+
return null;
|
436
|
+
}
|
437
|
+
public static PKCS10CertificationRequestExt readX509Request(Reader in, char[] f) throws IOException {
|
438
|
+
BufferedReader _in = makeBuffered(in);
|
439
|
+
String line;
|
440
|
+
while ((line = _in.readLine()) != null) {
|
441
|
+
if(line.indexOf(BEF_G+PEM_STRING_X509_REQ) != -1) {
|
442
|
+
try {
|
443
|
+
return readCertificateRequest(_in,BEF_E+PEM_STRING_X509_REQ);
|
444
|
+
} catch (Exception e) {
|
445
|
+
throw new IOException("problem creating X509 REQ: " + e.toString());
|
446
|
+
}
|
447
|
+
}
|
448
|
+
}
|
449
|
+
return null;
|
450
|
+
}
|
451
|
+
|
452
|
+
public static DHParameterSpec readDHParameters(Reader _in)
|
453
|
+
throws IOException, InvalidParameterSpecException {
|
454
|
+
BufferedReader in = makeBuffered(_in);
|
455
|
+
String line;
|
456
|
+
StringBuilder buf = new StringBuilder();
|
457
|
+
while ((line = in.readLine()) != null) {
|
458
|
+
if (line.indexOf(BEF_G + PEM_STRING_DHPARAMS) >= 0) {
|
459
|
+
do {
|
460
|
+
buf.append(line.trim());
|
461
|
+
} while (line.indexOf(BEF_E + PEM_STRING_DHPARAMS) < 0 &&
|
462
|
+
(line = in.readLine()) != null);
|
463
|
+
break;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
Matcher m = DH_PARAM_PATTERN.matcher(buf.toString());
|
467
|
+
if (m.find()) {
|
468
|
+
try {
|
469
|
+
byte[] decoded = Base64.decode(m.group(DH_PARAM_GROUP));
|
470
|
+
ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(decoded));
|
471
|
+
ASN1Sequence seq = (ASN1Sequence)aIn.readObject();
|
472
|
+
BigInteger p = ((DERInteger)seq.getObjectAt(0)).getValue();
|
473
|
+
BigInteger g = ((DERInteger)seq.getObjectAt(1)).getValue();
|
474
|
+
return new DHParameterSpec(p, g);
|
475
|
+
} catch (Exception e) {}
|
476
|
+
}
|
477
|
+
// probably not exactly the intended use of this exception, but
|
478
|
+
// close enough for internal throw/catch
|
479
|
+
throw new InvalidParameterSpecException("invalid " + PEM_STRING_DHPARAMS);
|
480
|
+
}
|
481
|
+
|
482
|
+
public static void writeDSAPublicKey(Writer _out, DSAPublicKey obj) throws IOException {
|
483
|
+
BufferedWriter out = makeBuffered(_out);
|
484
|
+
byte[] encoding = obj.getEncoded();
|
485
|
+
out.write(BEF_G + PEM_STRING_PUBLIC + AFT);
|
486
|
+
out.newLine();
|
487
|
+
writeEncoded(out,encoding);
|
488
|
+
out.write(BEF_E + PEM_STRING_PUBLIC + AFT);
|
489
|
+
out.newLine();
|
490
|
+
out.flush();
|
491
|
+
}
|
492
|
+
/** writes an RSA public key encoded in an PKCS#1 RSA structure. */
|
493
|
+
public static void writeRSAPublicKey(Writer _out, RSAPublicKey obj) throws IOException {
|
494
|
+
BufferedWriter out = makeBuffered(_out);
|
495
|
+
byte[] encoding = obj.getEncoded();
|
496
|
+
out.write(BEF_G + PEM_STRING_PUBLIC + AFT);
|
497
|
+
out.newLine();
|
498
|
+
writeEncoded(out,encoding);
|
499
|
+
out.write(BEF_E + PEM_STRING_PUBLIC + AFT);
|
500
|
+
out.newLine();
|
501
|
+
out.flush();
|
502
|
+
}
|
503
|
+
public static void writePKCS7(Writer _out, ContentInfo obj) throws IOException {
|
504
|
+
BufferedWriter out = makeBuffered(_out);
|
505
|
+
byte[] encoding = obj.getEncoded();
|
506
|
+
out.write(BEF_G + PEM_STRING_PKCS7 + AFT);
|
507
|
+
out.newLine();
|
508
|
+
writeEncoded(out,encoding);
|
509
|
+
out.write(BEF_E + PEM_STRING_PKCS7 + AFT);
|
510
|
+
out.newLine();
|
511
|
+
out.flush();
|
512
|
+
}
|
513
|
+
public static void writePKCS7(Writer _out, CMSSignedData obj) throws IOException {
|
514
|
+
BufferedWriter out = makeBuffered(_out);
|
515
|
+
byte[] encoding = obj.getEncoded();
|
516
|
+
out.write(BEF_G + PEM_STRING_PKCS7 + AFT);
|
517
|
+
out.newLine();
|
518
|
+
writeEncoded(out,encoding);
|
519
|
+
out.write(BEF_E + PEM_STRING_PKCS7 + AFT);
|
520
|
+
out.newLine();
|
521
|
+
out.flush();
|
522
|
+
}
|
523
|
+
public static void writeX509Certificate(Writer _out, X509Certificate obj) throws IOException {
|
524
|
+
BufferedWriter out = makeBuffered(_out);
|
525
|
+
try {
|
526
|
+
byte[] encoding = obj.getEncoded();
|
527
|
+
out.write(BEF_G + PEM_STRING_X509 + AFT);
|
528
|
+
out.newLine();
|
529
|
+
writeEncoded(out,encoding);
|
530
|
+
out.write(BEF_E + PEM_STRING_X509 + AFT);
|
531
|
+
out.newLine();
|
532
|
+
out.flush();
|
533
|
+
} catch(CertificateEncodingException e) {
|
534
|
+
throw new IOException("problem with encoding object in write_X509");
|
535
|
+
}
|
536
|
+
}
|
537
|
+
public static void writeX509Aux(Writer _out, X509AuxCertificate obj) throws IOException {
|
538
|
+
BufferedWriter out = makeBuffered(_out);
|
539
|
+
byte[] encoding = null;
|
540
|
+
try {
|
541
|
+
if(obj.getAux() == null) {
|
542
|
+
encoding = obj.getEncoded();
|
543
|
+
} else {
|
544
|
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
545
|
+
byte[] ymp = obj.getEncoded();
|
546
|
+
baos.write(ymp,0,ymp.length);
|
547
|
+
|
548
|
+
X509Aux aux = obj.getAux();
|
549
|
+
ASN1EncodableVector a1 = new ASN1EncodableVector();
|
550
|
+
if(aux.trust.size()>0) {
|
551
|
+
ASN1EncodableVector a2 = new ASN1EncodableVector();
|
552
|
+
for(String trust : aux.trust) {
|
553
|
+
a2.add(new DERObjectIdentifier(trust));
|
554
|
+
}
|
555
|
+
a1.add(new DERSequence(a2));
|
556
|
+
}
|
557
|
+
if(aux.reject.size()>0) {
|
558
|
+
ASN1EncodableVector a2 = new ASN1EncodableVector();
|
559
|
+
for(String reject : aux.reject) {
|
560
|
+
a2.add(new DERObjectIdentifier(reject));
|
561
|
+
}
|
562
|
+
a1.add(new DERTaggedObject(0,new DERSequence(a2)));
|
563
|
+
}
|
564
|
+
if(aux.alias != null) {
|
565
|
+
a1.add(new DERUTF8String(aux.alias));
|
566
|
+
}
|
567
|
+
if(aux.keyid != null) {
|
568
|
+
a1.add(new DEROctetString(aux.keyid));
|
569
|
+
}
|
570
|
+
if(aux.other.size()>0) {
|
571
|
+
ASN1EncodableVector a2 = new ASN1EncodableVector();
|
572
|
+
for(DERObject other : aux.other) {
|
573
|
+
a2.add(other);
|
574
|
+
}
|
575
|
+
a1.add(new DERTaggedObject(1,new DERSequence(a2)));
|
576
|
+
}
|
577
|
+
ymp = new DERSequence(a1).getEncoded();
|
578
|
+
baos.write(ymp,0,ymp.length);
|
579
|
+
encoding = baos.toByteArray();
|
580
|
+
}
|
581
|
+
} catch(CertificateEncodingException e) {
|
582
|
+
throw new IOException("problem with encoding object in write_X509_AUX");
|
583
|
+
}
|
584
|
+
out.write(BEF_G + PEM_STRING_X509_TRUSTED + AFT);
|
585
|
+
out.newLine();
|
586
|
+
writeEncoded(out,encoding);
|
587
|
+
out.write(BEF_E + PEM_STRING_X509_TRUSTED + AFT);
|
588
|
+
out.newLine();
|
589
|
+
out.flush();
|
590
|
+
}
|
591
|
+
public static void writeX509CRL(Writer _out, X509CRL obj) throws IOException {
|
592
|
+
BufferedWriter out = makeBuffered(_out);
|
593
|
+
try {
|
594
|
+
byte[] encoding = obj.getEncoded();
|
595
|
+
out.write(BEF_G + PEM_STRING_X509_CRL + AFT);
|
596
|
+
out.newLine();
|
597
|
+
writeEncoded(out,encoding);
|
598
|
+
out.write(BEF_E + PEM_STRING_X509_CRL + AFT);
|
599
|
+
out.newLine();
|
600
|
+
out.flush();
|
601
|
+
} catch(CRLException e) {
|
602
|
+
throw new IOException("problem with encoding object in write_X509_CRL");
|
603
|
+
}
|
604
|
+
}
|
605
|
+
public static void writeX509Request(Writer _out, PKCS10CertificationRequestExt obj) throws IOException {
|
606
|
+
BufferedWriter out = makeBuffered(_out);
|
607
|
+
byte[] encoding = obj.getEncoded();
|
608
|
+
out.write(BEF_G + PEM_STRING_X509_REQ + AFT);
|
609
|
+
out.newLine();
|
610
|
+
writeEncoded(out,encoding);
|
611
|
+
out.write(BEF_E + PEM_STRING_X509_REQ + AFT);
|
612
|
+
out.newLine();
|
613
|
+
out.flush();
|
614
|
+
}
|
615
|
+
|
616
|
+
private static SecureRandom random;
|
617
|
+
static {
|
618
|
+
try {
|
619
|
+
random = SecureRandom.getInstance("SHA1PRNG");
|
620
|
+
} catch(Exception e) {
|
621
|
+
random = null;
|
622
|
+
}
|
623
|
+
}
|
624
|
+
|
625
|
+
public static void writeDSAPrivateKey(Writer _out, DSAPrivateKey obj, String algo, char[] f) throws IOException {
|
626
|
+
BufferedWriter out = makeBuffered(_out);
|
627
|
+
ByteArrayInputStream bIn = new ByteArrayInputStream(obj.getEncoded());
|
628
|
+
ASN1InputStream aIn = new ASN1InputStream(bIn);
|
629
|
+
PrivateKeyInfo info = new PrivateKeyInfo((ASN1Sequence)aIn.readObject());
|
630
|
+
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
631
|
+
ASN1OutputStream aOut = new ASN1OutputStream(bOut);
|
632
|
+
|
633
|
+
DSAParameter p = DSAParameter.getInstance(info.getAlgorithmId().getParameters());
|
634
|
+
ASN1EncodableVector v = new ASN1EncodableVector();
|
635
|
+
|
636
|
+
v.add(new DERInteger(0));
|
637
|
+
v.add(new DERInteger(p.getP()));
|
638
|
+
v.add(new DERInteger(p.getQ()));
|
639
|
+
v.add(new DERInteger(p.getG()));
|
640
|
+
|
641
|
+
BigInteger x = ((DSAPrivateKey)obj).getX();
|
642
|
+
BigInteger y = p.getG().modPow(x, p.getP());
|
643
|
+
|
644
|
+
v.add(new DERInteger(y));
|
645
|
+
v.add(new DERInteger(x));
|
646
|
+
|
647
|
+
aOut.writeObject(new DERSequence(v));
|
648
|
+
byte[] encoding = bOut.toByteArray();
|
649
|
+
|
650
|
+
if(algo != null && f != null) {
|
651
|
+
byte[] salt = new byte[8];
|
652
|
+
byte[] encData = null;
|
653
|
+
random.nextBytes(salt);
|
654
|
+
OpenSSLPBEParametersGenerator pGen = new OpenSSLPBEParametersGenerator();
|
655
|
+
pGen.init(PBEParametersGenerator.PKCS5PasswordToBytes(f), salt);
|
656
|
+
SecretKey secretKey = null;
|
657
|
+
if(algo.equalsIgnoreCase("DESEDE")) {
|
658
|
+
// generate key
|
659
|
+
int keyLength = 24;
|
660
|
+
secretKey = new SecretKeySpec(((KeyParameter)pGen.generateDerivedParameters(keyLength * 8)).getKey(), algo);
|
661
|
+
} else {
|
662
|
+
throw new IOException("unknown algorithm in write_DSAPrivateKey");
|
663
|
+
}
|
664
|
+
|
665
|
+
// cipher
|
666
|
+
try {
|
667
|
+
Cipher c = Cipher.getInstance("DESede/CBC/PKCS5Padding", OpenSSLReal.PROVIDER);
|
668
|
+
c.init(Cipher.ENCRYPT_MODE, secretKey, new IvParameterSpec(salt));
|
669
|
+
encData = c.doFinal(encoding);
|
670
|
+
} catch (Exception e) {
|
671
|
+
throw new IOException("exception using cipher: " + e.toString());
|
672
|
+
}
|
673
|
+
|
674
|
+
// write the data
|
675
|
+
out.write(BEF_G + PEM_STRING_DSA + AFT);
|
676
|
+
out.newLine();
|
677
|
+
out.write("Proc-Type: 4,ENCRYPTED");
|
678
|
+
out.newLine();
|
679
|
+
out.write("DEK-Info: DES-EDE3-CBC,");
|
680
|
+
writeHexEncoded(out,salt);
|
681
|
+
out.newLine();
|
682
|
+
out.newLine();
|
683
|
+
writeEncoded(out,encData);
|
684
|
+
out.write(BEF_E + PEM_STRING_DSA + AFT);
|
685
|
+
out.flush();
|
686
|
+
} else {
|
687
|
+
out.write(BEF_G + PEM_STRING_DSA + AFT);
|
688
|
+
out.newLine();
|
689
|
+
writeEncoded(out,encoding);
|
690
|
+
out.write(BEF_E + PEM_STRING_DSA + AFT);
|
691
|
+
out.newLine();
|
692
|
+
out.flush();
|
693
|
+
}
|
694
|
+
}
|
695
|
+
|
696
|
+
public static void writeRSAPrivateKey(Writer _out, RSAPrivateCrtKey obj, String algo, char[] f) throws IOException {
|
697
|
+
BufferedWriter out = makeBuffered(_out);
|
698
|
+
RSAPrivateKeyStructure keyStruct = new RSAPrivateKeyStructure(
|
699
|
+
obj.getModulus(),
|
700
|
+
obj.getPublicExponent(),
|
701
|
+
obj.getPrivateExponent(),
|
702
|
+
obj.getPrimeP(),
|
703
|
+
obj.getPrimeQ(),
|
704
|
+
obj.getPrimeExponentP(),
|
705
|
+
obj.getPrimeExponentQ(),
|
706
|
+
obj.getCrtCoefficient());
|
707
|
+
|
708
|
+
// convert to bytearray
|
709
|
+
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
710
|
+
ASN1OutputStream aOut = new ASN1OutputStream(bOut);
|
711
|
+
|
712
|
+
aOut.writeObject(keyStruct);
|
713
|
+
aOut.close();
|
714
|
+
|
715
|
+
byte[] encoding = bOut.toByteArray();
|
716
|
+
|
717
|
+
if(algo != null && f != null) {
|
718
|
+
byte[] salt = new byte[8];
|
719
|
+
byte[] encData = null;
|
720
|
+
random.nextBytes(salt);
|
721
|
+
OpenSSLPBEParametersGenerator pGen = new OpenSSLPBEParametersGenerator();
|
722
|
+
pGen.init(PBEParametersGenerator.PKCS5PasswordToBytes(f), salt);
|
723
|
+
SecretKey secretKey = null;
|
724
|
+
|
725
|
+
if(algo.startsWith("DES")) {
|
726
|
+
// generate key
|
727
|
+
int keyLength = 24;
|
728
|
+
secretKey = new SecretKeySpec(((KeyParameter)pGen.generateDerivedParameters(keyLength * 8)).getKey(), algo);
|
729
|
+
if (algo.equalsIgnoreCase("DESEDE")) {
|
730
|
+
algo = "DESede/CBC/PKCS5Padding";
|
731
|
+
}
|
732
|
+
} else {
|
733
|
+
throw new IOException("unknown algorithm `" + algo + "' in write_DSAPrivateKey");
|
734
|
+
}
|
735
|
+
|
736
|
+
// cipher
|
737
|
+
try {
|
738
|
+
Cipher c = Cipher.getInstance(algo, OpenSSLReal.PROVIDER);
|
739
|
+
c.init(Cipher.ENCRYPT_MODE, secretKey, new IvParameterSpec(salt));
|
740
|
+
encData = c.doFinal(encoding);
|
741
|
+
} catch (Exception e) {
|
742
|
+
throw new IOException("exception using cipher: " + e.toString());
|
743
|
+
}
|
744
|
+
|
745
|
+
// write the data
|
746
|
+
out.write(BEF_G + PEM_STRING_RSA + AFT);
|
747
|
+
out.newLine();
|
748
|
+
out.write("Proc-Type: 4,ENCRYPTED");
|
749
|
+
out.newLine();
|
750
|
+
out.write("DEK-Info: DES-EDE3-CBC,");
|
751
|
+
writeHexEncoded(out,salt);
|
752
|
+
out.newLine();
|
753
|
+
out.newLine();
|
754
|
+
writeEncoded(out,encData);
|
755
|
+
out.write(BEF_E + PEM_STRING_RSA + AFT);
|
756
|
+
out.flush();
|
757
|
+
} else {
|
758
|
+
out.write(BEF_G + PEM_STRING_RSA + AFT);
|
759
|
+
out.newLine();
|
760
|
+
writeEncoded(out,encoding);
|
761
|
+
out.write(BEF_E + PEM_STRING_RSA + AFT);
|
762
|
+
out.newLine();
|
763
|
+
out.flush();
|
764
|
+
}
|
765
|
+
}
|
766
|
+
|
767
|
+
public static void writeDHParameters(Writer _out, DHParameterSpec params) throws IOException {
|
768
|
+
BufferedWriter out = makeBuffered(_out);
|
769
|
+
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
770
|
+
ASN1OutputStream aOut = new ASN1OutputStream(bOut);
|
771
|
+
|
772
|
+
ASN1EncodableVector v = new ASN1EncodableVector();
|
773
|
+
|
774
|
+
BigInteger value;
|
775
|
+
if ((value = params.getP()) != null) {
|
776
|
+
v.add(new DERInteger(value));
|
777
|
+
}
|
778
|
+
if ((value = params.getG()) != null) {
|
779
|
+
v.add(new DERInteger(value));
|
780
|
+
}
|
781
|
+
|
782
|
+
aOut.writeObject(new DERSequence(v));
|
783
|
+
byte[] encoding = bOut.toByteArray();
|
784
|
+
|
785
|
+
out.write(BEF_G + PEM_STRING_DHPARAMS + AFT);
|
786
|
+
out.newLine();
|
787
|
+
writeEncoded(out,encoding);
|
788
|
+
out.write(BEF_E + PEM_STRING_DHPARAMS + AFT);
|
789
|
+
out.newLine();
|
790
|
+
out.flush();
|
791
|
+
}
|
792
|
+
|
793
|
+
private static byte[] readBytes(BufferedReader in, String endMarker) throws IOException {
|
794
|
+
String line;
|
795
|
+
StringBuffer buf = new StringBuffer();
|
796
|
+
|
797
|
+
while ((line = in.readLine()) != null) {
|
798
|
+
if (line.indexOf(endMarker) != -1) {
|
799
|
+
break;
|
800
|
+
}
|
801
|
+
buf.append(line.trim());
|
802
|
+
}
|
803
|
+
|
804
|
+
if (line == null) {
|
805
|
+
throw new IOException(endMarker + " not found");
|
806
|
+
}
|
807
|
+
|
808
|
+
return Base64.decode(buf.toString());
|
809
|
+
}
|
810
|
+
|
811
|
+
/**
|
812
|
+
* create the secret key needed for this object, fetching the password
|
813
|
+
*/
|
814
|
+
private static SecretKey getKey(char[] k1, String algorithm,int keyLength, byte[] salt) throws IOException {
|
815
|
+
char[] password = k1;
|
816
|
+
|
817
|
+
if (password == null) {
|
818
|
+
throw new IOException("Password is null, but a password is required");
|
819
|
+
}
|
820
|
+
|
821
|
+
OpenSSLPBEParametersGenerator pGen = new OpenSSLPBEParametersGenerator();
|
822
|
+
|
823
|
+
pGen.init(PBEParametersGenerator.PKCS5PasswordToBytes(password), salt);
|
824
|
+
|
825
|
+
return new javax.crypto.spec.SecretKeySpec(((KeyParameter)pGen.generateDerivedParameters(keyLength * 8)).getKey(), algorithm);
|
826
|
+
}
|
827
|
+
|
828
|
+
private static RSAPublicKey readRSAPublicKey(BufferedReader in, String endMarker) throws IOException {
|
829
|
+
ByteArrayInputStream bAIS = new ByteArrayInputStream(readBytes(in,endMarker));
|
830
|
+
ASN1InputStream ais = new ASN1InputStream(bAIS);
|
831
|
+
Object asnObject = ais.readObject();
|
832
|
+
ASN1Sequence sequence = (ASN1Sequence) asnObject;
|
833
|
+
RSAPublicKeyStructure rsaPubStructure = new RSAPublicKeyStructure(sequence);
|
834
|
+
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(
|
835
|
+
rsaPubStructure.getModulus(),
|
836
|
+
rsaPubStructure.getPublicExponent());
|
837
|
+
|
838
|
+
try {
|
839
|
+
KeyFactory keyFact = KeyFactory.getInstance("RSA",OpenSSLReal.PROVIDER);
|
840
|
+
return (RSAPublicKey) keyFact.generatePublic(keySpec);
|
841
|
+
} catch (NoSuchAlgorithmException e) {
|
842
|
+
// ignore
|
843
|
+
} catch (InvalidKeySpecException e) {
|
844
|
+
// ignore
|
845
|
+
}
|
846
|
+
|
847
|
+
return null;
|
848
|
+
}
|
849
|
+
|
850
|
+
private static PublicKey readPublicKey(BufferedReader in, String alg, String endMarker) throws IOException {
|
851
|
+
KeySpec keySpec = new X509EncodedKeySpec(readBytes(in,endMarker));
|
852
|
+
try {
|
853
|
+
KeyFactory keyFact = KeyFactory.getInstance(alg,OpenSSLReal.PROVIDER);
|
854
|
+
PublicKey pubKey = keyFact.generatePublic(keySpec);
|
855
|
+
return pubKey;
|
856
|
+
} catch (NoSuchAlgorithmException e) {
|
857
|
+
// ignore
|
858
|
+
} catch (InvalidKeySpecException e) {
|
859
|
+
// ignore
|
860
|
+
}
|
861
|
+
return null;
|
862
|
+
}
|
863
|
+
|
864
|
+
private static PublicKey readPublicKey(BufferedReader in, String endMarker) throws IOException {
|
865
|
+
KeySpec keySpec = new X509EncodedKeySpec(readBytes(in,endMarker));
|
866
|
+
String[] algs = {"RSA","DSA"};
|
867
|
+
for(int i=0;i<algs.length;i++) {
|
868
|
+
try {
|
869
|
+
KeyFactory keyFact = KeyFactory.getInstance(algs[i],OpenSSLReal.PROVIDER);
|
870
|
+
PublicKey pubKey = keyFact.generatePublic(keySpec);
|
871
|
+
return pubKey;
|
872
|
+
} catch (NoSuchAlgorithmException e) {
|
873
|
+
// ignore
|
874
|
+
} catch (InvalidKeySpecException e) {
|
875
|
+
// ignore
|
876
|
+
}
|
877
|
+
}
|
878
|
+
return null;
|
879
|
+
}
|
880
|
+
|
881
|
+
/**
|
882
|
+
* Read a Key Pair
|
883
|
+
*/
|
884
|
+
private static KeyPair readKeyPair(BufferedReader _in, char[] passwd, String type,String endMarker)
|
885
|
+
throws Exception {
|
886
|
+
boolean isEncrypted = false;
|
887
|
+
String line = null;
|
888
|
+
String dekInfo = null;
|
889
|
+
StringBuffer buf = new StringBuffer();
|
890
|
+
|
891
|
+
while ((line = _in.readLine()) != null) {
|
892
|
+
if (line.startsWith("Proc-Type: 4,ENCRYPTED")) {
|
893
|
+
isEncrypted = true;
|
894
|
+
} else if (line.startsWith("DEK-Info:")) {
|
895
|
+
dekInfo = line.substring(10);
|
896
|
+
} else if (line.indexOf(endMarker) != -1) {
|
897
|
+
break;
|
898
|
+
} else {
|
899
|
+
buf.append(line.trim());
|
900
|
+
}
|
901
|
+
}
|
902
|
+
byte[] keyBytes = null;
|
903
|
+
if (isEncrypted) {
|
904
|
+
StringTokenizer tknz = new StringTokenizer(dekInfo, ",");
|
905
|
+
String encoding = tknz.nextToken();
|
906
|
+
|
907
|
+
if (encoding.equals("DES-EDE3-CBC")) {
|
908
|
+
String alg = "DESede";
|
909
|
+
byte[] iv = Hex.decode(tknz.nextToken());
|
910
|
+
Key sKey = getKey(passwd,alg, 24, iv);
|
911
|
+
Cipher c = Cipher.getInstance("DESede/CBC/PKCS5Padding", OpenSSLReal.PROVIDER);
|
912
|
+
c.init(Cipher.DECRYPT_MODE, sKey, new IvParameterSpec(iv));
|
913
|
+
keyBytes = c.doFinal(Base64.decode(buf.toString()));
|
914
|
+
} else if (encoding.equals("DES-CBC")) {
|
915
|
+
String alg = "DES";
|
916
|
+
byte[] iv = Hex.decode(tknz.nextToken());
|
917
|
+
Key sKey = getKey(passwd,alg, 8, iv);
|
918
|
+
Cipher c = Cipher.getInstance(
|
919
|
+
"DES/CBC/PKCS5Padding", OpenSSLReal.PROVIDER);
|
920
|
+
|
921
|
+
c.init(Cipher.DECRYPT_MODE, sKey, new IvParameterSpec(iv));
|
922
|
+
keyBytes = c.doFinal(Base64.decode(buf.toString()));
|
923
|
+
} else {
|
924
|
+
throw new IOException("unknown encryption with private key");
|
925
|
+
}
|
926
|
+
} else {
|
927
|
+
keyBytes = Base64.decode(buf.toString());
|
928
|
+
}
|
929
|
+
|
930
|
+
KeySpec pubSpec, privSpec;
|
931
|
+
ByteArrayInputStream bIn = new ByteArrayInputStream(keyBytes);
|
932
|
+
ASN1InputStream aIn = new ASN1InputStream(bIn);
|
933
|
+
ASN1Sequence seq = (ASN1Sequence)aIn.readObject();
|
934
|
+
|
935
|
+
if (type.equals("RSA"))
|
936
|
+
{
|
937
|
+
//DERInteger v = (DERInteger)seq.getObjectAt(0);
|
938
|
+
DERInteger mod = (DERInteger)seq.getObjectAt(1);
|
939
|
+
DERInteger pubExp = (DERInteger)seq.getObjectAt(2);
|
940
|
+
DERInteger privExp = (DERInteger)seq.getObjectAt(3);
|
941
|
+
DERInteger p1 = (DERInteger)seq.getObjectAt(4);
|
942
|
+
DERInteger p2 = (DERInteger)seq.getObjectAt(5);
|
943
|
+
DERInteger exp1 = (DERInteger)seq.getObjectAt(6);
|
944
|
+
DERInteger exp2 = (DERInteger)seq.getObjectAt(7);
|
945
|
+
DERInteger crtCoef = (DERInteger)seq.getObjectAt(8);
|
946
|
+
|
947
|
+
pubSpec = new RSAPublicKeySpec(
|
948
|
+
mod.getValue(), pubExp.getValue());
|
949
|
+
privSpec = new RSAPrivateCrtKeySpec(
|
950
|
+
mod.getValue(), pubExp.getValue(), privExp.getValue(),
|
951
|
+
p1.getValue(), p2.getValue(),
|
952
|
+
exp1.getValue(), exp2.getValue(),
|
953
|
+
crtCoef.getValue());
|
954
|
+
}
|
955
|
+
else // "DSA"
|
956
|
+
{
|
957
|
+
//DERInteger v = (DERInteger)seq.getObjectAt(0);
|
958
|
+
DERInteger p = (DERInteger)seq.getObjectAt(1);
|
959
|
+
DERInteger q = (DERInteger)seq.getObjectAt(2);
|
960
|
+
DERInteger g = (DERInteger)seq.getObjectAt(3);
|
961
|
+
DERInteger y = (DERInteger)seq.getObjectAt(4);
|
962
|
+
DERInteger x = (DERInteger)seq.getObjectAt(5);
|
963
|
+
|
964
|
+
privSpec = new DSAPrivateKeySpec(
|
965
|
+
x.getValue(), p.getValue(),
|
966
|
+
q.getValue(), g.getValue());
|
967
|
+
pubSpec = new DSAPublicKeySpec(
|
968
|
+
y.getValue(), p.getValue(),
|
969
|
+
q.getValue(), g.getValue());
|
970
|
+
}
|
971
|
+
|
972
|
+
KeyFactory fact = KeyFactory.getInstance(type, OpenSSLReal.PROVIDER);
|
973
|
+
|
974
|
+
return new KeyPair(
|
975
|
+
fact.generatePublic(pubSpec),
|
976
|
+
fact.generatePrivate(privSpec));
|
977
|
+
}
|
978
|
+
|
979
|
+
/**
|
980
|
+
* Reads in a X509Certificate.
|
981
|
+
*
|
982
|
+
* @return the X509Certificate
|
983
|
+
* @throws IOException if an I/O error occured
|
984
|
+
*/
|
985
|
+
private static X509Certificate readCertificate(BufferedReader in,String endMarker) throws IOException {
|
986
|
+
String line;
|
987
|
+
StringBuffer buf = new StringBuffer();
|
988
|
+
|
989
|
+
while ((line = in.readLine()) != null)
|
990
|
+
{
|
991
|
+
if (line.indexOf(endMarker) != -1)
|
992
|
+
{
|
993
|
+
break;
|
994
|
+
}
|
995
|
+
buf.append(line.trim());
|
996
|
+
}
|
997
|
+
|
998
|
+
if (line == null)
|
999
|
+
{
|
1000
|
+
throw new IOException(endMarker + " not found");
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
ByteArrayInputStream bIn = new ByteArrayInputStream(
|
1004
|
+
Base64.decode(buf.toString()));
|
1005
|
+
|
1006
|
+
try
|
1007
|
+
{
|
1008
|
+
CertificateFactory certFact
|
1009
|
+
= CertificateFactory.getInstance("X.509", OpenSSLReal.PROVIDER);
|
1010
|
+
|
1011
|
+
return (X509Certificate)certFact.generateCertificate(bIn);
|
1012
|
+
}
|
1013
|
+
catch (Exception e)
|
1014
|
+
{
|
1015
|
+
throw new IOException("problem parsing cert: " + e.toString());
|
1016
|
+
}
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
private static X509AuxCertificate readAuxCertificate(BufferedReader in,String endMarker) throws IOException {
|
1020
|
+
String line;
|
1021
|
+
StringBuffer buf = new StringBuffer();
|
1022
|
+
|
1023
|
+
while ((line = in.readLine()) != null) {
|
1024
|
+
if (line.indexOf(endMarker) != -1) {
|
1025
|
+
break;
|
1026
|
+
}
|
1027
|
+
buf.append(line.trim());
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
if (line == null) {
|
1031
|
+
throw new IOException(endMarker + " not found");
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
ASN1InputStream try1 = new ASN1InputStream(Base64.decode(buf.toString()));
|
1035
|
+
ByteArrayInputStream bIn = new ByteArrayInputStream(((DERObject)try1.readObject()).getEncoded());
|
1036
|
+
|
1037
|
+
try {
|
1038
|
+
CertificateFactory certFact = CertificateFactory.getInstance("X.509", OpenSSLReal.PROVIDER);
|
1039
|
+
X509Certificate bCert = (X509Certificate)certFact.generateCertificate(bIn);
|
1040
|
+
DERSequence aux = (DERSequence)try1.readObject();
|
1041
|
+
X509Aux ax = null;
|
1042
|
+
if(aux != null) {
|
1043
|
+
ax = new X509Aux();
|
1044
|
+
int ix = 0;
|
1045
|
+
if(aux.size() > ix && aux.getObjectAt(ix) instanceof DERSequence) {
|
1046
|
+
DERSequence trust = (DERSequence)aux.getObjectAt(ix++);
|
1047
|
+
for(int i=0;i<trust.size();i++) {
|
1048
|
+
ax.trust.add(((DERObjectIdentifier)trust.getObjectAt(i)).getId());
|
1049
|
+
}
|
1050
|
+
}
|
1051
|
+
if(aux.size() > ix && aux.getObjectAt(ix) instanceof DERTaggedObject && ((DERTaggedObject)aux.getObjectAt(ix)).getTagNo() == 0) {
|
1052
|
+
DERSequence reject = (DERSequence)((DERTaggedObject)aux.getObjectAt(ix++)).getObject();
|
1053
|
+
for(int i=0;i<reject.size();i++) {
|
1054
|
+
ax.reject.add(((DERObjectIdentifier)reject.getObjectAt(i)).getId());
|
1055
|
+
}
|
1056
|
+
}
|
1057
|
+
if(aux.size()>ix && aux.getObjectAt(ix) instanceof DERUTF8String) {
|
1058
|
+
ax.alias = ((DERUTF8String)aux.getObjectAt(ix++)).getString();
|
1059
|
+
}
|
1060
|
+
if(aux.size()>ix && aux.getObjectAt(ix) instanceof DEROctetString) {
|
1061
|
+
ax.keyid = ((DEROctetString)aux.getObjectAt(ix++)).getOctets();
|
1062
|
+
}
|
1063
|
+
if(aux.size() > ix && aux.getObjectAt(ix) instanceof DERTaggedObject && ((DERTaggedObject)aux.getObjectAt(ix)).getTagNo() == 1) {
|
1064
|
+
DERSequence other = (DERSequence)((DERTaggedObject)aux.getObjectAt(ix++)).getObject();
|
1065
|
+
for(int i=0;i<other.size();i++) {
|
1066
|
+
ax.other.add((DERObject)(other.getObjectAt(i)));
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
}
|
1070
|
+
return new X509AuxCertificate(bCert,ax);
|
1071
|
+
} catch (Exception e) {
|
1072
|
+
throw new IOException("problem parsing cert: " + e.toString());
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
/**
|
1077
|
+
* Reads in a X509CRL.
|
1078
|
+
*
|
1079
|
+
* @return the X509CRL
|
1080
|
+
* @throws IOException if an I/O error occured
|
1081
|
+
*/
|
1082
|
+
private static X509CRL readCRL(BufferedReader in, String endMarker) throws IOException {
|
1083
|
+
String line;
|
1084
|
+
StringBuffer buf = new StringBuffer();
|
1085
|
+
|
1086
|
+
while ((line = in.readLine()) != null)
|
1087
|
+
{
|
1088
|
+
if (line.indexOf(endMarker) != -1)
|
1089
|
+
{
|
1090
|
+
break;
|
1091
|
+
}
|
1092
|
+
buf.append(line.trim());
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
if (line == null)
|
1096
|
+
{
|
1097
|
+
throw new IOException(endMarker + " not found");
|
1098
|
+
}
|
1099
|
+
|
1100
|
+
ByteArrayInputStream bIn = new ByteArrayInputStream(
|
1101
|
+
Base64.decode(buf.toString()));
|
1102
|
+
|
1103
|
+
try
|
1104
|
+
{
|
1105
|
+
CertificateFactory certFact
|
1106
|
+
= CertificateFactory.getInstance("X.509", OpenSSLReal.PROVIDER);
|
1107
|
+
|
1108
|
+
return (X509CRL)certFact.generateCRL(bIn);
|
1109
|
+
}
|
1110
|
+
catch (Exception e)
|
1111
|
+
{
|
1112
|
+
throw new IOException("problem parsing cert: " + e.toString());
|
1113
|
+
}
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
/**
|
1117
|
+
* Reads in a PKCS10 certification request.
|
1118
|
+
*
|
1119
|
+
* @return the certificate request.
|
1120
|
+
* @throws IOException if an I/O error occured
|
1121
|
+
*/
|
1122
|
+
private static PKCS10CertificationRequestExt readCertificateRequest(BufferedReader in, String endMarker) throws IOException {
|
1123
|
+
String line;
|
1124
|
+
StringBuffer buf = new StringBuffer();
|
1125
|
+
|
1126
|
+
while ((line = in.readLine()) != null)
|
1127
|
+
{
|
1128
|
+
if (line.indexOf(endMarker) != -1)
|
1129
|
+
{
|
1130
|
+
break;
|
1131
|
+
}
|
1132
|
+
buf.append(line.trim());
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
if (line == null)
|
1136
|
+
{
|
1137
|
+
throw new IOException(endMarker + " not found");
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
try
|
1141
|
+
{
|
1142
|
+
return new PKCS10CertificationRequestExt(Base64.decode(buf.toString()));
|
1143
|
+
}
|
1144
|
+
catch (Exception e)
|
1145
|
+
{
|
1146
|
+
throw new IOException("problem parsing cert: " + e.toString());
|
1147
|
+
}
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
private static void writeHexEncoded(BufferedWriter out, byte[] bytes) throws IOException {
|
1151
|
+
bytes = Hex.encode(bytes);
|
1152
|
+
for (int i = 0; i != bytes.length; i++) {
|
1153
|
+
out.write((char)bytes[i]);
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
|
1157
|
+
private static void writeEncoded(BufferedWriter out, byte[] bytes) throws IOException {
|
1158
|
+
char[] buf = new char[64];
|
1159
|
+
bytes = Base64.encode(bytes);
|
1160
|
+
for (int i = 0; i < bytes.length; i += buf.length) {
|
1161
|
+
int index = 0;
|
1162
|
+
|
1163
|
+
while (index != buf.length) {
|
1164
|
+
if ((i + index) >= bytes.length) {
|
1165
|
+
break;
|
1166
|
+
}
|
1167
|
+
buf[index] = (char)bytes[i + index];
|
1168
|
+
index++;
|
1169
|
+
}
|
1170
|
+
out.write(buf, 0, index);
|
1171
|
+
out.newLine();
|
1172
|
+
}
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
/**
|
1176
|
+
* Reads in a PKCS7 object. This returns a ContentInfo object suitable for use with the CMS
|
1177
|
+
* API.
|
1178
|
+
*
|
1179
|
+
* @return the X509Certificate
|
1180
|
+
* @throws IOException if an I/O error occured
|
1181
|
+
*/
|
1182
|
+
private static CMSSignedData readPKCS7(BufferedReader in, char[] p, String endMarker) throws IOException {
|
1183
|
+
String line;
|
1184
|
+
StringBuffer buf = new StringBuffer();
|
1185
|
+
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
|
1186
|
+
|
1187
|
+
while ((line = in.readLine()) != null) {
|
1188
|
+
if (line.indexOf(endMarker) != -1) {
|
1189
|
+
break;
|
1190
|
+
}
|
1191
|
+
line = line.trim();
|
1192
|
+
buf.append(line.trim());
|
1193
|
+
Base64.decode(buf.substring(0, (buf.length() / 4) * 4), bOut);
|
1194
|
+
buf.delete(0, (buf.length() / 4) * 4);
|
1195
|
+
}
|
1196
|
+
if (buf.length() != 0) {
|
1197
|
+
throw new RuntimeException("base64 data appears to be truncated");
|
1198
|
+
}
|
1199
|
+
if (line == null) {
|
1200
|
+
throw new IOException(endMarker + " not found");
|
1201
|
+
}
|
1202
|
+
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
|
1203
|
+
try {
|
1204
|
+
ASN1InputStream aIn = new ASN1InputStream(bIn);
|
1205
|
+
return new CMSSignedData(ContentInfo.getInstance(aIn.readObject()));
|
1206
|
+
} catch (Exception e) {
|
1207
|
+
throw new IOException("problem parsing PKCS7 object: " + e.toString());
|
1208
|
+
}
|
1209
|
+
}
|
1210
|
+
}// PEM
|