redcar 0.3.2dev → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (485) hide show
  1. data/CHANGES +49 -2
  2. data/README.md +2 -7
  3. data/ROADMAP.md +8 -9
  4. data/Rakefile +29 -44
  5. data/bin/redcar +11 -2
  6. data/lib/openssl/History.txt +75 -0
  7. data/lib/openssl/License.txt +30 -0
  8. data/lib/openssl/Manifest.txt +99 -0
  9. data/lib/openssl/README.txt +24 -0
  10. data/lib/openssl/Rakefile +71 -0
  11. data/lib/openssl/build.properties.SAMPLE +7 -0
  12. data/lib/openssl/build.xml +57 -0
  13. data/lib/openssl/lib/jopenssl/version.rb +5 -0
  14. data/lib/openssl/lib/openssl.rb +24 -0
  15. data/lib/openssl/lib/openssl/bn.rb +33 -0
  16. data/lib/openssl/lib/openssl/buffering.rb +239 -0
  17. data/lib/openssl/lib/openssl/cipher.rb +56 -0
  18. data/lib/openssl/lib/openssl/digest.rb +46 -0
  19. data/lib/openssl/lib/openssl/dummy.rb +34 -0
  20. data/lib/openssl/lib/openssl/dummyssl.rb +13 -0
  21. data/lib/openssl/lib/openssl/ssl.rb +135 -0
  22. data/lib/openssl/lib/openssl/x509.rb +154 -0
  23. data/lib/openssl/mocha/COPYING +3 -0
  24. data/lib/openssl/mocha/MIT-LICENSE +7 -0
  25. data/lib/openssl/mocha/README +35 -0
  26. data/lib/openssl/mocha/RELEASE +171 -0
  27. data/lib/openssl/mocha/Rakefile +147 -0
  28. data/lib/openssl/mocha/TODO +48 -0
  29. data/lib/openssl/mocha/examples/misc.rb +36 -0
  30. data/lib/openssl/mocha/examples/mocha.rb +26 -0
  31. data/lib/openssl/mocha/examples/stubba.rb +65 -0
  32. data/lib/openssl/mocha/init.rb +3 -0
  33. data/lib/openssl/mocha/lib/mocha.rb +19 -0
  34. data/lib/openssl/mocha/lib/mocha/any_instance_method.rb +35 -0
  35. data/lib/openssl/mocha/lib/mocha/auto_verify.rb +111 -0
  36. data/lib/openssl/mocha/lib/mocha/central.rb +35 -0
  37. data/lib/openssl/mocha/lib/mocha/class_method.rb +62 -0
  38. data/lib/openssl/mocha/lib/mocha/deprecation.rb +22 -0
  39. data/lib/openssl/mocha/lib/mocha/exception_raiser.rb +17 -0
  40. data/lib/openssl/mocha/lib/mocha/expectation.rb +382 -0
  41. data/lib/openssl/mocha/lib/mocha/expectation_error.rb +6 -0
  42. data/lib/openssl/mocha/lib/mocha/expectation_list.rb +45 -0
  43. data/lib/openssl/mocha/lib/mocha/infinite_range.rb +25 -0
  44. data/lib/openssl/mocha/lib/mocha/inspect.rb +39 -0
  45. data/lib/openssl/mocha/lib/mocha/instance_method.rb +8 -0
  46. data/lib/openssl/mocha/lib/mocha/is_a.rb +9 -0
  47. data/lib/openssl/mocha/lib/mocha/metaclass.rb +7 -0
  48. data/lib/openssl/mocha/lib/mocha/missing_expectation.rb +27 -0
  49. data/lib/openssl/mocha/lib/mocha/mock.rb +200 -0
  50. data/lib/openssl/mocha/lib/mocha/multiple_yields.rb +20 -0
  51. data/lib/openssl/mocha/lib/mocha/no_yields.rb +11 -0
  52. data/lib/openssl/mocha/lib/mocha/object.rb +110 -0
  53. data/lib/openssl/mocha/lib/mocha/parameter_matchers.rb +9 -0
  54. data/lib/openssl/mocha/lib/mocha/parameter_matchers/all_of.rb +39 -0
  55. data/lib/openssl/mocha/lib/mocha/parameter_matchers/any_of.rb +44 -0
  56. data/lib/openssl/mocha/lib/mocha/parameter_matchers/anything.rb +30 -0
  57. data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_entry.rb +39 -0
  58. data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_key.rb +39 -0
  59. data/lib/openssl/mocha/lib/mocha/parameter_matchers/has_value.rb +39 -0
  60. data/lib/openssl/mocha/lib/mocha/parameter_matchers/includes.rb +37 -0
  61. data/lib/openssl/mocha/lib/mocha/parameter_matchers/instance_of.rb +39 -0
  62. data/lib/openssl/mocha/lib/mocha/parameter_matchers/kind_of.rb +39 -0
  63. data/lib/openssl/mocha/lib/mocha/pretty_parameters.rb +28 -0
  64. data/lib/openssl/mocha/lib/mocha/return_values.rb +31 -0
  65. data/lib/openssl/mocha/lib/mocha/setup_and_teardown.rb +23 -0
  66. data/lib/openssl/mocha/lib/mocha/single_return_value.rb +24 -0
  67. data/lib/openssl/mocha/lib/mocha/single_yield.rb +18 -0
  68. data/lib/openssl/mocha/lib/mocha/standalone.rb +32 -0
  69. data/lib/openssl/mocha/lib/mocha/stub.rb +18 -0
  70. data/lib/openssl/mocha/lib/mocha/test_case_adapter.rb +49 -0
  71. data/lib/openssl/mocha/lib/mocha/yield_parameters.rb +31 -0
  72. data/lib/openssl/mocha/lib/mocha_standalone.rb +2 -0
  73. data/lib/openssl/mocha/lib/stubba.rb +2 -0
  74. data/lib/openssl/mocha/templates/html_with_google_analytics.rb +742 -0
  75. data/lib/openssl/mocha/test/acceptance/expected_invocation_count_acceptance_test.rb +187 -0
  76. data/lib/openssl/mocha/test/acceptance/mocha_acceptance_test.rb +98 -0
  77. data/lib/openssl/mocha/test/acceptance/mocked_methods_dispatch_acceptance_test.rb +71 -0
  78. data/lib/openssl/mocha/test/acceptance/parameter_matcher_acceptance_test.rb +63 -0
  79. data/lib/openssl/mocha/test/acceptance/standalone_acceptance_test.rb +131 -0
  80. data/lib/openssl/mocha/test/acceptance/stubba_acceptance_test.rb +102 -0
  81. data/lib/openssl/mocha/test/active_record_test_case.rb +36 -0
  82. data/lib/openssl/mocha/test/deprecation_disabler.rb +15 -0
  83. data/lib/openssl/mocha/test/execution_point.rb +34 -0
  84. data/lib/openssl/mocha/test/integration/mocha_test_result_integration_test.rb +105 -0
  85. data/lib/openssl/mocha/test/integration/stubba_integration_test.rb +89 -0
  86. data/lib/openssl/mocha/test/integration/stubba_test_result_integration_test.rb +85 -0
  87. data/lib/openssl/mocha/test/method_definer.rb +18 -0
  88. data/lib/openssl/mocha/test/test_helper.rb +12 -0
  89. data/lib/openssl/mocha/test/test_runner.rb +31 -0
  90. data/lib/openssl/mocha/test/unit/any_instance_method_test.rb +124 -0
  91. data/lib/openssl/mocha/test/unit/array_inspect_test.rb +16 -0
  92. data/lib/openssl/mocha/test/unit/auto_verify_test.rb +122 -0
  93. data/lib/openssl/mocha/test/unit/central_test.rb +124 -0
  94. data/lib/openssl/mocha/test/unit/class_method_test.rb +196 -0
  95. data/lib/openssl/mocha/test/unit/date_time_inspect_test.rb +21 -0
  96. data/lib/openssl/mocha/test/unit/expectation_list_test.rb +69 -0
  97. data/lib/openssl/mocha/test/unit/expectation_raiser_test.rb +28 -0
  98. data/lib/openssl/mocha/test/unit/expectation_test.rb +399 -0
  99. data/lib/openssl/mocha/test/unit/hash_inspect_test.rb +16 -0
  100. data/lib/openssl/mocha/test/unit/infinite_range_test.rb +53 -0
  101. data/lib/openssl/mocha/test/unit/metaclass_test.rb +22 -0
  102. data/lib/openssl/mocha/test/unit/missing_expectation_test.rb +45 -0
  103. data/lib/openssl/mocha/test/unit/mock_test.rb +316 -0
  104. data/lib/openssl/mocha/test/unit/multiple_yields_test.rb +18 -0
  105. data/lib/openssl/mocha/test/unit/no_yield_test.rb +18 -0
  106. data/lib/openssl/mocha/test/unit/object_inspect_test.rb +35 -0
  107. data/lib/openssl/mocha/test/unit/object_test.rb +165 -0
  108. data/lib/openssl/mocha/test/unit/parameter_matchers/all_of_test.rb +26 -0
  109. data/lib/openssl/mocha/test/unit/parameter_matchers/any_of_test.rb +26 -0
  110. data/lib/openssl/mocha/test/unit/parameter_matchers/anything_test.rb +21 -0
  111. data/lib/openssl/mocha/test/unit/parameter_matchers/has_entry_test.rb +25 -0
  112. data/lib/openssl/mocha/test/unit/parameter_matchers/has_key_test.rb +25 -0
  113. data/lib/openssl/mocha/test/unit/parameter_matchers/has_value_test.rb +25 -0
  114. data/lib/openssl/mocha/test/unit/parameter_matchers/includes_test.rb +25 -0
  115. data/lib/openssl/mocha/test/unit/parameter_matchers/instance_of_test.rb +25 -0
  116. data/lib/openssl/mocha/test/unit/parameter_matchers/kind_of_test.rb +25 -0
  117. data/lib/openssl/mocha/test/unit/parameter_matchers/stub_matcher.rb +22 -0
  118. data/lib/openssl/mocha/test/unit/pretty_parameters_test.rb +32 -0
  119. data/lib/openssl/mocha/test/unit/return_values_test.rb +63 -0
  120. data/lib/openssl/mocha/test/unit/setup_and_teardown_test.rb +76 -0
  121. data/lib/openssl/mocha/test/unit/single_return_value_test.rb +33 -0
  122. data/lib/openssl/mocha/test/unit/single_yield_test.rb +18 -0
  123. data/lib/openssl/mocha/test/unit/string_inspect_test.rb +11 -0
  124. data/lib/openssl/mocha/test/unit/stub_test.rb +24 -0
  125. data/lib/openssl/mocha/test/unit/yield_parameters_test.rb +93 -0
  126. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/FOLDERS +53 -0
  127. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/LICENSE +340 -0
  128. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/README +117 -0
  129. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/bin/coderay +77 -0
  130. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/bin/coderay_stylesheet +4 -0
  131. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay.rb +319 -0
  132. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/duo.rb +29 -0
  133. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoder.rb +173 -0
  134. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/_map.rb +8 -0
  135. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/count.rb +21 -0
  136. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/debug.rb +46 -0
  137. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/div.rb +20 -0
  138. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html.rb +260 -0
  139. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/classes.rb +77 -0
  140. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/css.rb +65 -0
  141. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/numerization.rb +122 -0
  142. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/html/output.rb +195 -0
  143. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/null.rb +26 -0
  144. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/page.rb +21 -0
  145. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/span.rb +20 -0
  146. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/statistic.rb +81 -0
  147. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/text.rb +33 -0
  148. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/tokens.rb +44 -0
  149. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/xml.rb +71 -0
  150. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/encoders/yaml.rb +22 -0
  151. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/file_type.rb +182 -0
  152. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/gzip_simple.rb +122 -0
  153. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/plugin.rb +326 -0
  154. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/helpers/word_list.rb +119 -0
  155. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanner.rb +238 -0
  156. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/_map.rb +15 -0
  157. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/c.rb +163 -0
  158. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/debug.rb +60 -0
  159. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/delphi.rb +149 -0
  160. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/html.rb +177 -0
  161. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/nitro_xhtml.rb +133 -0
  162. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/plaintext.rb +16 -0
  163. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/rhtml.rb +73 -0
  164. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/ruby.rb +367 -0
  165. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/ruby/patterns.rb +230 -0
  166. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/scanners/xml.rb +18 -0
  167. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/style.rb +20 -0
  168. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/_map.rb +7 -0
  169. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/cycnus.rb +125 -0
  170. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/styles/murphy.rb +119 -0
  171. data/lib/openssl/mocha/vendor/coderay-0.7.4.215/lib/coderay/tokens.rb +368 -0
  172. data/lib/openssl/mocha/vendor/meta_project-0.4.15/CHANGES +295 -0
  173. data/lib/openssl/mocha/vendor/meta_project-0.4.15/MIT-LICENSE +21 -0
  174. data/lib/openssl/mocha/vendor/meta_project-0.4.15/README +129 -0
  175. data/lib/openssl/mocha/vendor/meta_project-0.4.15/Rakefile +152 -0
  176. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project.rb +19 -0
  177. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/open_uri.rb +22 -0
  178. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/pathname.rb +36 -0
  179. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/core_ext/string.rb +5 -0
  180. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/http/multipart.rb +32 -0
  181. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/patois.rb +1 -0
  182. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/patois/parser.rb +99 -0
  183. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project.rb +4 -0
  184. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/base.rb +9 -0
  185. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/codehaus.rb +1 -0
  186. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/codehaus/codehaus_project_svn.rb +31 -0
  187. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/trac.rb +1 -0
  188. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/trac/trac_project.rb +54 -0
  189. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge.rb +5 -0
  190. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/ruby_forge.rb +47 -0
  191. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/session.rb +177 -0
  192. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/source_forge.rb +50 -0
  193. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/xfile.rb +45 -0
  194. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project/xforge/xforge_base.rb +85 -0
  195. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/project_analyzer.rb +36 -0
  196. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/release/freshmeat.rb +267 -0
  197. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/release/raa.rb +572 -0
  198. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web.rb +2 -0
  199. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web/browser.rb +112 -0
  200. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/scm_web/pathname.rb +89 -0
  201. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker.rb +6 -0
  202. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/base.rb +24 -0
  203. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/digit_issues.rb +34 -0
  204. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/issue.rb +57 -0
  205. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira.rb +2 -0
  206. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira/jira_issues.rb +35 -0
  207. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/jira/jira_tracker.rb +149 -0
  208. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/trac.rb +1 -0
  209. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/trac/trac_tracker.rb +33 -0
  210. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge.rb +3 -0
  211. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/ruby_forge_tracker.rb +17 -0
  212. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/source_forge_tracker.rb +17 -0
  213. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/tracker/xforge/xforge_tracker.rb +191 -0
  214. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/meta_project/version_parser.rb +52 -0
  215. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge.rb +3 -0
  216. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/base.rb +64 -0
  217. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/news_publisher.rb +97 -0
  218. data/lib/openssl/mocha/vendor/meta_project-0.4.15/lib/rake/contrib/xforge/release.rb +134 -0
  219. data/lib/openssl/nbproject/genfiles.properties +5 -0
  220. data/lib/openssl/nbproject/jdk.xml +157 -0
  221. data/lib/openssl/nbproject/nbjdk.properties +1 -0
  222. data/lib/openssl/nbproject/nbjdk.xml +16 -0
  223. data/lib/openssl/nbproject/project.xml +117 -0
  224. data/lib/openssl/src/java/JopensslService.java +41 -0
  225. data/lib/openssl/src/java/org/jruby/ext/openssl/ASN1.java +930 -0
  226. data/lib/openssl/src/java/org/jruby/ext/openssl/Attribute.java +132 -0
  227. data/lib/openssl/src/java/org/jruby/ext/openssl/BN.java +769 -0
  228. data/lib/openssl/src/java/org/jruby/ext/openssl/BouncyCastlePEMHandler.java +69 -0
  229. data/lib/openssl/src/java/org/jruby/ext/openssl/Callable.java +10 -0
  230. data/lib/openssl/src/java/org/jruby/ext/openssl/Cipher.java +661 -0
  231. data/lib/openssl/src/java/org/jruby/ext/openssl/CipherStrings.java +1827 -0
  232. data/lib/openssl/src/java/org/jruby/ext/openssl/Config.java +49 -0
  233. data/lib/openssl/src/java/org/jruby/ext/openssl/DefaultPEMHandler.java +44 -0
  234. data/lib/openssl/src/java/org/jruby/ext/openssl/Digest.java +207 -0
  235. data/lib/openssl/src/java/org/jruby/ext/openssl/HMAC.java +183 -0
  236. data/lib/openssl/src/java/org/jruby/ext/openssl/NetscapeSPKI.java +212 -0
  237. data/lib/openssl/src/java/org/jruby/ext/openssl/OpenSSLImpl.java +341 -0
  238. data/lib/openssl/src/java/org/jruby/ext/openssl/OpenSSLReal.java +113 -0
  239. data/lib/openssl/src/java/org/jruby/ext/openssl/PEMHandler.java +40 -0
  240. data/lib/openssl/src/java/org/jruby/ext/openssl/PKCS10CertificationRequestExt.java +159 -0
  241. data/lib/openssl/src/java/org/jruby/ext/openssl/PKCS7.java +642 -0
  242. data/lib/openssl/src/java/org/jruby/ext/openssl/PKey.java +154 -0
  243. data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyDH.java +401 -0
  244. data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyDSA.java +419 -0
  245. data/lib/openssl/src/java/org/jruby/ext/openssl/PKeyRSA.java +762 -0
  246. data/lib/openssl/src/java/org/jruby/ext/openssl/Random.java +103 -0
  247. data/lib/openssl/src/java/org/jruby/ext/openssl/Request.java +336 -0
  248. data/lib/openssl/src/java/org/jruby/ext/openssl/SSL.java +71 -0
  249. data/lib/openssl/src/java/org/jruby/ext/openssl/SSLContext.java +358 -0
  250. data/lib/openssl/src/java/org/jruby/ext/openssl/SSLSocket.java +561 -0
  251. data/lib/openssl/src/java/org/jruby/ext/openssl/SimpleSecretKey.java +53 -0
  252. data/lib/openssl/src/java/org/jruby/ext/openssl/Utils.java +60 -0
  253. data/lib/openssl/src/java/org/jruby/ext/openssl/X509.java +108 -0
  254. data/lib/openssl/src/java/org/jruby/ext/openssl/X509CRL.java +446 -0
  255. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Cert.java +520 -0
  256. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Extensions.java +751 -0
  257. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Name.java +405 -0
  258. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Revoked.java +111 -0
  259. data/lib/openssl/src/java/org/jruby/ext/openssl/X509Store.java +282 -0
  260. data/lib/openssl/src/java/org/jruby/ext/openssl/X509StoreCtx.java +206 -0
  261. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/ASN1Registry.java +5135 -0
  262. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Attribute.java +79 -0
  263. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/BIO.java +345 -0
  264. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/BIOFilter.java +38 -0
  265. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Base64BIOFilter.java +84 -0
  266. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/CipherBIOFilter.java +157 -0
  267. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Digest.java +126 -0
  268. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/EVP.java +136 -0
  269. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/EncContent.java +178 -0
  270. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Encrypt.java +77 -0
  271. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Envelope.java +169 -0
  272. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/IssuerAndSerial.java +35 -0
  273. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MemBIO.java +117 -0
  274. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MessageDigestBIOFilter.java +76 -0
  275. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Mime.java +245 -0
  276. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MimeHeader.java +103 -0
  277. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/MimeParam.java +69 -0
  278. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/NotVerifiedPKCS7Exception.java +38 -0
  279. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/NullSinkBIO.java +52 -0
  280. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7.java +1276 -0
  281. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7Data.java +168 -0
  282. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataData.java +88 -0
  283. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataDigest.java +64 -0
  284. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataEncrypted.java +61 -0
  285. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataEnveloped.java +85 -0
  286. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataSigned.java +127 -0
  287. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7DataSignedAndEnveloped.java +91 -0
  288. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/PKCS7Exception.java +68 -0
  289. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/RecipInfo.java +244 -0
  290. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SMIME.java +281 -0
  291. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SignEnvelope.java +202 -0
  292. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/Signed.java +345 -0
  293. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/SignerInfoWithPkey.java +365 -0
  294. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/TypeDiscriminating.java +34 -0
  295. data/lib/openssl/src/java/org/jruby/ext/openssl/impl/utils/Base64.java +1809 -0
  296. data/lib/openssl/src/java/org/jruby/ext/openssl/util/Base64Coder.java +103 -0
  297. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CRL.java +59 -0
  298. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Certificate.java +57 -0
  299. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CertificateFile.java +46 -0
  300. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/CertificateHashDir.java +46 -0
  301. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function0.java +43 -0
  302. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function1.java +43 -0
  303. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function2.java +43 -0
  304. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function3.java +43 -0
  305. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function4.java +43 -0
  306. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Function5.java +43 -0
  307. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Lookup.java +560 -0
  308. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/LookupMethod.java +84 -0
  309. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Name.java +85 -0
  310. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PEMInputOutput.java +1210 -0
  311. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PKey.java +41 -0
  312. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/PolicyTree.java +36 -0
  313. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Purpose.java +475 -0
  314. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Store.java +377 -0
  315. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/StoreContext.java +1356 -0
  316. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/Trust.java +279 -0
  317. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/VerifyParameter.java +324 -0
  318. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Aux.java +43 -0
  319. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509AuxCertificate.java +170 -0
  320. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Error.java +70 -0
  321. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Object.java +88 -0
  322. data/lib/openssl/src/java/org/jruby/ext/openssl/x509store/X509Utils.java +541 -0
  323. data/lib/openssl/test/cert_with_ec_pk.cer +27 -0
  324. data/lib/openssl/test/fixture/ca_path/72fa7371.0 +19 -0
  325. data/lib/openssl/test/fixture/ca_path/verisign.pem +19 -0
  326. data/lib/openssl/test/fixture/cacert.pem +23 -0
  327. data/lib/openssl/test/fixture/cert_localhost.pem +19 -0
  328. data/lib/openssl/test/fixture/common.pem +48 -0
  329. data/lib/openssl/test/fixture/localhost_keypair.pem +18 -0
  330. data/lib/openssl/test/fixture/max.pem +29 -0
  331. data/lib/openssl/test/fixture/purpose/b70a5bc1.0 +24 -0
  332. data/lib/openssl/test/fixture/purpose/ca/PASSWD_OF_CA_KEY_IS_1234 +0 -0
  333. data/lib/openssl/test/fixture/purpose/ca/ca_config.rb +37 -0
  334. data/lib/openssl/test/fixture/purpose/ca/cacert.pem +24 -0
  335. data/lib/openssl/test/fixture/purpose/ca/newcerts/2_cert.pem +19 -0
  336. data/lib/openssl/test/fixture/purpose/ca/newcerts/3_cert.pem +19 -0
  337. data/lib/openssl/test/fixture/purpose/ca/private/cakeypair.pem +30 -0
  338. data/lib/openssl/test/fixture/purpose/ca/serial +1 -0
  339. data/lib/openssl/test/fixture/purpose/cacert.pem +24 -0
  340. data/lib/openssl/test/fixture/purpose/scripts/gen_cert.rb +127 -0
  341. data/lib/openssl/test/fixture/purpose/scripts/gen_csr.rb +50 -0
  342. data/lib/openssl/test/fixture/purpose/scripts/init_ca.rb +66 -0
  343. data/lib/openssl/test/fixture/purpose/sslclient.pem +19 -0
  344. data/lib/openssl/test/fixture/purpose/sslclient/csr.pem +10 -0
  345. data/lib/openssl/test/fixture/purpose/sslclient/keypair.pem +15 -0
  346. data/lib/openssl/test/fixture/purpose/sslclient/sslclient.pem +19 -0
  347. data/lib/openssl/test/fixture/purpose/sslserver.pem +19 -0
  348. data/lib/openssl/test/fixture/purpose/sslserver/csr.pem +10 -0
  349. data/lib/openssl/test/fixture/purpose/sslserver/keypair.pem +15 -0
  350. data/lib/openssl/test/fixture/purpose/sslserver/sslserver.pem +19 -0
  351. data/lib/openssl/test/fixture/verisign.pem +19 -0
  352. data/lib/openssl/test/fixture/verisign_c3.pem +14 -0
  353. data/lib/openssl/test/openssl/ssl_server.rb +99 -0
  354. data/lib/openssl/test/openssl/test_asn1.rb +199 -0
  355. data/lib/openssl/test/openssl/test_cipher.rb +196 -0
  356. data/lib/openssl/test/openssl/test_digest.rb +88 -0
  357. data/lib/openssl/test/openssl/test_hmac.rb +44 -0
  358. data/lib/openssl/test/openssl/test_ns_spki.rb +69 -0
  359. data/lib/openssl/test/openssl/test_pair.rb +149 -0
  360. data/lib/openssl/test/openssl/test_pkcs7.rb +160 -0
  361. data/lib/openssl/test/openssl/test_pkey_rsa.rb +49 -0
  362. data/lib/openssl/test/openssl/test_ssl.rb +413 -0
  363. data/lib/openssl/test/openssl/test_x509cert.rb +236 -0
  364. data/lib/openssl/test/openssl/test_x509crl.rb +234 -0
  365. data/lib/openssl/test/openssl/test_x509ext.rb +95 -0
  366. data/lib/openssl/test/openssl/test_x509name.rb +281 -0
  367. data/lib/openssl/test/openssl/test_x509req.rb +178 -0
  368. data/lib/openssl/test/openssl/test_x509store.rb +245 -0
  369. data/lib/openssl/test/openssl/utils.rb +135 -0
  370. data/lib/openssl/test/pkcs7_mime_enveloped.message +19 -0
  371. data/lib/openssl/test/pkcs7_mime_signed.message +30 -0
  372. data/lib/openssl/test/pkcs7_multipart_signed.message +45 -0
  373. data/lib/openssl/test/ref/compile.rb +8 -0
  374. data/lib/openssl/test/ref/pkcs1 +0 -0
  375. data/lib/openssl/test/ref/pkcs1.c +21 -0
  376. data/lib/openssl/test/test_cipher.rb +95 -0
  377. data/lib/openssl/test/test_integration.rb +139 -0
  378. data/lib/openssl/test/test_java.rb +98 -0
  379. data/lib/openssl/test/test_java_attribute.rb +25 -0
  380. data/lib/openssl/test/test_java_bio.rb +42 -0
  381. data/lib/openssl/test/test_java_mime.rb +173 -0
  382. data/lib/openssl/test/test_java_pkcs7.rb +769 -0
  383. data/lib/openssl/test/test_java_smime.rb +177 -0
  384. data/lib/openssl/test/test_openssl.rb +34 -0
  385. data/lib/openssl/test/test_openssl_x509.rb +34 -0
  386. data/lib/openssl/test/test_parse_certificate.rb +20 -0
  387. data/lib/openssl/test/test_pkey.rb +46 -0
  388. data/lib/openssl/test/test_x509store.rb +155 -0
  389. data/lib/openssl/test/ut_eof.rb +128 -0
  390. data/lib/redcar.rb +134 -8
  391. data/lib/redcar/installer.rb +46 -11
  392. data/lib/redcar/runner.rb +2 -1
  393. data/lib/redcar/usage.rb +12 -5
  394. data/lib/redcar_quick_start.rb +37 -0
  395. data/plugins/application/features/support/env.rb +9 -1
  396. data/plugins/application/icons/redcar_icon_beta.png +0 -0
  397. data/plugins/application/lib/application.rb +113 -43
  398. data/plugins/application/lib/application/clipboard.rb +28 -4
  399. data/plugins/application/lib/application/command.rb +4 -12
  400. data/plugins/application/lib/application/command/executor.rb +2 -2
  401. data/plugins/application/lib/application/keymap.rb +39 -0
  402. data/plugins/application/lib/application/keymap/builder.rb +19 -0
  403. data/plugins/application/lib/application/speedbar.rb +33 -24
  404. data/plugins/application/lib/application/tab.rb +15 -0
  405. data/plugins/application/lib/application/window.rb +28 -5
  406. data/plugins/application/spec/application/clipboard_spec.rb +20 -1
  407. data/plugins/application/spec/application/command/executor_spec.rb +7 -2
  408. data/plugins/application/spec/application/command_spec.rb +0 -5
  409. data/plugins/application/spec/application/keymap/builder_spec.rb +17 -0
  410. data/plugins/application/spec/application/menu_spec.rb +30 -0
  411. data/plugins/application/spec/application/speedbar_spec.rb +30 -6
  412. data/plugins/application/spec/application/window_spec.rb +2 -2
  413. data/plugins/application/spec/spec_helper.rb +1 -1
  414. data/plugins/application_swt/lib/application_swt.rb +3 -0
  415. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +10 -1
  416. data/plugins/application_swt/lib/application_swt/html_tab.rb +1 -0
  417. data/plugins/application_swt/lib/application_swt/menu.rb +4 -3
  418. data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +12 -4
  419. data/plugins/application_swt/lib/application_swt/speedbar.rb +105 -19
  420. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +2 -0
  421. data/plugins/application_swt/lib/application_swt/window.rb +55 -23
  422. data/plugins/application_swt/spec/spec_helper.rb +0 -1
  423. data/plugins/auto_completer/lib/auto_completer.rb +57 -3
  424. data/plugins/auto_indenter/lib/auto_indenter.rb +1 -1
  425. data/plugins/core/lib/core.rb +5 -3
  426. data/plugins/core/lib/core/interface.rb +73 -0
  427. data/plugins/core/lib/core/model.rb +2 -0
  428. data/plugins/core/lib/core/observable.rb +12 -1
  429. data/plugins/core/lib/core/observable_struct.rb +34 -0
  430. data/plugins/core/lib/core/plugin/storage.rb +16 -3
  431. data/plugins/core/lib/core/reentry_helpers.rb +13 -0
  432. data/plugins/core/spec/core/observable_spec.rb +13 -0
  433. data/plugins/core/spec/core/storage_spec.rb +18 -0
  434. data/plugins/core/spec/spec_helper.rb +1 -0
  435. data/plugins/edit_view/features/cut_and_paste.feature +4 -2
  436. data/plugins/edit_view/features/soft_tabs.feature +243 -0
  437. data/plugins/edit_view/features/step_definitions/editing_steps.rb +91 -2
  438. data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
  439. data/plugins/edit_view/features/tabs.feature +146 -0
  440. data/plugins/edit_view/lib/edit_view.rb +197 -8
  441. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +121 -0
  442. data/plugins/edit_view/lib/edit_view/actions/deletion.rb +30 -0
  443. data/plugins/edit_view/lib/edit_view/actions/tab.rb +66 -0
  444. data/plugins/edit_view/lib/edit_view/command.rb +0 -2
  445. data/plugins/edit_view/lib/edit_view/document.rb +62 -27
  446. data/plugins/edit_view/lib/edit_view/document/command.rb +11 -0
  447. data/plugins/edit_view/lib/edit_view/edit_tab.rb +2 -1
  448. data/plugins/edit_view/lib/edit_view/info_speedbar.rb +69 -0
  449. data/plugins/edit_view/lib/edit_view/tab_settings.rb +40 -0
  450. data/plugins/edit_view/spec/edit_view/document_spec.rb +26 -0
  451. data/plugins/edit_view/spec/spec_helper.rb +0 -1
  452. data/plugins/edit_view_swt/lib/edit_view_swt.rb +57 -69
  453. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +24 -3
  454. data/plugins/edit_view_swt/lib/edit_view_swt/edit_tab.rb +23 -6
  455. data/plugins/edit_view_swt/spec/spec_helper.rb +0 -1
  456. data/plugins/edit_view_swt/vendor/java-mateview.rb +19 -2
  457. data/plugins/encryption/encryption.rb +38 -0
  458. data/plugins/encryption/ezcrypto.rb +652 -0
  459. data/plugins/encryption/jarmor-1.1.jar +0 -0
  460. data/plugins/encryption/plugin.rb +9 -0
  461. data/plugins/execute_current_tab/lib/execute_current_tab.rb +56 -0
  462. data/plugins/execute_current_tab/plugin.rb +8 -0
  463. data/plugins/html_view/lib/html_view.rb +16 -11
  464. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +2 -1
  465. data/plugins/plugin_manager_ui/views/index.html.erb +22 -4
  466. data/plugins/project/lib/project.rb +140 -26
  467. data/plugins/project/lib/project/drb_service.rb +75 -0
  468. data/plugins/project/lib/project/file_mirror.rb +5 -5
  469. data/plugins/project/lib/project/find_file_dialog.rb +123 -32
  470. data/plugins/project/spec/project/file_mirror_spec.rb +10 -1
  471. data/plugins/project/spec/spec_helper.rb +0 -1
  472. data/plugins/redcar/plugin.rb +1 -1
  473. data/plugins/redcar/redcar.rb +204 -109
  474. data/plugins/redcar/spec/redcar/redcar_spec.rb +70 -0
  475. data/plugins/redcar/spec/spec_helper.rb +4 -0
  476. data/plugins/repl/lib/repl.rb +14 -7
  477. data/plugins/repl/lib/repl/internal_mirror.rb +43 -22
  478. data/plugins/repl/spec/repl/internal_mirror_spec.rb +34 -7
  479. data/plugins/repl/spec/spec_helper.rb +0 -1
  480. data/plugins/tree/spec/spec_helper.rb +0 -1
  481. data/plugins/tree_view_swt/lib/tree_view_swt.rb +1 -1
  482. data/textmate/Bundles/RedcarRepl.tmbundle/Syntaxes/InternalRuby.plist +2 -18
  483. data/textmate/Bundles/asciidoc.tmbundle/Syntaxes/AsciiDoc.tmLanguage +428 -0
  484. metadata +790 -371
  485. data/lib/redcar/boot.rb +0 -108
@@ -0,0 +1,419 @@
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
+ * Copyright (C) 2007 Wiliam 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;
30
+
31
+ import java.io.StringReader;
32
+ import java.io.StringWriter;
33
+ import java.math.BigInteger;
34
+ import java.security.KeyFactory;
35
+ import java.security.KeyPair;
36
+ import java.security.NoSuchAlgorithmException;
37
+ import java.security.PrivateKey;
38
+ import java.security.PublicKey;
39
+ import java.security.interfaces.DSAKey;
40
+ import java.security.interfaces.DSAParams;
41
+ import java.security.interfaces.DSAPrivateKey;
42
+ import java.security.interfaces.DSAPublicKey;
43
+ import java.security.spec.DSAPublicKeySpec;
44
+ import java.security.spec.InvalidKeySpecException;
45
+ import java.security.spec.PKCS8EncodedKeySpec;
46
+ import java.security.spec.X509EncodedKeySpec;
47
+
48
+ import org.bouncycastle.asn1.ASN1EncodableVector;
49
+ import org.bouncycastle.asn1.DERInteger;
50
+ import org.bouncycastle.asn1.DERSequence;
51
+ import org.jruby.Ruby;
52
+ import org.jruby.RubyClass;
53
+ import org.jruby.RubyFixnum;
54
+ import org.jruby.RubyModule;
55
+ import org.jruby.RubyString;
56
+ import org.jruby.anno.JRubyMethod;
57
+ import org.jruby.exceptions.RaiseException;
58
+ import org.jruby.ext.openssl.x509store.PEMInputOutput;
59
+ import org.jruby.runtime.Block;
60
+ import org.jruby.runtime.ObjectAllocator;
61
+ import org.jruby.runtime.builtin.IRubyObject;
62
+ import org.jruby.util.ByteList;
63
+
64
+ /**
65
+ * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
66
+ */
67
+ public class PKeyDSA extends PKey {
68
+ private static final long serialVersionUID = 2359742219218350277L;
69
+
70
+ private static ObjectAllocator PKEYDSA_ALLOCATOR = new ObjectAllocator() {
71
+ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
72
+ return new PKeyDSA(runtime, klass);
73
+ }
74
+ };
75
+
76
+ public static void createPKeyDSA(Ruby runtime, RubyModule mPKey) {
77
+ RubyClass cDSA = mPKey.defineClassUnder("DSA",mPKey.getClass("PKey"),PKEYDSA_ALLOCATOR);
78
+ RubyClass pkeyError = mPKey.getClass("PKeyError");
79
+ mPKey.defineClassUnder("DSAError",pkeyError,pkeyError.getAllocator());
80
+
81
+
82
+ cDSA.defineAnnotatedMethods(PKeyDSA.class);
83
+ }
84
+
85
+ public static RaiseException newDSAError(Ruby runtime, String message) {
86
+ return new RaiseException(runtime, ((RubyModule)runtime.getModule("OpenSSL").getConstantAt("PKey")).getClass("DSAError"), message, true);
87
+ }
88
+
89
+ public PKeyDSA(Ruby runtime, RubyClass type) {
90
+ super(runtime,type);
91
+ }
92
+
93
+ private DSAPrivateKey privKey;
94
+ private DSAPublicKey pubKey;
95
+
96
+ // specValues holds individual DSAPublicKeySpec components. this allows
97
+ // a public key to be constructed incrementally, as required by the
98
+ // current implementation of Net::SSH.
99
+ // (see net-ssh-1.1.2/lib/net/ssh/transport/ossl/buffer.rb #read_keyblob)
100
+ private BigInteger[] specValues;
101
+
102
+ private static final int SPEC_Y = 0;
103
+ private static final int SPEC_P = 1;
104
+ private static final int SPEC_Q = 2;
105
+ private static final int SPEC_G = 3;
106
+
107
+
108
+ PublicKey getPublicKey() {
109
+ return pubKey;
110
+ }
111
+
112
+ PrivateKey getPrivateKey() {
113
+ return privKey;
114
+ }
115
+
116
+ String getAlgorithm() {
117
+ return "DSA";
118
+ }
119
+
120
+ @JRubyMethod(rest=true)
121
+ public IRubyObject initialize(IRubyObject[] args) {
122
+ IRubyObject arg;
123
+ IRubyObject pass = null;
124
+ char[] passwd = null;
125
+ if(org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,0,2) == 0) {
126
+ } else {
127
+ arg = args[0];
128
+ if(args.length > 1) {
129
+ pass = args[1];
130
+ }
131
+ if(arg instanceof RubyFixnum) {
132
+ } else {
133
+ if(pass != null && !pass.isNil()) {
134
+ passwd = pass.toString().toCharArray();
135
+ }
136
+ String input = arg.toString();
137
+
138
+ Object val = null;
139
+ KeyFactory fact = null;
140
+ try {
141
+ fact = KeyFactory.getInstance("DSA",OpenSSLReal.PROVIDER);
142
+ } catch(NoSuchAlgorithmException e) {
143
+ throw getRuntime().newLoadError("unsupported key algorithm (DSA)");
144
+ }
145
+ if(null == val) {
146
+ try {
147
+ val = PEMInputOutput.readDSAPrivateKey(new StringReader(input),passwd);
148
+ } catch(Exception e3) {
149
+ val = null;
150
+ }
151
+ }
152
+ if(null == val) {
153
+ try {
154
+ val = PEMInputOutput.readDSAPublicKey(new StringReader(input),passwd);
155
+ } catch(Exception e3) {
156
+ val = null;
157
+ }
158
+ }
159
+ if(null == val) {
160
+ try {
161
+ val = PEMInputOutput.readDSAPubKey(new StringReader(input),passwd);
162
+ } catch(Exception e3) {
163
+ val = null;
164
+ }
165
+ }
166
+ if(null == val) {
167
+ try {
168
+ val = fact.generatePrivate(new PKCS8EncodedKeySpec(ByteList.plain(input)));
169
+ } catch(Exception e) {
170
+ val = null;
171
+ }
172
+ }
173
+ if(null == val) {
174
+ try {
175
+ val = fact.generatePublic(new X509EncodedKeySpec(ByteList.plain(input)));
176
+ } catch(Exception e) {
177
+ val = null;
178
+ }
179
+ }
180
+ if(null == val) {
181
+ throw newDSAError(getRuntime(), "Neither PUB key nor PRIV key:");
182
+ }
183
+
184
+ if(val instanceof KeyPair) {
185
+ privKey = (DSAPrivateKey)(((KeyPair)val).getPrivate());
186
+ pubKey = (DSAPublicKey)(((KeyPair)val).getPublic());
187
+ } else if(val instanceof DSAPrivateKey) {
188
+ privKey = (DSAPrivateKey)val;
189
+ } else if(val instanceof DSAPublicKey) {
190
+ pubKey = (DSAPublicKey)val;
191
+ privKey = null;
192
+ } else {
193
+ throw newDSAError(getRuntime(), "Neither PUB key nor PRIV key:");
194
+ }
195
+ }
196
+ }
197
+
198
+ return this;
199
+ }
200
+
201
+ @JRubyMethod(name="public?")
202
+ public IRubyObject public_p() {
203
+ return pubKey != null ? getRuntime().getTrue() : getRuntime().getFalse();
204
+ }
205
+
206
+ @JRubyMethod(name="private?")
207
+ public IRubyObject private_p() {
208
+ return privKey != null ? getRuntime().getTrue() : getRuntime().getFalse();
209
+ }
210
+
211
+ @JRubyMethod
212
+ public IRubyObject to_der() throws Exception {
213
+ if(pubKey != null && privKey == null) {
214
+ return RubyString.newString(getRuntime(), pubKey.getEncoded());
215
+ } else if(privKey != null && pubKey != null) {
216
+ DSAParams params = privKey.getParams();
217
+ ASN1EncodableVector v1 = new ASN1EncodableVector();
218
+ v1.add(new DERInteger(0));
219
+ v1.add(new DERInteger(params.getP()));
220
+ v1.add(new DERInteger(params.getQ()));
221
+ v1.add(new DERInteger(params.getG()));
222
+ v1.add(new DERInteger(pubKey.getY()));
223
+ v1.add(new DERInteger(privKey.getX()));
224
+ return RubyString.newString(getRuntime(), new DERSequence(v1).getEncoded());
225
+ } else {
226
+ return RubyString.newString(getRuntime(), privKey.getEncoded());
227
+ }
228
+ }
229
+
230
+ @JRubyMethod
231
+ public IRubyObject to_text() throws Exception {
232
+ return getRuntime().getNil();
233
+ }
234
+
235
+ @JRubyMethod
236
+ public IRubyObject public_key() {
237
+ PKeyDSA val = new PKeyDSA(getRuntime(),getMetaClass().getRealClass());
238
+ val.privKey = null;
239
+ val.pubKey = this.pubKey;
240
+ return val;
241
+ }
242
+
243
+ @JRubyMethod(name={"export","to_pem","to_s"}, rest=true)
244
+ public IRubyObject export(IRubyObject[] args) throws Exception {
245
+ StringWriter w = new StringWriter();
246
+ org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,0,2);
247
+ char[] passwd = null;
248
+ String algo = null;
249
+ if(args.length > 0 && !args[0].isNil()) {
250
+ algo = ((Cipher)args[0]).getAlgorithm();
251
+ if(args.length > 1 && !args[1].isNil()) {
252
+ passwd = args[1].toString().toCharArray();
253
+ }
254
+ }
255
+ if(privKey != null) {
256
+ PEMInputOutput.writeDSAPrivateKey(w,privKey,algo,passwd);
257
+ } else {
258
+ PEMInputOutput.writeDSAPublicKey(w,pubKey);
259
+ }
260
+ w.close();
261
+ return getRuntime().newString(w.toString());
262
+ }
263
+
264
+ /*
265
+ private String getPadding(int padding) {
266
+ if(padding < 1 || padding > 4) {
267
+ throw new RaiseException(getRuntime(), (RubyClass)(((RubyModule)(getRuntime().getModule("OpenSSL").getConstant("PKey"))).getConstant("DSAError")), null, true);
268
+ }
269
+
270
+ String p = "/NONE/PKCS1Padding";
271
+ if(padding == 3) {
272
+ p = "/NONE/NoPadding";
273
+ } else if(padding == 4) {
274
+ p = "/NONE/OAEPWithMD5AndMGF1Padding";
275
+ } else if(padding == 2) {
276
+ p = "/NONE/ISO9796-1Padding";
277
+ }
278
+ return p;
279
+ }
280
+ */
281
+
282
+ @JRubyMethod
283
+ public IRubyObject syssign(IRubyObject arg) {
284
+ return getRuntime().getNil();
285
+ }
286
+
287
+ @JRubyMethod
288
+ public IRubyObject sysverify(IRubyObject arg, IRubyObject arg2) {
289
+ return getRuntime().getNil();
290
+ }
291
+
292
+ @JRubyMethod(name="p")
293
+ public synchronized IRubyObject get_p() {
294
+ // FIXME: return only for public?
295
+ DSAKey key;
296
+ BigInteger param;
297
+ if ((key = this.pubKey) != null || (key = this.privKey) != null) {
298
+ if ((param = key.getParams().getP()) != null) {
299
+ return BN.newBN(getRuntime(), param);
300
+ }
301
+ } else if (specValues != null) {
302
+ if ((param = specValues[SPEC_P]) != null) {
303
+ return BN.newBN(getRuntime(), param);
304
+ }
305
+ }
306
+ return getRuntime().getNil();
307
+ }
308
+
309
+ @JRubyMethod(name="p=")
310
+ public synchronized IRubyObject set_p(IRubyObject p) {
311
+ return setKeySpecComponent(SPEC_P, p);
312
+ }
313
+
314
+ @JRubyMethod(name="q")
315
+ public synchronized IRubyObject get_q() {
316
+ // FIXME: return only for public?
317
+ DSAKey key;
318
+ BigInteger param;
319
+ if ((key = this.pubKey) != null || (key = this.privKey) != null) {
320
+ if ((param = key.getParams().getQ()) != null) {
321
+ return BN.newBN(getRuntime(), param);
322
+ }
323
+ } else if (specValues != null) {
324
+ if ((param = specValues[SPEC_Q]) != null) {
325
+ return BN.newBN(getRuntime(), param);
326
+ }
327
+ }
328
+ return getRuntime().getNil();
329
+ }
330
+
331
+ @JRubyMethod(name="q=")
332
+ public synchronized IRubyObject set_q(IRubyObject q) {
333
+ return setKeySpecComponent(SPEC_Q, q);
334
+ }
335
+
336
+ @JRubyMethod(name="g")
337
+ public synchronized IRubyObject get_g() {
338
+ // FIXME: return only for public?
339
+ DSAKey key;
340
+ BigInteger param;
341
+ if ((key = this.pubKey) != null || (key = this.privKey) != null) {
342
+ if ((param = key.getParams().getG()) != null) {
343
+ return BN.newBN(getRuntime(), param);
344
+ }
345
+ } else if (specValues != null) {
346
+ if ((param = specValues[SPEC_G]) != null) {
347
+ return BN.newBN(getRuntime(), param);
348
+ }
349
+ }
350
+ return getRuntime().getNil();
351
+ }
352
+
353
+ @JRubyMethod(name="g=")
354
+ public synchronized IRubyObject set_g(IRubyObject g) {
355
+ return setKeySpecComponent(SPEC_G, g);
356
+ }
357
+
358
+ @JRubyMethod(name="pub_key")
359
+ public synchronized IRubyObject get_pub_key() {
360
+ DSAPublicKey key;
361
+ BigInteger param;
362
+ if ((key = this.pubKey) != null) {
363
+ return BN.newBN(getRuntime(), key.getY());
364
+ } else if (specValues != null) {
365
+ if ((param = specValues[SPEC_Y]) != null) {
366
+ return BN.newBN(getRuntime(), param);
367
+ }
368
+ }
369
+ return getRuntime().getNil();
370
+ }
371
+
372
+ @JRubyMethod(name="pub_key=")
373
+ public synchronized IRubyObject set_pub_key(IRubyObject pub_key) {
374
+ return setKeySpecComponent(SPEC_Y, pub_key);
375
+ }
376
+
377
+ private IRubyObject setKeySpecComponent(int index, IRubyObject value) {
378
+ BigInteger[] vals;
379
+ // illegal to set if we already have a key for this component
380
+ // FIXME: allow changes after keys are created? MRI doesn't prevent it...
381
+ if (this.pubKey != null || this.privKey != null ||
382
+ (vals = this.specValues) != null && vals[index] != null) {
383
+ throw newDSAError(getRuntime(), "illegal modification");
384
+ }
385
+ // get the BigInteger value
386
+ BigInteger bival = BN.getBigInteger(value);
387
+
388
+ if (vals != null) {
389
+ // we already have some vals stored, store this one, too
390
+ vals[index] = bival;
391
+ // check to see if we have all values yet
392
+ for (int i = vals.length; --i >= 0; ) {
393
+ if (vals[i] == null) {
394
+ // still missing components, return
395
+ return value;
396
+ }
397
+ }
398
+ // we now have all components. create the key.
399
+ DSAPublicKeySpec spec = new DSAPublicKeySpec(vals[SPEC_Y], vals[SPEC_P], vals[SPEC_Q], vals[SPEC_G]);
400
+ try {
401
+ this.pubKey = (DSAPublicKey)KeyFactory.getInstance("DSA").generatePublic(spec);
402
+ } catch (InvalidKeySpecException e) {
403
+ throw newDSAError(getRuntime(), "invalid keyspec");
404
+ } catch (NoSuchAlgorithmException e) {
405
+ throw newDSAError(getRuntime(), "unsupported key algorithm (DSA)");
406
+ }
407
+ // clear out the specValues
408
+ this.specValues = null;
409
+
410
+ } else {
411
+
412
+ // first value received, save
413
+ this.specValues = new BigInteger[4];
414
+ this.specValues[index] = bival;
415
+ }
416
+ return value;
417
+ }
418
+
419
+ }// PKeyDSA
@@ -0,0 +1,762 @@
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.io.StringReader;
31
+ import java.io.StringWriter;
32
+ import java.math.BigInteger;
33
+ import java.security.KeyFactory;
34
+ import java.security.KeyPair;
35
+ import java.security.KeyPairGenerator;
36
+ import java.security.PrivateKey;
37
+ import java.security.PublicKey;
38
+ import java.security.interfaces.RSAPrivateCrtKey;
39
+ import java.security.interfaces.RSAPublicKey;
40
+ import java.security.spec.InvalidKeySpecException;
41
+ import java.security.spec.PKCS8EncodedKeySpec;
42
+ import java.security.spec.RSAKeyGenParameterSpec;
43
+ import java.security.spec.RSAPrivateCrtKeySpec;
44
+ import java.security.spec.RSAPublicKeySpec;
45
+ import java.security.spec.X509EncodedKeySpec;
46
+
47
+ import javax.crypto.Cipher;
48
+
49
+ import org.bouncycastle.asn1.ASN1EncodableVector;
50
+ import org.bouncycastle.asn1.ASN1InputStream;
51
+ import org.bouncycastle.asn1.DERInteger;
52
+ import org.bouncycastle.asn1.DERSequence;
53
+ import org.jruby.Ruby;
54
+ import org.jruby.RubyClass;
55
+ import org.jruby.RubyBignum;
56
+ import org.jruby.RubyFixnum;
57
+ import org.jruby.RubyHash;
58
+ import org.jruby.RubyModule;
59
+ import org.jruby.RubyNumeric;
60
+ import org.jruby.RubyString;
61
+ import org.jruby.anno.JRubyMethod;
62
+ import org.jruby.exceptions.RaiseException;
63
+ import org.jruby.ext.openssl.x509store.PEMInputOutput;
64
+ import org.jruby.runtime.Arity;
65
+ import org.jruby.runtime.Block;
66
+ import org.jruby.runtime.ObjectAllocator;
67
+ import org.jruby.runtime.ThreadContext;
68
+ import org.jruby.runtime.builtin.IRubyObject;
69
+ import org.jruby.util.ByteList;
70
+
71
+ /**
72
+ * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
73
+ */
74
+ public class PKeyRSA extends PKey {
75
+ private static ObjectAllocator PKEYRSA_ALLOCATOR = new ObjectAllocator() {
76
+ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
77
+ return new PKeyRSA(runtime, klass);
78
+ }
79
+ };
80
+
81
+ public static void createPKeyRSA(Ruby runtime, RubyModule mPKey) {
82
+ RubyClass cRSA = mPKey.defineClassUnder("RSA",mPKey.getClass("PKey"),PKEYRSA_ALLOCATOR);
83
+ RubyClass pkeyError = mPKey.getClass("PKeyError");
84
+ mPKey.defineClassUnder("RSAError",pkeyError,pkeyError.getAllocator());
85
+
86
+ cRSA.defineAnnotatedMethods(PKeyRSA.class);
87
+
88
+ cRSA.setConstant("PKCS1_PADDING",runtime.newFixnum(1));
89
+ cRSA.setConstant("SSLV23_PADDING",runtime.newFixnum(2));
90
+ cRSA.setConstant("NO_PADDING",runtime.newFixnum(3));
91
+ cRSA.setConstant("PKCS1_OAEP_PADDING",runtime.newFixnum(4));
92
+ }
93
+
94
+ public static RaiseException newRSAError(Ruby runtime, String message) {
95
+ return new RaiseException(runtime, ((RubyModule)runtime.getModule("OpenSSL").getConstantAt("PKey")).getClass("RSAError"), message, true);
96
+ }
97
+
98
+ public PKeyRSA(Ruby runtime, RubyClass type) {
99
+ super(runtime,type);
100
+ }
101
+
102
+ private transient volatile RSAPrivateCrtKey privKey;
103
+ private transient volatile RSAPublicKey pubKey;
104
+
105
+ // fields to hold individual RSAPublicKeySpec components. this allows
106
+ // a public key to be constructed incrementally, as required by the
107
+ // current implementation of Net::SSH.
108
+ // (see net-ssh-1.1.2/lib/net/ssh/transport/ossl/buffer.rb #read_keyblob)
109
+ private transient volatile BigInteger rsa_e;
110
+ private transient volatile BigInteger rsa_n;
111
+
112
+ private transient volatile BigInteger rsa_d;
113
+ private transient volatile BigInteger rsa_p;
114
+ private transient volatile BigInteger rsa_q;
115
+ private transient volatile BigInteger rsa_dmp1;
116
+ private transient volatile BigInteger rsa_dmq1;
117
+ private transient volatile BigInteger rsa_iqmp;
118
+
119
+ PublicKey getPublicKey() {
120
+ return pubKey;
121
+ }
122
+
123
+ PrivateKey getPrivateKey() {
124
+ return privKey;
125
+ }
126
+
127
+ String getAlgorithm() {
128
+ return "RSA";
129
+ }
130
+
131
+ @JRubyMethod(name="generate", meta=true, rest=true)
132
+ public static IRubyObject generate(IRubyObject recv, IRubyObject[] args) {
133
+ BigInteger exp = RSAKeyGenParameterSpec.F4;
134
+ if(Arity.checkArgumentCount(recv.getRuntime(),args,1,2) == 2) {
135
+ if(args[1] instanceof RubyFixnum) {
136
+ exp = BigInteger.valueOf(RubyNumeric.num2long(args[1]));
137
+ } else {
138
+ exp = ((RubyBignum)args[1]).getValue();
139
+ }
140
+ }
141
+ int keysize = RubyNumeric.fix2int(args[0]);
142
+ RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(keysize, exp);
143
+ try {
144
+ KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA",OpenSSLReal.PROVIDER);
145
+ gen.initialize(spec);
146
+ KeyPair pair = gen.generateKeyPair();
147
+ PKeyRSA rsa = new PKeyRSA(recv.getRuntime(), (RubyClass)recv);
148
+ rsa.privKey = (RSAPrivateCrtKey)(pair.getPrivate());
149
+ rsa.pubKey = (RSAPublicKey)(pair.getPublic());
150
+ return rsa;
151
+ } catch(Exception e) {
152
+ throw newRSAError(recv.getRuntime(), null);
153
+ }
154
+ }
155
+
156
+ @JRubyMethod(frame=true, rest=true)
157
+ public IRubyObject initialize(IRubyObject[] args, Block block) {
158
+ IRubyObject arg;
159
+ IRubyObject pass = null;
160
+ char[] passwd = null;
161
+ if(org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,0,2) == 0) {
162
+ } else {
163
+ arg = args[0];
164
+ if(args.length > 1) {
165
+ pass = args[1];
166
+ }
167
+ if(arg instanceof RubyFixnum) {
168
+ int keyLen = RubyNumeric.fix2int(arg);
169
+ BigInteger pubExp = RSAKeyGenParameterSpec.F4;
170
+ if(null != pass && !pass.isNil()) {
171
+ pubExp = BigInteger.valueOf(RubyNumeric.num2long(pass));
172
+ }
173
+ try {
174
+ KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA",OpenSSLReal.PROVIDER);
175
+ gen.initialize(new RSAKeyGenParameterSpec(keyLen,pubExp));
176
+ KeyPair pair = gen.generateKeyPair();
177
+ privKey = (RSAPrivateCrtKey)(pair.getPrivate());
178
+ pubKey = (RSAPublicKey)(pair.getPublic());
179
+ } catch(Exception e) {
180
+ throw newRSAError(getRuntime(), null);
181
+ }
182
+ } else {
183
+ if(pass != null && !pass.isNil()) {
184
+ passwd = pass.toString().toCharArray();
185
+ }
186
+ String input = arg.toString();
187
+
188
+ Object val = null;
189
+ KeyFactory fact = null;
190
+ try {
191
+ fact = KeyFactory.getInstance("RSA", OpenSSLReal.PROVIDER);
192
+ } catch(Exception e) {
193
+ throw getRuntime().newLoadError("unsupported key algorithm (RSA)");
194
+ }
195
+
196
+ if(null == val) {
197
+ try {
198
+ val = PEMInputOutput.readRSAPrivateKey(new StringReader(input),passwd);
199
+ } catch(Exception e) {
200
+ val = null;
201
+ }
202
+ }
203
+ if(null == val) {
204
+ try {
205
+ val = PEMInputOutput.readRSAPublicKey(new StringReader(input),passwd);
206
+ } catch(Exception e) {
207
+ val = null;
208
+ }
209
+ }
210
+ if(null == val) {
211
+ try {
212
+ val = PEMInputOutput.readRSAPubKey(new StringReader(input),passwd);
213
+ } catch(Exception e) {
214
+ val = null;
215
+ }
216
+ }
217
+ if(null == val) {
218
+ try {
219
+ DERSequence seq = (DERSequence)(new ASN1InputStream(ByteList.plain(input)).readObject());
220
+ if(seq.size() == 9) {
221
+ BigInteger mod = ((DERInteger)seq.getObjectAt(1)).getValue();
222
+ BigInteger pubexp = ((DERInteger)seq.getObjectAt(2)).getValue();
223
+ BigInteger privexp = ((DERInteger)seq.getObjectAt(3)).getValue();
224
+ BigInteger primep = ((DERInteger)seq.getObjectAt(4)).getValue();
225
+ BigInteger primeq = ((DERInteger)seq.getObjectAt(5)).getValue();
226
+ BigInteger primeep = ((DERInteger)seq.getObjectAt(6)).getValue();
227
+ BigInteger primeeq = ((DERInteger)seq.getObjectAt(7)).getValue();
228
+ BigInteger crtcoeff = ((DERInteger)seq.getObjectAt(8)).getValue();
229
+ val = fact.generatePrivate(new RSAPrivateCrtKeySpec(mod,pubexp,privexp,primep,primeq,primeep,primeeq,crtcoeff));
230
+ } else {
231
+ val = null;
232
+ }
233
+ } catch(Exception ex) {
234
+ val = null;
235
+ }
236
+ }
237
+ if(null == val) {
238
+ try {
239
+ DERSequence seq = (DERSequence)(new ASN1InputStream(ByteList.plain(input)).readObject());
240
+ if(seq.size() == 2) {
241
+ BigInteger mod = ((DERInteger)seq.getObjectAt(0)).getValue();
242
+ BigInteger pubexp = ((DERInteger)seq.getObjectAt(1)).getValue();
243
+ val = fact.generatePublic(new RSAPublicKeySpec(mod,pubexp));
244
+ } else {
245
+ val = null;
246
+ }
247
+ } catch(Exception ex) {
248
+ val = null;
249
+ }
250
+ }
251
+ if(null == val) {
252
+ try {
253
+ val = fact.generatePublic(new X509EncodedKeySpec(ByteList.plain(input)));
254
+ } catch(Exception e) {
255
+ val = null;
256
+ }
257
+ }
258
+ if(null == val) {
259
+ try {
260
+ val = fact.generatePrivate(new PKCS8EncodedKeySpec(ByteList.plain(input)));
261
+ } catch(Exception e) {
262
+ val = null;
263
+ }
264
+ }
265
+ if(null == val) {
266
+ throw newRSAError(getRuntime(), "Neither PUB key nor PRIV key:");
267
+ }
268
+
269
+ if(val instanceof KeyPair) {
270
+ privKey = (RSAPrivateCrtKey)(((KeyPair)val).getPrivate());
271
+ pubKey = (RSAPublicKey)(((KeyPair)val).getPublic());
272
+ } else if(val instanceof RSAPrivateCrtKey) {
273
+ privKey = (RSAPrivateCrtKey)val;
274
+ try {
275
+ pubKey = (RSAPublicKey)(fact.generatePublic(new RSAPublicKeySpec(privKey.getModulus(),privKey.getPublicExponent())));
276
+ } catch(Exception e) {
277
+ throw newRSAError(getRuntime(), "Something rotten with private key");
278
+ }
279
+ } else if(val instanceof RSAPublicKey) {
280
+ pubKey = (RSAPublicKey)val;
281
+ privKey = null;
282
+ } else {
283
+ throw newRSAError(getRuntime(), "Neither PUB key nor PRIV key:");
284
+ }
285
+ }
286
+ }
287
+
288
+ return this;
289
+ }
290
+
291
+ @JRubyMethod(name="public?")
292
+ public IRubyObject public_p() {
293
+ return pubKey != null ? getRuntime().getTrue() : getRuntime().getFalse();
294
+ }
295
+
296
+ @JRubyMethod(name="private?")
297
+ public IRubyObject private_p() {
298
+ return privKey != null ? getRuntime().getTrue() : getRuntime().getFalse();
299
+ }
300
+
301
+ @JRubyMethod
302
+ public IRubyObject to_der() throws Exception {
303
+ if(pubKey != null && privKey == null) {
304
+ ASN1EncodableVector v1 = new ASN1EncodableVector();
305
+ v1.add(new DERInteger(pubKey.getModulus()));
306
+ v1.add(new DERInteger(pubKey.getPublicExponent()));
307
+ return RubyString.newString(getRuntime(), new DERSequence(v1).getEncoded());
308
+ } else {
309
+ ASN1EncodableVector v1 = new ASN1EncodableVector();
310
+ v1.add(new DERInteger(0));
311
+ v1.add(new DERInteger(privKey.getModulus()));
312
+ v1.add(new DERInteger(privKey.getPublicExponent()));
313
+ v1.add(new DERInteger(privKey.getPrivateExponent()));
314
+ v1.add(new DERInteger(privKey.getPrimeP()));
315
+ v1.add(new DERInteger(privKey.getPrimeQ()));
316
+ v1.add(new DERInteger(privKey.getPrimeExponentP()));
317
+ v1.add(new DERInteger(privKey.getPrimeExponentQ()));
318
+ v1.add(new DERInteger(privKey.getCrtCoefficient()));
319
+ return RubyString.newString(getRuntime(), new DERSequence(v1).getEncoded());
320
+ }
321
+ }
322
+
323
+ @JRubyMethod
324
+ public IRubyObject public_key() {
325
+ PKeyRSA val = new PKeyRSA(getRuntime(),getMetaClass().getRealClass());
326
+ val.privKey = null;
327
+ val.pubKey = this.pubKey;
328
+ return val;
329
+ }
330
+
331
+ private static void addSplittedAndFormatted(int keylen, StringBuilder result, BigInteger value) {
332
+ String v = value.toString(16);
333
+ if((v.length() % 2) != 0) {
334
+ v = "0" + v;
335
+ }
336
+ String sep = "";
337
+ for(int i = 0; i<v.length(); i+=2) {
338
+ result.append(sep);
339
+ if((i % 30) == 0) {
340
+ result.append("\n ");
341
+ }
342
+ result.append(v.substring(i, i+2));
343
+ sep = ":";
344
+ }
345
+ result.append("\n");
346
+ }
347
+
348
+ @JRubyMethod
349
+ public IRubyObject params() throws Exception {
350
+ ThreadContext ctx = getRuntime().getCurrentContext();
351
+ RubyHash hash = RubyHash.newHash(getRuntime());
352
+ if(privKey != null) {
353
+ hash.op_aset(ctx, getRuntime().newString("iqmp"), BN.newBN(getRuntime(), privKey.getCrtCoefficient()));
354
+ hash.op_aset(ctx, getRuntime().newString("n"), BN.newBN(getRuntime(), privKey.getModulus()));
355
+ hash.op_aset(ctx, getRuntime().newString("d"), BN.newBN(getRuntime(), privKey.getPrivateExponent()));
356
+ hash.op_aset(ctx, getRuntime().newString("p"), BN.newBN(getRuntime(), privKey.getPrimeP()));
357
+ hash.op_aset(ctx, getRuntime().newString("e"), BN.newBN(getRuntime(), privKey.getPublicExponent()));
358
+ hash.op_aset(ctx, getRuntime().newString("q"), BN.newBN(getRuntime(), privKey.getPrimeQ()));
359
+ hash.op_aset(ctx, getRuntime().newString("dmq1"), BN.newBN(getRuntime(), privKey.getPrimeExponentQ()));
360
+ hash.op_aset(ctx, getRuntime().newString("dmp1"), BN.newBN(getRuntime(), privKey.getPrimeExponentP()));
361
+
362
+ } else {
363
+ hash.op_aset(ctx, getRuntime().newString("iqmp"), BN.newBN(getRuntime(), BigInteger.ZERO));
364
+ hash.op_aset(ctx, getRuntime().newString("n"), BN.newBN(getRuntime(), pubKey.getModulus()));
365
+ hash.op_aset(ctx, getRuntime().newString("d"), BN.newBN(getRuntime(), BigInteger.ZERO));
366
+ hash.op_aset(ctx, getRuntime().newString("p"), BN.newBN(getRuntime(), BigInteger.ZERO));
367
+ hash.op_aset(ctx, getRuntime().newString("e"), BN.newBN(getRuntime(), pubKey.getPublicExponent()));
368
+ hash.op_aset(ctx, getRuntime().newString("q"), BN.newBN(getRuntime(), BigInteger.ZERO));
369
+ hash.op_aset(ctx, getRuntime().newString("dmq1"), BN.newBN(getRuntime(), BigInteger.ZERO));
370
+ hash.op_aset(ctx, getRuntime().newString("dmp1"), BN.newBN(getRuntime(), BigInteger.ZERO));
371
+ }
372
+ return hash;
373
+ }
374
+
375
+ @JRubyMethod
376
+ public IRubyObject to_text() throws Exception {
377
+ StringBuilder result = new StringBuilder();
378
+ if(privKey != null) {
379
+ int len = privKey.getModulus().bitLength();
380
+ result.append("Private-Key: (").append(len).append(" bit)").append("\n");
381
+ result.append("modulus:");
382
+ addSplittedAndFormatted(len, result, privKey.getModulus());
383
+ result.append("publicExponent: ").append(privKey.getPublicExponent()).append(" (0x").append(privKey.getPublicExponent().toString(16)).append(")\n");
384
+ result.append("privateExponent:");
385
+ addSplittedAndFormatted(len, result, privKey.getPrivateExponent());
386
+ result.append("prime1:");
387
+ addSplittedAndFormatted(len, result, privKey.getPrimeP());
388
+ result.append("prime2:");
389
+ addSplittedAndFormatted(len, result, privKey.getPrimeQ());
390
+ result.append("exponent1:");
391
+ addSplittedAndFormatted(len, result, privKey.getPrimeExponentP());
392
+ result.append("exponent2:");
393
+ addSplittedAndFormatted(len, result, privKey.getPrimeExponentQ());
394
+ result.append("coefficient:");
395
+ addSplittedAndFormatted(len, result, privKey.getCrtCoefficient());
396
+ } else {
397
+ int len = pubKey.getModulus().bitLength();
398
+ result.append("Modulus (").append(len).append(" bit):");
399
+ addSplittedAndFormatted(len, result, pubKey.getModulus());
400
+ result.append("Exponent: ").append(pubKey.getPublicExponent()).append(" (0x").append(pubKey.getPublicExponent().toString(16)).append(")\n");
401
+ }
402
+ return getRuntime().newString(result.toString());
403
+ }
404
+
405
+ @JRubyMethod(name={"export", "to_pem", "to_s"}, rest=true)
406
+ public IRubyObject export(IRubyObject[] args) throws Exception {
407
+ StringWriter w = new StringWriter();
408
+ org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,0,2);
409
+ char[] passwd = null;
410
+ String algo = null;
411
+ if(args.length > 0 && !args[0].isNil()) {
412
+ algo = ((org.jruby.ext.openssl.Cipher)args[0]).getAlgorithm();
413
+ if(args.length > 1 && !args[1].isNil()) {
414
+ passwd = args[1].toString().toCharArray();
415
+ }
416
+ }
417
+ if(privKey != null) {
418
+ PEMInputOutput.writeRSAPrivateKey(w,privKey,algo,passwd);
419
+ } else {
420
+ PEMInputOutput.writeRSAPublicKey(w,pubKey);
421
+ }
422
+ w.close();
423
+ return getRuntime().newString(w.toString());
424
+ }
425
+
426
+ private String getPadding(int padding) {
427
+ if(padding < 1 || padding > 4) {
428
+ throw newRSAError(getRuntime(), null);
429
+ }
430
+
431
+ String p = "/NONE/PKCS1Padding";
432
+ if(padding == 3) {
433
+ p = "/NONE/NoPadding";
434
+ } else if(padding == 4) {
435
+ p = "/NONE/OAEPWithMD5AndMGF1Padding";
436
+ } else if(padding == 2) {
437
+ p = "/NONE/ISO9796-1Padding";
438
+ }
439
+ return p;
440
+ }
441
+
442
+ @JRubyMethod(rest=true)
443
+ public IRubyObject private_encrypt(IRubyObject[] args) throws Exception {
444
+ int padding = 1;
445
+ if(org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,1,2) == 2 && !args[1].isNil()) {
446
+ padding = RubyNumeric.fix2int(args[1]);
447
+ }
448
+ String p = getPadding(padding);
449
+
450
+ RubyString buffer = args[0].convertToString();
451
+ if(privKey == null) {
452
+ throw newRSAError(getRuntime(), "private key needed.");
453
+ }
454
+
455
+ Cipher engine = Cipher.getInstance("RSA"+p,OpenSSLReal.PROVIDER);
456
+ engine.init(Cipher.ENCRYPT_MODE,privKey);
457
+ byte[] outp = engine.doFinal(buffer.getBytes());
458
+ return RubyString.newString(getRuntime(), outp);
459
+ }
460
+
461
+ @JRubyMethod(rest=true)
462
+ public IRubyObject private_decrypt(IRubyObject[] args) throws Exception {
463
+ int padding = 1;
464
+ if(org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,1,2) == 2 && !args[1].isNil()) {
465
+ padding = RubyNumeric.fix2int(args[1]);
466
+ }
467
+ String p = getPadding(padding);
468
+
469
+ RubyString buffer = args[0].convertToString();
470
+ if(privKey == null) {
471
+ throw newRSAError(getRuntime(), "private key needed.");
472
+ }
473
+
474
+ Cipher engine = Cipher.getInstance("RSA"+p,OpenSSLReal.PROVIDER);
475
+ engine.init(Cipher.DECRYPT_MODE,privKey);
476
+ byte[] outp = engine.doFinal(buffer.getBytes());
477
+ return RubyString.newString(getRuntime(), outp);
478
+ }
479
+
480
+ @JRubyMethod(rest=true)
481
+ public IRubyObject public_encrypt(IRubyObject[] args) throws Exception {
482
+ int padding = 1;
483
+ if(org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,1,2) == 2 && !args[1].isNil()) {
484
+ padding = RubyNumeric.fix2int(args[1]);
485
+ }
486
+ String p = getPadding(padding);
487
+
488
+ RubyString buffer = args[0].convertToString();
489
+ Cipher engine = Cipher.getInstance("RSA"+p,OpenSSLReal.PROVIDER);
490
+ engine.init(Cipher.ENCRYPT_MODE,pubKey);
491
+ byte[] outp = engine.doFinal(buffer.getBytes());
492
+ return RubyString.newString(getRuntime(), outp);
493
+ }
494
+
495
+ @JRubyMethod(rest=true)
496
+ public IRubyObject public_decrypt(IRubyObject[] args) throws Exception {
497
+ int padding = 1;
498
+ if(org.jruby.runtime.Arity.checkArgumentCount(getRuntime(),args,1,2) == 2 && !args[1].isNil()) {
499
+ padding = RubyNumeric.fix2int(args[1]);
500
+ }
501
+ String p = getPadding(padding);
502
+
503
+ RubyString buffer = args[0].convertToString();
504
+ Cipher engine = Cipher.getInstance("RSA"+p,OpenSSLReal.PROVIDER);
505
+ engine.init(Cipher.DECRYPT_MODE,pubKey);
506
+ byte[] outp = engine.doFinal(buffer.getBytes());
507
+ return RubyString.newString(getRuntime(), outp);
508
+ }
509
+
510
+ @JRubyMethod(name="d=")
511
+ public synchronized IRubyObject set_d(IRubyObject value) {
512
+ if (privKey != null) {
513
+ throw newRSAError(getRuntime(), "illegal modification");
514
+ }
515
+ rsa_d = BN.getBigInteger(value);
516
+ generatePrivateKeyIfParams();
517
+ return value;
518
+ }
519
+
520
+ @JRubyMethod(name="p=")
521
+ public synchronized IRubyObject set_p(IRubyObject value) {
522
+ if (privKey != null) {
523
+ throw newRSAError(getRuntime(), "illegal modification");
524
+ }
525
+ rsa_p = BN.getBigInteger(value);
526
+ generatePrivateKeyIfParams();
527
+ return value;
528
+ }
529
+
530
+ @JRubyMethod(name="q=")
531
+ public synchronized IRubyObject set_q(IRubyObject value) {
532
+ if (privKey != null) {
533
+ throw newRSAError(getRuntime(), "illegal modification");
534
+ }
535
+ rsa_q = BN.getBigInteger(value);
536
+ generatePrivateKeyIfParams();
537
+ return value;
538
+ }
539
+
540
+ @JRubyMethod(name="dmp1=")
541
+ public synchronized IRubyObject set_dmp1(IRubyObject value) {
542
+ if (privKey != null) {
543
+ throw newRSAError(getRuntime(), "illegal modification");
544
+ }
545
+ rsa_dmp1 = BN.getBigInteger(value);
546
+ generatePrivateKeyIfParams();
547
+ return value;
548
+ }
549
+
550
+ @JRubyMethod(name="dmq1=")
551
+ public synchronized IRubyObject set_dmq1(IRubyObject value) {
552
+ if (privKey != null) {
553
+ throw newRSAError(getRuntime(), "illegal modification");
554
+ }
555
+ rsa_dmq1 = BN.getBigInteger(value);
556
+ generatePrivateKeyIfParams();
557
+ return value;
558
+ }
559
+
560
+ @JRubyMethod(name="iqmp=")
561
+ public synchronized IRubyObject set_iqmp(IRubyObject value) {
562
+ if (privKey != null) {
563
+ throw newRSAError(getRuntime(), "illegal modification");
564
+ }
565
+ rsa_iqmp = BN.getBigInteger(value);
566
+ generatePrivateKeyIfParams();
567
+ return value;
568
+ }
569
+
570
+ @JRubyMethod(name="iqmp")
571
+ public synchronized IRubyObject get_iqmp() {
572
+ BigInteger iqmp = null;
573
+ if (privKey != null) {
574
+ iqmp = privKey.getCrtCoefficient();
575
+ } else {
576
+ iqmp = rsa_iqmp;
577
+ }
578
+ if (iqmp != null) {
579
+ return BN.newBN(getRuntime(), iqmp);
580
+ }
581
+ return getRuntime().getNil();
582
+ }
583
+
584
+ @JRubyMethod(name="dmp1")
585
+ public synchronized IRubyObject get_dmp1() {
586
+ BigInteger dmp1 = null;
587
+ if (privKey != null) {
588
+ dmp1 = privKey.getPrimeExponentP();
589
+ } else {
590
+ dmp1 = rsa_dmp1;
591
+ }
592
+ if (dmp1 != null) {
593
+ return BN.newBN(getRuntime(), dmp1);
594
+ }
595
+ return getRuntime().getNil();
596
+ }
597
+
598
+ @JRubyMethod(name="dmq1")
599
+ public synchronized IRubyObject get_dmq1() {
600
+ BigInteger dmq1 = null;
601
+ if (privKey != null) {
602
+ dmq1 = privKey.getPrimeExponentQ();
603
+ } else {
604
+ dmq1 = rsa_dmq1;
605
+ }
606
+ if (dmq1 != null) {
607
+ return BN.newBN(getRuntime(), dmq1);
608
+ }
609
+ return getRuntime().getNil();
610
+ }
611
+
612
+ @JRubyMethod(name="d")
613
+ public synchronized IRubyObject get_d() {
614
+ BigInteger d = null;
615
+ if (privKey != null) {
616
+ d = privKey.getPrivateExponent();
617
+ } else {
618
+ d = rsa_d;
619
+ }
620
+ if (d != null) {
621
+ return BN.newBN(getRuntime(), d);
622
+ }
623
+ return getRuntime().getNil();
624
+ }
625
+
626
+ @JRubyMethod(name="p")
627
+ public synchronized IRubyObject get_p() {
628
+ BigInteger p = null;
629
+ if (privKey != null) {
630
+ p = privKey.getPrimeP();
631
+ } else {
632
+ p = rsa_p;
633
+ }
634
+ if (p != null) {
635
+ return BN.newBN(getRuntime(), p);
636
+ }
637
+ return getRuntime().getNil();
638
+ }
639
+
640
+ @JRubyMethod(name="q")
641
+ public synchronized IRubyObject get_q() {
642
+ BigInteger q = null;
643
+ if (privKey != null) {
644
+ q = privKey.getPrimeQ();
645
+ } else {
646
+ q = rsa_q;
647
+ }
648
+ if (q != null) {
649
+ return BN.newBN(getRuntime(), q);
650
+ }
651
+ return getRuntime().getNil();
652
+ }
653
+
654
+ @JRubyMethod(name="e")
655
+ public synchronized IRubyObject get_e() {
656
+ RSAPublicKey key;
657
+ BigInteger e;
658
+ if ((key = pubKey) != null) {
659
+ e = key.getPublicExponent();
660
+ } else if(privKey != null) {
661
+ e = privKey.getPublicExponent();
662
+ } else {
663
+ e = rsa_e;
664
+ }
665
+ if (e != null) {
666
+ return BN.newBN(getRuntime(), e);
667
+ }
668
+ return getRuntime().getNil();
669
+ }
670
+
671
+ @JRubyMethod(name="e=")
672
+ public synchronized IRubyObject set_e(IRubyObject value) {
673
+ rsa_e = BN.getBigInteger(value);
674
+
675
+ if(privKey == null) {
676
+ generatePrivateKeyIfParams();
677
+ }
678
+ if(pubKey == null) {
679
+ generatePublicKeyIfParams();
680
+ }
681
+ return value;
682
+ }
683
+
684
+ @JRubyMethod(name="n")
685
+ public synchronized IRubyObject get_n() {
686
+ RSAPublicKey key;
687
+ BigInteger n;
688
+ if ((key = pubKey) != null) {
689
+ n = key.getModulus();
690
+ } else if(privKey != null) {
691
+ n = privKey.getModulus();
692
+ } else {
693
+ n = rsa_n;
694
+ }
695
+ if (n != null) {
696
+ return BN.newBN(getRuntime(), n);
697
+ }
698
+ return getRuntime().getNil();
699
+ }
700
+
701
+ @JRubyMethod(name="n=")
702
+ public synchronized IRubyObject set_n(IRubyObject value) {
703
+ rsa_n = BN.getBigInteger(value);
704
+
705
+ if(privKey == null) {
706
+ generatePrivateKeyIfParams();
707
+ }
708
+ if(pubKey == null) {
709
+ generatePublicKeyIfParams();
710
+ }
711
+ return value;
712
+ }
713
+
714
+ private void generatePublicKeyIfParams() {
715
+ if (pubKey != null) {
716
+ throw newRSAError(getRuntime(), "illegal modification");
717
+ }
718
+ BigInteger e, n;
719
+ if ((e = rsa_e) != null && (n = rsa_n) != null) {
720
+ KeyFactory fact;
721
+ try {
722
+ fact = KeyFactory.getInstance("RSA", OpenSSLReal.PROVIDER);
723
+ } catch(Exception ex) {
724
+ throw getRuntime().newLoadError("unsupported key algorithm (RSA)");
725
+ }
726
+ try {
727
+ pubKey = (RSAPublicKey)fact.generatePublic(new RSAPublicKeySpec(n, e));
728
+ } catch (InvalidKeySpecException ex) {
729
+ throw newRSAError(getRuntime(), "invalid parameters");
730
+ }
731
+ rsa_e = null;
732
+ rsa_n = null;
733
+ }
734
+ }
735
+
736
+ private void generatePrivateKeyIfParams() {
737
+ if (privKey != null) {
738
+ throw newRSAError(getRuntime(), "illegal modification");
739
+ }
740
+ if (rsa_e != null && rsa_n != null && rsa_p != null && rsa_q != null && rsa_d != null && rsa_dmp1 != null && rsa_dmq1 != null && rsa_iqmp != null) {
741
+ KeyFactory fact;
742
+ try {
743
+ fact = KeyFactory.getInstance("RSA", OpenSSLReal.PROVIDER);
744
+ } catch(Exception ex) {
745
+ throw getRuntime().newLoadError("unsupported key algorithm (RSA)");
746
+ }
747
+ try {
748
+ privKey = (RSAPrivateCrtKey)fact.generatePrivate(new RSAPrivateCrtKeySpec(rsa_n, rsa_e, rsa_d, rsa_p, rsa_q, rsa_dmp1, rsa_dmq1, rsa_iqmp));
749
+ } catch (InvalidKeySpecException ex) {
750
+ throw newRSAError(getRuntime(), "invalid parameters");
751
+ }
752
+ rsa_n = null;
753
+ rsa_e = null;
754
+ rsa_d = null;
755
+ rsa_p = null;
756
+ rsa_q = null;
757
+ rsa_dmp1 = null;
758
+ rsa_dmq1 = null;
759
+ rsa_iqmp = null;
760
+ }
761
+ }
762
+ }// PKeyRSA