rho-tau-extensions 5.5.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (661) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +2 -0
  3. data/LICENSE +21 -0
  4. data/README.md +6 -0
  5. data/Rakefile +90 -0
  6. data/libs/crosswalk.rb +2 -0
  7. data/libs/crosswalk/crosswalk.rb +2 -0
  8. data/libs/crosswalk/ext.yml +21 -0
  9. data/libs/crosswalk/ext/Crosswalk.xml +27 -0
  10. data/libs/crosswalk/ext/build +19 -0
  11. data/libs/crosswalk/ext/build.bat +29 -0
  12. data/libs/crosswalk/ext/platform/android/AndroidManifest.xml +9 -0
  13. data/libs/crosswalk/ext/platform/android/Rakefile +141 -0
  14. data/libs/crosswalk/ext/platform/android/adds/lib/armeabi/libxwalkcore.so +0 -0
  15. data/libs/crosswalk/ext/platform/android/adds/lib/armeabi/libxwalkdummy.so +0 -0
  16. data/libs/crosswalk/ext/platform/android/adds/lib/x86/libxwalkcore.so +0 -0
  17. data/libs/crosswalk/ext/platform/android/adds/lib/x86/libxwalkdummy.so +0 -0
  18. data/libs/crosswalk/ext/platform/android/adds/lib/xwalk_core_library_java.jar +0 -0
  19. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/bubble.9.png +0 -0
  20. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/bubble_arrow_up.png +0 -0
  21. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/color_picker_advanced_select_handle.png +0 -0
  22. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/crosswalk.png +0 -0
  23. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/dropdown_popup_background_down.9.png +0 -0
  24. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/dropdown_popup_background_up.9.png +0 -0
  25. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/ic_menu_share_holo_light.png +0 -0
  26. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/ic_search.png +0 -0
  27. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/ic_warning.png +0 -0
  28. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/ondemand_overlay.9.png +0 -0
  29. data/libs/crosswalk/ext/platform/android/adds/res/drawable-hdpi/verify_checkmark.png +0 -0
  30. data/libs/crosswalk/ext/platform/android/adds/res/drawable-ldpi/crosswalk.png +0 -0
  31. data/libs/crosswalk/ext/platform/android/adds/res/drawable-mdpi/crosswalk.png +0 -0
  32. data/libs/crosswalk/ext/platform/android/adds/res/drawable-v21/button_borderless_compat.xml +10 -0
  33. data/libs/crosswalk/ext/platform/android/adds/res/drawable-v21/button_compat.xml +9 -0
  34. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/bubble.9.png +0 -0
  35. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/bubble_arrow_up.png +0 -0
  36. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/color_picker_advanced_select_handle.png +0 -0
  37. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/crosswalk.png +0 -0
  38. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/dropdown_popup_background_down.9.png +0 -0
  39. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/dropdown_popup_background_up.9.png +0 -0
  40. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/ic_menu_share_holo_light.png +0 -0
  41. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/ic_search.png +0 -0
  42. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/ic_warning.png +0 -0
  43. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/ondemand_overlay.9.png +0 -0
  44. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xhdpi/verify_checkmark.png +0 -0
  45. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xxhdpi/ic_menu_share_holo_light.png +0 -0
  46. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xxhdpi/ic_search.png +0 -0
  47. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xxhdpi/ic_warning.png +0 -0
  48. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xxhdpi/verify_checkmark.png +0 -0
  49. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xxxhdpi/ic_menu_share_holo_light.png +0 -0
  50. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xxxhdpi/ic_search.png +0 -0
  51. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xxxhdpi/ic_warning.png +0 -0
  52. data/libs/crosswalk/ext/platform/android/adds/res/drawable-xxxhdpi/verify_checkmark.png +0 -0
  53. data/libs/crosswalk/ext/platform/android/adds/res/drawable/autofill_chip_inset.xml +15 -0
  54. data/libs/crosswalk/ext/platform/android/adds/res/drawable/bubble.9.png +0 -0
  55. data/libs/crosswalk/ext/platform/android/adds/res/drawable/bubble_arrow_up.png +0 -0
  56. data/libs/crosswalk/ext/platform/android/adds/res/drawable/button_compat_shape.xml +9 -0
  57. data/libs/crosswalk/ext/platform/android/adds/res/drawable/color_button_background.xml +36 -0
  58. data/libs/crosswalk/ext/platform/android/adds/res/drawable/color_picker_advanced_select_handle.png +0 -0
  59. data/libs/crosswalk/ext/platform/android/adds/res/drawable/color_picker_border.xml +12 -0
  60. data/libs/crosswalk/ext/platform/android/adds/res/drawable/dropdown_label_color.xml +11 -0
  61. data/libs/crosswalk/ext/platform/android/adds/res/drawable/dropdown_popup_background.xml +13 -0
  62. data/libs/crosswalk/ext/platform/android/adds/res/drawable/dropdown_popup_background_down.9.png +0 -0
  63. data/libs/crosswalk/ext/platform/android/adds/res/drawable/dropdown_popup_background_up.9.png +0 -0
  64. data/libs/crosswalk/ext/platform/android/adds/res/drawable/ic_menu_share_holo_light.png +0 -0
  65. data/libs/crosswalk/ext/platform/android/adds/res/drawable/ic_search.png +0 -0
  66. data/libs/crosswalk/ext/platform/android/adds/res/drawable/ic_warning.png +0 -0
  67. data/libs/crosswalk/ext/platform/android/adds/res/drawable/launchscreen_bg.xml +19 -0
  68. data/libs/crosswalk/ext/platform/android/adds/res/drawable/ondemand_overlay.9.png +0 -0
  69. data/libs/crosswalk/ext/platform/android/adds/res/drawable/verify_checkmark.png +0 -0
  70. data/libs/crosswalk/ext/platform/android/adds/res/layout-land/date_time_picker_dialog.xml +42 -0
  71. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/autofill_keyboard_accessory_item.xml +40 -0
  72. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/autofill_suggestion_item.xml +18 -0
  73. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/color_picker_advanced_component.xml +46 -0
  74. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/color_picker_dialog_content.xml +51 -0
  75. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/color_picker_dialog_title.xml +41 -0
  76. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/date_time_suggestion.xml +35 -0
  77. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/dropdown_item.xml +58 -0
  78. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/multi_field_time_picker_dialog.xml +122 -0
  79. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/two_field_date_picker.xml +38 -0
  80. data/libs/crosswalk/ext/platform/android/adds/res/layout-v17/validation_message_bubble.xml +72 -0
  81. data/libs/crosswalk/ext/platform/android/adds/res/layout/autofill_keyboard_accessory_icon.xml +13 -0
  82. data/libs/crosswalk/ext/platform/android/adds/res/layout/autofill_keyboard_accessory_item.xml +17 -0
  83. data/libs/crosswalk/ext/platform/android/adds/res/layout/autofill_suggestion_item.xml +7 -0
  84. data/libs/crosswalk/ext/platform/android/adds/res/layout/color_picker_advanced_component.xml +30 -0
  85. data/libs/crosswalk/ext/platform/android/adds/res/layout/color_picker_dialog_content.xml +36 -0
  86. data/libs/crosswalk/ext/platform/android/adds/res/layout/color_picker_dialog_title.xml +25 -0
  87. data/libs/crosswalk/ext/platform/android/adds/res/layout/date_time_picker_dialog.xml +42 -0
  88. data/libs/crosswalk/ext/platform/android/adds/res/layout/date_time_suggestion.xml +16 -0
  89. data/libs/crosswalk/ext/platform/android/adds/res/layout/dropdown_item.xml +34 -0
  90. data/libs/crosswalk/ext/platform/android/adds/res/layout/multi_field_time_picker_dialog.xml +50 -0
  91. data/libs/crosswalk/ext/platform/android/adds/res/layout/two_field_date_picker.xml +26 -0
  92. data/libs/crosswalk/ext/platform/android/adds/res/layout/validation_message_bubble.xml +47 -0
  93. data/libs/crosswalk/ext/platform/android/adds/res/menu/select_action_menu.xml +54 -0
  94. data/libs/crosswalk/ext/platform/android/adds/res/raw/contacts_api.js +206 -0
  95. data/libs/crosswalk/ext/platform/android/adds/res/raw/device_capabilities_api.js +231 -0
  96. data/libs/crosswalk/ext/platform/android/adds/res/raw/empty.wav +0 -0
  97. data/libs/crosswalk/ext/platform/android/adds/res/raw/icudtl.dat +0 -0
  98. data/libs/crosswalk/ext/platform/android/adds/res/raw/launch_screen_api.js +9 -0
  99. data/libs/crosswalk/ext/platform/android/adds/res/raw/messaging_api.js +359 -0
  100. data/libs/crosswalk/ext/platform/android/adds/res/raw/presentation_api.js +144 -0
  101. data/libs/crosswalk/ext/platform/android/adds/res/raw/wifidirect_api.js +227 -0
  102. data/libs/crosswalk/ext/platform/android/adds/res/raw/xwalk.pak +0 -0
  103. data/libs/crosswalk/ext/platform/android/adds/res/values-am/android_content_strings.xml +15 -0
  104. data/libs/crosswalk/ext/platform/android/adds/res/values-am/android_ui_strings.xml +47 -0
  105. data/libs/crosswalk/ext/platform/android/adds/res/values-ar/android_content_strings.xml +15 -0
  106. data/libs/crosswalk/ext/platform/android/adds/res/values-ar/android_ui_strings.xml +47 -0
  107. data/libs/crosswalk/ext/platform/android/adds/res/values-bg/android_content_strings.xml +15 -0
  108. data/libs/crosswalk/ext/platform/android/adds/res/values-bg/android_ui_strings.xml +47 -0
  109. data/libs/crosswalk/ext/platform/android/adds/res/values-ca/android_content_strings.xml +15 -0
  110. data/libs/crosswalk/ext/platform/android/adds/res/values-ca/android_ui_strings.xml +47 -0
  111. data/libs/crosswalk/ext/platform/android/adds/res/values-cs/android_content_strings.xml +15 -0
  112. data/libs/crosswalk/ext/platform/android/adds/res/values-cs/android_ui_strings.xml +47 -0
  113. data/libs/crosswalk/ext/platform/android/adds/res/values-da/android_content_strings.xml +15 -0
  114. data/libs/crosswalk/ext/platform/android/adds/res/values-da/android_ui_strings.xml +47 -0
  115. data/libs/crosswalk/ext/platform/android/adds/res/values-de/android_content_strings.xml +15 -0
  116. data/libs/crosswalk/ext/platform/android/adds/res/values-de/android_ui_strings.xml +47 -0
  117. data/libs/crosswalk/ext/platform/android/adds/res/values-el/android_content_strings.xml +15 -0
  118. data/libs/crosswalk/ext/platform/android/adds/res/values-el/android_ui_strings.xml +47 -0
  119. data/libs/crosswalk/ext/platform/android/adds/res/values-en-rGB/android_content_strings.xml +15 -0
  120. data/libs/crosswalk/ext/platform/android/adds/res/values-en-rGB/android_ui_strings.xml +47 -0
  121. data/libs/crosswalk/ext/platform/android/adds/res/values-es-rUS/android_content_strings.xml +15 -0
  122. data/libs/crosswalk/ext/platform/android/adds/res/values-es-rUS/android_ui_strings.xml +47 -0
  123. data/libs/crosswalk/ext/platform/android/adds/res/values-es/android_content_strings.xml +15 -0
  124. data/libs/crosswalk/ext/platform/android/adds/res/values-es/android_ui_strings.xml +47 -0
  125. data/libs/crosswalk/ext/platform/android/adds/res/values-fa/android_content_strings.xml +15 -0
  126. data/libs/crosswalk/ext/platform/android/adds/res/values-fa/android_ui_strings.xml +47 -0
  127. data/libs/crosswalk/ext/platform/android/adds/res/values-fi/android_content_strings.xml +15 -0
  128. data/libs/crosswalk/ext/platform/android/adds/res/values-fi/android_ui_strings.xml +47 -0
  129. data/libs/crosswalk/ext/platform/android/adds/res/values-fr/android_content_strings.xml +15 -0
  130. data/libs/crosswalk/ext/platform/android/adds/res/values-fr/android_ui_strings.xml +47 -0
  131. data/libs/crosswalk/ext/platform/android/adds/res/values-hi/android_content_strings.xml +15 -0
  132. data/libs/crosswalk/ext/platform/android/adds/res/values-hi/android_ui_strings.xml +47 -0
  133. data/libs/crosswalk/ext/platform/android/adds/res/values-hr/android_content_strings.xml +15 -0
  134. data/libs/crosswalk/ext/platform/android/adds/res/values-hr/android_ui_strings.xml +47 -0
  135. data/libs/crosswalk/ext/platform/android/adds/res/values-hu/android_content_strings.xml +15 -0
  136. data/libs/crosswalk/ext/platform/android/adds/res/values-hu/android_ui_strings.xml +47 -0
  137. data/libs/crosswalk/ext/platform/android/adds/res/values-in/android_content_strings.xml +15 -0
  138. data/libs/crosswalk/ext/platform/android/adds/res/values-in/android_ui_strings.xml +47 -0
  139. data/libs/crosswalk/ext/platform/android/adds/res/values-it/android_content_strings.xml +15 -0
  140. data/libs/crosswalk/ext/platform/android/adds/res/values-it/android_ui_strings.xml +47 -0
  141. data/libs/crosswalk/ext/platform/android/adds/res/values-iw/android_content_strings.xml +15 -0
  142. data/libs/crosswalk/ext/platform/android/adds/res/values-iw/android_ui_strings.xml +47 -0
  143. data/libs/crosswalk/ext/platform/android/adds/res/values-ja/android_content_strings.xml +15 -0
  144. data/libs/crosswalk/ext/platform/android/adds/res/values-ja/android_ui_strings.xml +47 -0
  145. data/libs/crosswalk/ext/platform/android/adds/res/values-ko/android_content_strings.xml +15 -0
  146. data/libs/crosswalk/ext/platform/android/adds/res/values-ko/android_ui_strings.xml +47 -0
  147. data/libs/crosswalk/ext/platform/android/adds/res/values-lt/android_content_strings.xml +15 -0
  148. data/libs/crosswalk/ext/platform/android/adds/res/values-lt/android_ui_strings.xml +47 -0
  149. data/libs/crosswalk/ext/platform/android/adds/res/values-lv/android_content_strings.xml +15 -0
  150. data/libs/crosswalk/ext/platform/android/adds/res/values-lv/android_ui_strings.xml +47 -0
  151. data/libs/crosswalk/ext/platform/android/adds/res/values-nb/android_content_strings.xml +15 -0
  152. data/libs/crosswalk/ext/platform/android/adds/res/values-nb/android_ui_strings.xml +47 -0
  153. data/libs/crosswalk/ext/platform/android/adds/res/values-nl/android_content_strings.xml +15 -0
  154. data/libs/crosswalk/ext/platform/android/adds/res/values-nl/android_ui_strings.xml +47 -0
  155. data/libs/crosswalk/ext/platform/android/adds/res/values-pl/android_content_strings.xml +15 -0
  156. data/libs/crosswalk/ext/platform/android/adds/res/values-pl/android_ui_strings.xml +47 -0
  157. data/libs/crosswalk/ext/platform/android/adds/res/values-pt-rBR/android_content_strings.xml +15 -0
  158. data/libs/crosswalk/ext/platform/android/adds/res/values-pt-rBR/android_ui_strings.xml +47 -0
  159. data/libs/crosswalk/ext/platform/android/adds/res/values-pt-rPT/android_content_strings.xml +15 -0
  160. data/libs/crosswalk/ext/platform/android/adds/res/values-pt-rPT/android_ui_strings.xml +47 -0
  161. data/libs/crosswalk/ext/platform/android/adds/res/values-ro/android_content_strings.xml +15 -0
  162. data/libs/crosswalk/ext/platform/android/adds/res/values-ro/android_ui_strings.xml +47 -0
  163. data/libs/crosswalk/ext/platform/android/adds/res/values-ru/android_content_strings.xml +15 -0
  164. data/libs/crosswalk/ext/platform/android/adds/res/values-ru/android_ui_strings.xml +47 -0
  165. data/libs/crosswalk/ext/platform/android/adds/res/values-sk/android_content_strings.xml +15 -0
  166. data/libs/crosswalk/ext/platform/android/adds/res/values-sk/android_ui_strings.xml +47 -0
  167. data/libs/crosswalk/ext/platform/android/adds/res/values-sl/android_content_strings.xml +15 -0
  168. data/libs/crosswalk/ext/platform/android/adds/res/values-sl/android_ui_strings.xml +47 -0
  169. data/libs/crosswalk/ext/platform/android/adds/res/values-sr/android_content_strings.xml +15 -0
  170. data/libs/crosswalk/ext/platform/android/adds/res/values-sr/android_ui_strings.xml +47 -0
  171. data/libs/crosswalk/ext/platform/android/adds/res/values-sv/android_content_strings.xml +15 -0
  172. data/libs/crosswalk/ext/platform/android/adds/res/values-sv/android_ui_strings.xml +47 -0
  173. data/libs/crosswalk/ext/platform/android/adds/res/values-sw/android_content_strings.xml +15 -0
  174. data/libs/crosswalk/ext/platform/android/adds/res/values-sw/android_ui_strings.xml +47 -0
  175. data/libs/crosswalk/ext/platform/android/adds/res/values-th/android_content_strings.xml +15 -0
  176. data/libs/crosswalk/ext/platform/android/adds/res/values-th/android_ui_strings.xml +47 -0
  177. data/libs/crosswalk/ext/platform/android/adds/res/values-tl/android_content_strings.xml +15 -0
  178. data/libs/crosswalk/ext/platform/android/adds/res/values-tl/android_ui_strings.xml +47 -0
  179. data/libs/crosswalk/ext/platform/android/adds/res/values-tr/android_content_strings.xml +15 -0
  180. data/libs/crosswalk/ext/platform/android/adds/res/values-tr/android_ui_strings.xml +47 -0
  181. data/libs/crosswalk/ext/platform/android/adds/res/values-uk/android_content_strings.xml +15 -0
  182. data/libs/crosswalk/ext/platform/android/adds/res/values-uk/android_ui_strings.xml +47 -0
  183. data/libs/crosswalk/ext/platform/android/adds/res/values-v14/theme.xml +16 -0
  184. data/libs/crosswalk/ext/platform/android/adds/res/values-v17/styles.xml +19 -0
  185. data/libs/crosswalk/ext/platform/android/adds/res/values-v17/ui_java_styles.xml +41 -0
  186. data/libs/crosswalk/ext/platform/android/adds/res/values-v21/styles.xml +14 -0
  187. data/libs/crosswalk/ext/platform/android/adds/res/values-v21/ui_java_styles.xml +14 -0
  188. data/libs/crosswalk/ext/platform/android/adds/res/values-vi/android_content_strings.xml +15 -0
  189. data/libs/crosswalk/ext/platform/android/adds/res/values-vi/android_ui_strings.xml +47 -0
  190. data/libs/crosswalk/ext/platform/android/adds/res/values-zh-rCN/android_content_strings.xml +15 -0
  191. data/libs/crosswalk/ext/platform/android/adds/res/values-zh-rCN/android_ui_strings.xml +47 -0
  192. data/libs/crosswalk/ext/platform/android/adds/res/values-zh-rTW/android_content_strings.xml +15 -0
  193. data/libs/crosswalk/ext/platform/android/adds/res/values-zh-rTW/android_ui_strings.xml +47 -0
  194. data/libs/crosswalk/ext/platform/android/adds/res/values/android_content_strings.xml +15 -0
  195. data/libs/crosswalk/ext/platform/android/adds/res/values/android_ui_strings.xml +47 -0
  196. data/libs/crosswalk/ext/platform/android/adds/res/values/android_xwalk_strings.xml +17 -0
  197. data/libs/crosswalk/ext/platform/android/adds/res/values/ui_java_attrs.xml +9 -0
  198. data/libs/crosswalk/ext/platform/android/adds/res/values/ui_java_dimens.xml +31 -0
  199. data/libs/crosswalk/ext/platform/android/adds/res/values/ui_java_strings.xml +16 -0
  200. data/libs/crosswalk/ext/platform/android/adds/res/values/ui_java_styles.xml +101 -0
  201. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_app_strings.xml +28 -0
  202. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_attrs.xml +11 -0
  203. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_colors.xml +13 -0
  204. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_core_internal_java_strings.xml +16 -0
  205. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_core_java_strings.xml +16 -0
  206. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_dimens.xml +11 -0
  207. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_resources_list.xml +7 -0
  208. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_styles.xml +40 -0
  209. data/libs/crosswalk/ext/platform/android/adds/res/values/xwalk_values.xml +10 -0
  210. data/libs/crosswalk/ext/platform/android/ext_java.files +14 -0
  211. data/libs/crosswalk/ext/platform/android/ext_native.files +7 -0
  212. data/libs/crosswalk/ext/platform/android/jni/Crosswalk_impl.cpp +61 -0
  213. data/libs/crosswalk/ext/platform/android/src/com/rho/crosswalk/Crosswalk.java +14 -0
  214. data/libs/crosswalk/ext/platform/android/src/com/rho/crosswalk/CrosswalkFactory.java +18 -0
  215. data/libs/crosswalk/ext/platform/android/src/com/rho/crosswalk/CrosswalkSingleton.java +24 -0
  216. data/libs/crosswalk/ext/platform/android/src/com/tautechnologies/tau/crosswalk/CrosswalkExtension.java +16 -0
  217. data/libs/crosswalk/ext/platform/android/src/com/tautechnologies/tau/crosswalk/RhodesListener.java +18 -0
  218. data/libs/crosswalk/ext/platform/android/src/com/tautechnologies/tau/crosswalk/TauXWResourceClient.java +182 -0
  219. data/libs/crosswalk/ext/platform/android/src/com/tautechnologies/tau/crosswalk/TauXWUIClient.java +125 -0
  220. data/libs/crosswalk/ext/platform/android/src/com/tautechnologies/tau/crosswalk/TauXWalkWebView.java +368 -0
  221. data/libs/crosswalk/ext/platform/iphone/Crosswalk.xcodeproj/project.pbxproj +368 -0
  222. data/libs/crosswalk/ext/platform/iphone/Crosswalk_Prefix.pch +7 -0
  223. data/libs/crosswalk/ext/platform/iphone/Rakefile +73 -0
  224. data/libs/crosswalk/ext/platform/iphone/impl/Crosswalk.h +14 -0
  225. data/libs/crosswalk/ext/platform/iphone/impl/Crosswalk.m +24 -0
  226. data/libs/crosswalk/ext/platform/iphone/impl/CrosswalkFactorySingleton.m +16 -0
  227. data/libs/crosswalk/ext/platform/iphone/impl/CrosswalkSetup.m +9 -0
  228. data/libs/crosswalk/ext/platform/iphone/impl/CrosswalkSingleton.h +17 -0
  229. data/libs/crosswalk/ext/platform/iphone/impl/CrosswalkSingleton.m +23 -0
  230. data/libs/crosswalk/ext/platform/iphone/impl/readme.txt +7 -0
  231. data/libs/crosswalk/ext/platform/qt/Crosswalk.pro +66 -0
  232. data/libs/crosswalk/ext/platform/qt/Rakefile +35 -0
  233. data/libs/crosswalk/ext/platform/qt/src/Crosswalk_impl.cpp +77 -0
  234. data/libs/crosswalk/ext/platform/wm/Crosswalk.sln +52 -0
  235. data/libs/crosswalk/ext/platform/wm/Crosswalk.vcproj +714 -0
  236. data/libs/crosswalk/ext/platform/wm/Crosswalk.vsprops +15 -0
  237. data/libs/crosswalk/ext/platform/wm/src/Crosswalk_impl.cpp +77 -0
  238. data/libs/crosswalk/ext/platform/wp8/Crosswalk.props +18 -0
  239. data/libs/crosswalk/ext/platform/wp8/Crosswalk.vcxproj +170 -0
  240. data/libs/crosswalk/ext/platform/wp8/Crosswalk.vcxproj.filters +50 -0
  241. data/libs/crosswalk/ext/platform/wp8/CrosswalkImpl.csproj +119 -0
  242. data/libs/crosswalk/ext/platform/wp8/CrosswalkImpl.props +8 -0
  243. data/libs/crosswalk/ext/platform/wp8/CrosswalkImpl.targets +7 -0
  244. data/libs/crosswalk/ext/platform/wp8/CrosswalkLib.props +18 -0
  245. data/libs/crosswalk/ext/platform/wp8/CrosswalkLib.vcxproj +185 -0
  246. data/libs/crosswalk/ext/platform/wp8/CrosswalkLib.vcxproj.filters +58 -0
  247. data/libs/crosswalk/ext/platform/wp8/src/Crosswalk_impl.cpp +76 -0
  248. data/libs/crosswalk/ext/platform/wp8/src/Crosswalk_impl.cs +69 -0
  249. data/libs/crosswalk/ext/platform/wp8/src/Properties/AssemblyInfo.cs +37 -0
  250. data/libs/enterprise-barcode/ext.yml +13 -0
  251. data/libs/enterprise-barcode/ext/barcode.xml +2144 -0
  252. data/libs/enterprise-barcode/ext/build +17 -0
  253. data/libs/enterprise-barcode/ext/build.bat +29 -0
  254. data/libs/enterprise-barcode/ext/platform/android/AndroidManifest.xml +31 -0
  255. data/libs/enterprise-barcode/ext/platform/android/ZXing_Info/AUTHORS +58 -0
  256. data/libs/enterprise-barcode/ext/platform/android/ZXing_Info/CHANGES +266 -0
  257. data/libs/enterprise-barcode/ext/platform/android/ZXing_Info/COPYING +201 -0
  258. data/libs/enterprise-barcode/ext/platform/android/ZXing_Info/README +11 -0
  259. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/drawable-hdpi/cancel_icon.png +0 -0
  260. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/drawable-hdpi/ok_icon.png +0 -0
  261. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/drawable-hdpi/retake_icon.png +0 -0
  262. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/drawable/cancel_icon.png +0 -0
  263. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/drawable/ok_icon.png +0 -0
  264. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/drawable/retake_icon.png +0 -0
  265. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/layout/capture.xml +122 -0
  266. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/raw/beep.ogg +0 -0
  267. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/values/attrs.xml +20 -0
  268. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/values/colors.xml +42 -0
  269. data/libs/enterprise-barcode/ext/platform/android/additional_files/res/values/ids.xml +31 -0
  270. data/libs/enterprise-barcode/ext/platform/android/adds/lib/armeabi/liballbarcode.a +0 -0
  271. data/libs/enterprise-barcode/ext/platform/android/adds/lib/x86/liballbarcode.a +0 -0
  272. data/libs/enterprise-barcode/ext/platform/android/allbarcode.jar +0 -0
  273. data/libs/enterprise-barcode/ext/platform/iphone/Barcode.xcodeproj/project.pbxproj +524 -0
  274. data/libs/enterprise-barcode/ext/platform/iphone/Barcode_Prefix.pch +7 -0
  275. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeCallbackHelper.h +27 -0
  276. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeCallbackHelper.mm +231 -0
  277. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeViewController.h +95 -0
  278. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeViewController.m +1017 -0
  279. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeViewFactory.h +7 -0
  280. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeViewFactory.mm +58 -0
  281. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeViewFactoryRegister.mm +18 -0
  282. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeViewManager.h +16 -0
  283. data/libs/enterprise-barcode/ext/platform/iphone/Classes/BarcodeViewManager.mm +32 -0
  284. data/libs/enterprise-barcode/ext/platform/iphone/Classes/ImageProvider.cpp +25 -0
  285. data/libs/enterprise-barcode/ext/platform/iphone/Classes/ImageProvider.h +15 -0
  286. data/libs/enterprise-barcode/ext/platform/iphone/Classes/ImageProvider.mm +159 -0
  287. data/libs/enterprise-barcode/ext/platform/iphone/Classes/barcode.m +123 -0
  288. data/libs/enterprise-barcode/ext/platform/iphone/Rakefile +69 -0
  289. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/COPYING +27 -0
  290. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarCameraSimulator.h +45 -0
  291. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarCaptureReader.h +111 -0
  292. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarHelpController.h +60 -0
  293. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarImage.h +69 -0
  294. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarImageScanner.h +51 -0
  295. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarReaderController.h +142 -0
  296. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarReaderView.h +135 -0
  297. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarReaderViewController.h +130 -0
  298. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarSDK.h +34 -0
  299. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarSymbol.h +71 -0
  300. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar.h +1497 -0
  301. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Decoder.h +202 -0
  302. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Exception.h +187 -0
  303. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Image.h +321 -0
  304. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/ImageScanner.h +130 -0
  305. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Processor.h +223 -0
  306. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Scanner.h +162 -0
  307. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Symbol.h +528 -0
  308. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Video.h +170 -0
  309. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Window.h +136 -0
  310. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/LICENSE +504 -0
  311. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/README +59 -0
  312. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Resources/zbar-back.png +0 -0
  313. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Resources/zbar-help.html +88 -0
  314. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Resources/zbar-helpicons.png +0 -0
  315. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/Resources/zbar-samples.png +0 -0
  316. data/libs/enterprise-barcode/ext/platform/iphone/ZBarSDK/libzbar.a +0 -0
  317. data/libs/enterprise-barcode/ext/platform/iphone/impl/Barcode.h +21 -0
  318. data/libs/enterprise-barcode/ext/platform/iphone/impl/Barcode.m +132 -0
  319. data/libs/enterprise-barcode/ext/platform/iphone/impl/BarcodeFactory.h +10 -0
  320. data/libs/enterprise-barcode/ext/platform/iphone/impl/BarcodeFactory.m +16 -0
  321. data/libs/enterprise-barcode/ext/platform/iphone/impl/BarcodeFactorySingleton.m +16 -0
  322. data/libs/enterprise-barcode/ext/platform/iphone/impl/BarcodeSetup.m +8 -0
  323. data/libs/enterprise-barcode/ext/platform/iphone/impl/BarcodeSingleton.h +17 -0
  324. data/libs/enterprise-barcode/ext/platform/iphone/impl/BarcodeSingleton.m +22 -0
  325. data/libs/enterprise-barcode/ext/platform/iphone/impl/readme.txt +7 -0
  326. data/libs/enterprise-barcode/ext/platform/wm/Barcode.sln +44 -0
  327. data/libs/enterprise-barcode/ext/platform/wm/Barcode.vcproj +836 -0
  328. data/libs/enterprise-barcode/ext/platform/wm/Barcode.vsprops +15 -0
  329. data/libs/enterprise-barcode/ext/platform/wm/readme.txt +0 -0
  330. data/libs/enterprise-barcode/ext/platform/wm/src/Barcode_impl.cpp +376 -0
  331. data/libs/enterprise-barcode/ext/platform/wm/src/DecodeNotifier.cpp +173 -0
  332. data/libs/enterprise-barcode/ext/platform/wm/src/DecodeNotifier.h +149 -0
  333. data/libs/enterprise-barcode/ext/platform/wm/src/EMDKInterfaceAbstraction.cpp +476 -0
  334. data/libs/enterprise-barcode/ext/platform/wm/src/GetDecoderProperties.cpp +1195 -0
  335. data/libs/enterprise-barcode/ext/platform/wm/src/GetScannerProperties.cpp +553 -0
  336. data/libs/enterprise-barcode/ext/platform/wm/src/KeyInjector.cpp +177 -0
  337. data/libs/enterprise-barcode/ext/platform/wm/src/KeyInjector.h +40 -0
  338. data/libs/enterprise-barcode/ext/platform/wm/src/NotificationLoader.cpp +76 -0
  339. data/libs/enterprise-barcode/ext/platform/wm/src/NotificationLoader.h +44 -0
  340. data/libs/enterprise-barcode/ext/platform/wm/src/RSM.cpp +1211 -0
  341. data/libs/enterprise-barcode/ext/platform/wm/src/Scanner.cpp +2609 -0
  342. data/libs/enterprise-barcode/ext/platform/wm/src/Scanner.h +1099 -0
  343. data/libs/enterprise-barcode/ext/platform/wm/src/ScannerDefines.h +322 -0
  344. data/libs/enterprise-barcode/ext/platform/wm/src/SetDecoderProperties.cpp +2106 -0
  345. data/libs/enterprise-barcode/ext/platform/wm/src/SetScannerProperties.cpp +1060 -0
  346. data/libs/enterprise-barcode/ext/platform/wm/src/Utilities.cpp +184 -0
  347. data/libs/enterprise-barcode/ext/platform/wp8/BarcodeImpl.csproj +119 -0
  348. data/libs/enterprise-barcode/ext/platform/wp8/BarcodeImpl.props +8 -0
  349. data/libs/enterprise-barcode/ext/platform/wp8/BarcodeImpl.targets +35 -0
  350. data/libs/enterprise-barcode/ext/platform/wp8/BarcodeLib.props +18 -0
  351. data/libs/enterprise-barcode/ext/platform/wp8/BarcodeLib.vcxproj +185 -0
  352. data/libs/enterprise-barcode/ext/platform/wp8/BarcodeLib.vcxproj.filters +58 -0
  353. data/libs/enterprise-barcode/ext/platform/wp8/lib/ARM/Nokia.Graphics.Imaging.dll +0 -0
  354. data/libs/enterprise-barcode/ext/platform/wp8/lib/ARM/Nokia.Graphics.Imaging.winmd +0 -0
  355. data/libs/enterprise-barcode/ext/platform/wp8/lib/ARM/Nokia.Graphics.Imaging.xml +4813 -0
  356. data/libs/enterprise-barcode/ext/platform/wp8/lib/ARM/Nokia.InteropServices.WindowsRuntime.dll +0 -0
  357. data/libs/enterprise-barcode/ext/platform/wp8/lib/ARM/Nokia.InteropServices.WindowsRuntime.winmd +0 -0
  358. data/libs/enterprise-barcode/ext/platform/wp8/lib/ARM/Nokia.InteropServices.WindowsRuntime.xml +41 -0
  359. data/libs/enterprise-barcode/ext/platform/wp8/lib/ARM/OpticalReaderLib.dll +0 -0
  360. data/libs/enterprise-barcode/ext/platform/wp8/lib/BarcodeReaderLib.XML +68 -0
  361. data/libs/enterprise-barcode/ext/platform/wp8/lib/BarcodeReaderLib.dll +0 -0
  362. data/libs/enterprise-barcode/ext/platform/wp8/lib/BarcodeReaderLib/BarcodeReaderLib.csproj +120 -0
  363. data/libs/enterprise-barcode/ext/platform/wp8/lib/BarcodeReaderLib/BarcodeReaderLib.sln +34 -0
  364. data/libs/enterprise-barcode/ext/platform/wp8/lib/BarcodeReaderLib/CameraNavigatePage.xaml +32 -0
  365. data/libs/enterprise-barcode/ext/platform/wp8/lib/BarcodeReaderLib/CameraNavigatePage.xaml.cs +235 -0
  366. data/libs/enterprise-barcode/ext/platform/wp8/lib/BarcodeReaderLib/OpticalReaderTask.cs +182 -0
  367. data/libs/enterprise-barcode/ext/platform/wp8/lib/BarcodeReaderLib/Properties/AssemblyInfo.cs +37 -0
  368. data/libs/enterprise-barcode/ext/platform/wp8/lib/Nokia.Graphics.Imaging.Managed.dll +0 -0
  369. data/libs/enterprise-barcode/ext/platform/wp8/lib/Nokia.Graphics.Imaging.Managed.xml +341 -0
  370. data/libs/enterprise-barcode/ext/platform/wp8/lib/x86/Nokia.Graphics.Imaging.dll +0 -0
  371. data/libs/enterprise-barcode/ext/platform/wp8/lib/x86/Nokia.Graphics.Imaging.winmd +0 -0
  372. data/libs/enterprise-barcode/ext/platform/wp8/lib/x86/Nokia.Graphics.Imaging.xml +4813 -0
  373. data/libs/enterprise-barcode/ext/platform/wp8/lib/x86/Nokia.InteropServices.WindowsRuntime.dll +0 -0
  374. data/libs/enterprise-barcode/ext/platform/wp8/lib/x86/Nokia.InteropServices.WindowsRuntime.winmd +0 -0
  375. data/libs/enterprise-barcode/ext/platform/wp8/lib/x86/Nokia.InteropServices.WindowsRuntime.xml +41 -0
  376. data/libs/enterprise-barcode/ext/platform/wp8/lib/x86/OpticalReaderLib.dll +0 -0
  377. data/libs/enterprise-barcode/ext/platform/wp8/lib/zxing.wp8.0.XML +10324 -0
  378. data/libs/enterprise-barcode/ext/platform/wp8/lib/zxing.wp8.0.dll +0 -0
  379. data/libs/enterprise-barcode/ext/platform/wp8/src/Barcode_impl.cs +630 -0
  380. data/libs/enterprise-barcode/ext/platform/wp8/src/Properties/AssemblyInfo.cs +37 -0
  381. data/libs/enterprise-barcode/public/api/generated/Rho.Barcode.js +772 -0
  382. data/libs/ie/rhobrowser.dll +0 -0
  383. data/libs/nodejs.rb +2 -0
  384. data/libs/nodejs/ext.yml +25 -0
  385. data/libs/nodejs/ext/Nodejs.xml +37 -0
  386. data/libs/nodejs/ext/build +19 -0
  387. data/libs/nodejs/ext/build.bat +29 -0
  388. data/libs/nodejs/ext/platform/android/Rakefile +161 -0
  389. data/libs/nodejs/ext/platform/android/ext_native.files +8 -0
  390. data/libs/nodejs/ext/platform/android/jxCore/jx.h +134 -0
  391. data/libs/nodejs/ext/platform/android/jxCore/jx_result.h +221 -0
  392. data/libs/nodejs/ext/platform/android/jxCore/libcares_arm.a +0 -0
  393. data/libs/nodejs/ext/platform/android/jxCore/libcares_ia32.a +0 -0
  394. data/libs/nodejs/ext/platform/android/jxCore/libcares_x64.a +0 -0
  395. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_arm.a +0 -0
  396. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_ia32.a +0 -0
  397. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_x64.a +0 -0
  398. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_arm.a +0 -0
  399. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_ia32.a +0 -0
  400. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_x64.a +0 -0
  401. data/libs/nodejs/ext/platform/android/jxCore/libjx_arm.a +0 -0
  402. data/libs/nodejs/ext/platform/android/jxCore/libjx_ia32.a +0 -0
  403. data/libs/nodejs/ext/platform/android/jxCore/libjx_x64.a +0 -0
  404. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_arm.a +0 -0
  405. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_ia32.a +0 -0
  406. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_x64.a +0 -0
  407. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_arm.a +0 -0
  408. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_ia32.a +0 -0
  409. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_x64.a +0 -0
  410. data/libs/nodejs/ext/platform/android/jxCore/libuv_arm.a +0 -0
  411. data/libs/nodejs/ext/platform/android/jxCore/libuv_ia32.a +0 -0
  412. data/libs/nodejs/ext/platform/android/jxCore/libuv_x64.a +0 -0
  413. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_arm.a +0 -0
  414. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_ia32.a +0 -0
  415. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_x64.a +0 -0
  416. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_arm.a +0 -0
  417. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_ia32.a +0 -0
  418. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_x64.a +0 -0
  419. data/libs/nodejs/ext/platform/iphone/Nodejs.xcodeproj/project.pbxproj +350 -0
  420. data/libs/nodejs/ext/platform/iphone/Nodejs_Prefix.pch +7 -0
  421. data/libs/nodejs/ext/platform/iphone/Rakefile +73 -0
  422. data/libs/nodejs/ext/platform/iphone/jxCore/jx.h +134 -0
  423. data/libs/nodejs/ext/platform/iphone/jxCore/jx_result.h +221 -0
  424. data/libs/nodejs/ext/platform/iphone/jxCore/libcares.a +0 -0
  425. data/libs/nodejs/ext/platform/iphone/jxCore/libchrome_zlib.a +0 -0
  426. data/libs/nodejs/ext/platform/iphone/jxCore/libhttp_parser.a +0 -0
  427. data/libs/nodejs/ext/platform/iphone/jxCore/libjx.a +0 -0
  428. data/libs/nodejs/ext/platform/iphone/jxCore/libmozjs.a +0 -0
  429. data/libs/nodejs/ext/platform/iphone/jxCore/libopenssl.a +0 -0
  430. data/libs/nodejs/ext/platform/iphone/jxCore/libsqlite3.a +0 -0
  431. data/libs/nodejs/ext/platform/iphone/jxCore/libuv.a +0 -0
  432. data/libs/nodejs/ext/shared/jxcore/jx.h +134 -0
  433. data/libs/nodejs/ext/shared/jxcore/jx_result.h +221 -0
  434. data/libs/nodejs/ext/shared/jxcoretau.cpp +454 -0
  435. data/libs/nodejs/ext/shared/jxcoretau.h +20 -0
  436. data/libs/nodejs/ext/shared/nodejs_impl.cpp +106 -0
  437. data/libs/nodejs/nodejs.rb +2 -0
  438. data/libs/openssl-edge.rb +2 -0
  439. data/libs/openssl-edge/ext.yml +4 -0
  440. data/libs/openssl-edge/ext/Rakefile +145 -0
  441. data/libs/openssl-edge/ext/android/Rakefile +107 -0
  442. data/libs/openssl-edge/ext/android/ext_native.files +32 -0
  443. data/libs/openssl-edge/ext/android/extconf.h +91 -0
  444. data/libs/openssl-edge/ext/build +12 -0
  445. data/libs/openssl-edge/ext/build.bat +5 -0
  446. data/libs/openssl-edge/ext/extconf.rb +141 -0
  447. data/libs/openssl-edge/ext/openssl.pro +109 -0
  448. data/libs/openssl-edge/ext/openssl.sln +52 -0
  449. data/libs/openssl-edge/ext/openssl.vcproj +1010 -0
  450. data/libs/openssl-edge/ext/openssl_missing.c +1163 -0
  451. data/libs/openssl-edge/ext/openssl_missing.h +537 -0
  452. data/libs/openssl-edge/ext/ossl.c +1203 -0
  453. data/libs/openssl-edge/ext/ossl.h +242 -0
  454. data/libs/openssl-edge/ext/ossl_asn1.c +2008 -0
  455. data/libs/openssl-edge/ext/ossl_asn1.h +66 -0
  456. data/libs/openssl-edge/ext/ossl_bio.c +118 -0
  457. data/libs/openssl-edge/ext/ossl_bio.h +19 -0
  458. data/libs/openssl-edge/ext/ossl_bn.c +1153 -0
  459. data/libs/openssl-edge/ext/ossl_bn.h +23 -0
  460. data/libs/openssl-edge/ext/ossl_cipher.c +1085 -0
  461. data/libs/openssl-edge/ext/ossl_cipher.h +20 -0
  462. data/libs/openssl-edge/ext/ossl_config.c +89 -0
  463. data/libs/openssl-edge/ext/ossl_config.h +19 -0
  464. data/libs/openssl-edge/ext/ossl_digest.c +453 -0
  465. data/libs/openssl-edge/ext/ossl_digest.h +20 -0
  466. data/libs/openssl-edge/ext/ossl_engine.c +580 -0
  467. data/libs/openssl-edge/ext/ossl_engine.h +19 -0
  468. data/libs/openssl-edge/ext/ossl_hmac.c +398 -0
  469. data/libs/openssl-edge/ext/ossl_hmac.h +18 -0
  470. data/libs/openssl-edge/ext/ossl_ns_spki.c +406 -0
  471. data/libs/openssl-edge/ext/ossl_ns_spki.h +19 -0
  472. data/libs/openssl-edge/ext/ossl_ocsp.c +2013 -0
  473. data/libs/openssl-edge/ext/ossl_ocsp.h +23 -0
  474. data/libs/openssl-edge/ext/ossl_pkcs12.c +261 -0
  475. data/libs/openssl-edge/ext/ossl_pkcs12.h +13 -0
  476. data/libs/openssl-edge/ext/ossl_pkcs5.c +180 -0
  477. data/libs/openssl-edge/ext/ossl_pkcs5.h +6 -0
  478. data/libs/openssl-edge/ext/ossl_pkcs7.c +1157 -0
  479. data/libs/openssl-edge/ext/ossl_pkcs7.h +20 -0
  480. data/libs/openssl-edge/ext/ossl_pkey.c +469 -0
  481. data/libs/openssl-edge/ext/ossl_pkey.h +245 -0
  482. data/libs/openssl-edge/ext/ossl_pkey_dh.c +650 -0
  483. data/libs/openssl-edge/ext/ossl_pkey_dsa.c +672 -0
  484. data/libs/openssl-edge/ext/ossl_pkey_ec.c +1806 -0
  485. data/libs/openssl-edge/ext/ossl_pkey_rsa.c +768 -0
  486. data/libs/openssl-edge/ext/ossl_rand.c +238 -0
  487. data/libs/openssl-edge/ext/ossl_rand.h +18 -0
  488. data/libs/openssl-edge/ext/ossl_ssl.c +2724 -0
  489. data/libs/openssl-edge/ext/ossl_ssl.h +41 -0
  490. data/libs/openssl-edge/ext/ossl_ssl_session.c +352 -0
  491. data/libs/openssl-edge/ext/ossl_version.h +15 -0
  492. data/libs/openssl-edge/ext/ossl_x509.c +186 -0
  493. data/libs/openssl-edge/ext/ossl_x509.h +119 -0
  494. data/libs/openssl-edge/ext/ossl_x509attr.c +328 -0
  495. data/libs/openssl-edge/ext/ossl_x509cert.c +863 -0
  496. data/libs/openssl-edge/ext/ossl_x509crl.c +565 -0
  497. data/libs/openssl-edge/ext/ossl_x509ext.c +480 -0
  498. data/libs/openssl-edge/ext/ossl_x509name.c +547 -0
  499. data/libs/openssl-edge/ext/ossl_x509req.c +492 -0
  500. data/libs/openssl-edge/ext/ossl_x509revoked.c +279 -0
  501. data/libs/openssl-edge/ext/ossl_x509store.c +846 -0
  502. data/libs/openssl-edge/ext/ruby_missing.h +32 -0
  503. data/libs/openssl-edge/openssl-edge.rb +2 -0
  504. data/libs/openssl-edge/openssl.rb +24 -0
  505. data/libs/openssl-edge/openssl/bn.rb +35 -0
  506. data/libs/openssl-edge/openssl/buffering.rb +341 -0
  507. data/libs/openssl-edge/openssl/cipher.rb +65 -0
  508. data/libs/openssl-edge/openssl/digest.rb +61 -0
  509. data/libs/openssl-edge/openssl/ssl-internal.rb +180 -0
  510. data/libs/openssl-edge/openssl/ssl.rb +1 -0
  511. data/libs/openssl-edge/openssl/x509-internal.rb +153 -0
  512. data/libs/openssl-edge/openssl/x509.rb +1 -0
  513. data/libs/openssl.so-edge.rb +2 -0
  514. data/libs/openssl.so-edge/ext.yml +8 -0
  515. data/libs/openssl.so-edge/ext/Rakefile +140 -0
  516. data/libs/openssl.so-edge/ext/android/armeabi/libcrypto.a +0 -0
  517. data/libs/openssl.so-edge/ext/android/armeabi/libssl.a +0 -0
  518. data/libs/openssl.so-edge/ext/android/x86/libcrypto.a +0 -0
  519. data/libs/openssl.so-edge/ext/android/x86/libssl.a +0 -0
  520. data/libs/openssl.so-edge/ext/build +12 -0
  521. data/libs/openssl.so-edge/ext/build.bat +1 -0
  522. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/dh/dh_locl.h +56 -0
  523. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/dsa/dsa_locl.h +76 -0
  524. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/evp/evp_locl.h +66 -0
  525. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/hmac/hmac_lcl.h +33 -0
  526. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/asn1_int.h +94 -0
  527. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/async.h +14 -0
  528. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/bn_conf.h +28 -0
  529. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/bn_dh.h +17 -0
  530. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/bn_int.h +82 -0
  531. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/bn_srp.h +32 -0
  532. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/chacha.h +49 -0
  533. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/cryptlib.h +81 -0
  534. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/cryptlib_int.h +31 -0
  535. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/dso_conf.h +16 -0
  536. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/engine.h +20 -0
  537. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/err_int.h +17 -0
  538. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/evp_int.h +382 -0
  539. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/md32_common.h +383 -0
  540. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/objects.h +12 -0
  541. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/poly1305.h +19 -0
  542. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/rand.h +20 -0
  543. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/include/internal/x509_int.h +267 -0
  544. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/ocsp/ocsp_lcl.h +216 -0
  545. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/rsa/rsa_locl.h +96 -0
  546. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/crypto/x509/x509_lcl.h +142 -0
  547. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/e_os.h +520 -0
  548. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/bio.h +26 -0
  549. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/comp.h +12 -0
  550. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/conf.h +32 -0
  551. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/constant_time_locl.h +185 -0
  552. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/dane.h +103 -0
  553. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/dso.h +216 -0
  554. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/err.h +15 -0
  555. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/numbers.h +68 -0
  556. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/o_dir.h +63 -0
  557. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/o_str.h +17 -0
  558. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/internal/thread_once.h +42 -0
  559. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/__DECC_INCLUDE_EPILOGUE.H +16 -0
  560. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/__DECC_INCLUDE_PROLOGUE.H +20 -0
  561. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/aes.h +92 -0
  562. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/asn1.h +1096 -0
  563. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/asn1_mac.h +10 -0
  564. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/asn1t.h +924 -0
  565. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/async.h +98 -0
  566. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/bio.h +854 -0
  567. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/blowfish.h +61 -0
  568. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/bn.h +575 -0
  569. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/buffer.h +76 -0
  570. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/camellia.h +83 -0
  571. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/cast.h +53 -0
  572. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/cmac.h +41 -0
  573. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/cms.h +512 -0
  574. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/comp.h +72 -0
  575. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/conf.h +216 -0
  576. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/conf_api.h +40 -0
  577. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/crypto.h +463 -0
  578. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ct.h +518 -0
  579. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/des.h +174 -0
  580. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/dh.h +343 -0
  581. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/dsa.h +282 -0
  582. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/dtls1.h +56 -0
  583. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/e_os2.h +311 -0
  584. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ebcdic.h +33 -0
  585. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ec.h +1581 -0
  586. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ecdh.h +10 -0
  587. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ecdsa.h +10 -0
  588. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/engine.h +842 -0
  589. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/err.h +259 -0
  590. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/evp.h +1586 -0
  591. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/hmac.h +49 -0
  592. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/idea.h +64 -0
  593. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/kdf.h +75 -0
  594. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/lhash.h +204 -0
  595. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/md2.h +44 -0
  596. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/md4.h +51 -0
  597. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/md5.h +50 -0
  598. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/mdc2.h +42 -0
  599. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/modes.h +203 -0
  600. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/obj_mac.h +4577 -0
  601. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/objects.h +1097 -0
  602. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ocsp.h +409 -0
  603. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/opensslconf.h +169 -0
  604. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/opensslconf.h.in +141 -0
  605. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/opensslv.h +105 -0
  606. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ossl_typ.h +190 -0
  607. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/pem.h +501 -0
  608. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/pem2.h +20 -0
  609. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/pkcs12.h +282 -0
  610. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/pkcs7.h +404 -0
  611. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/rand.h +89 -0
  612. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/rc2.h +51 -0
  613. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/rc4.h +36 -0
  614. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/rc5.h +63 -0
  615. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ripemd.h +47 -0
  616. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/rsa.h +588 -0
  617. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/safestack.h +164 -0
  618. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/seed.h +98 -0
  619. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/sha.h +119 -0
  620. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/srp.h +131 -0
  621. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/srtp.h +50 -0
  622. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ssl.h +2527 -0
  623. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ssl2.h +24 -0
  624. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ssl3.h +307 -0
  625. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/stack.h +78 -0
  626. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/symhacks.h +52 -0
  627. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/tls1.h +972 -0
  628. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ts.h +643 -0
  629. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/txt_db.h +57 -0
  630. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/ui.h +368 -0
  631. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/whrlpool.h +48 -0
  632. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/x509.h +1123 -0
  633. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/x509_vfy.h +539 -0
  634. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/openssl/x509v3.h +1005 -0
  635. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/ssl/packet_locl.h +555 -0
  636. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/ssl/record/record.h +240 -0
  637. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/ssl/record/record_locl.h +114 -0
  638. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/ssl/ssl_locl.h +2127 -0
  639. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/ssl/statem/statem.h +123 -0
  640. data/libs/openssl.so-edge/ext/openssl-1-1-0-stable/include/ssl/statem/statem_locl.h +124 -0
  641. data/libs/openssl.so-edge/openssl.so.rb +2 -0
  642. data/libs/webkit.rb +2 -0
  643. data/libs/webkit/ext.yml +4 -0
  644. data/libs/webkit/ext/build +12 -0
  645. data/libs/webkit/ext/build.bat +7 -0
  646. data/libs/webkit/ext/wm/Rakefile +61 -0
  647. data/libs/webkit/ext/wm/RhoMsgs.cpp +17 -0
  648. data/libs/webkit/ext/wm/RhoMsgs.h +14 -0
  649. data/libs/webkit/ext/wm/RhoWKBrowserEngine.cpp +736 -0
  650. data/libs/webkit/ext/wm/RhoWKBrowserEngine.h +105 -0
  651. data/libs/webkit/ext/wm/lib/npapi/rhobridge.dll +0 -0
  652. data/libs/webkit/ext/wm/lib/rhoengine_defs.h +80 -0
  653. data/libs/webkit/ext/wm/lib/rhowebkit.dll +0 -0
  654. data/libs/webkit/ext/wm/webkit.sln +36 -0
  655. data/libs/webkit/ext/wm/webkit.suo +0 -0
  656. data/libs/webkit/ext/wm/webkit.vcproj +800 -0
  657. data/libs/webkit/ext/wm/webkit.vsprops +20 -0
  658. data/libs/webkit/webkit.rb +2 -0
  659. data/rho-tau-extensions.gemspec +23 -0
  660. data/version +1 -0
  661. metadata +705 -0
@@ -0,0 +1,242 @@
1
+ /*
2
+ * 'OpenSSL for Ruby' project
3
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
4
+ * All rights reserved.
5
+ */
6
+ /*
7
+ * This program is licensed under the same licence as Ruby.
8
+ * (See the file 'LICENCE'.)
9
+ */
10
+ #if !defined(_OSSL_H_)
11
+ #define _OSSL_H_
12
+
13
+
14
+ //TAU
15
+ #if defined(WIN32) || defined (WINCE)
16
+ #include "windows/extconf.h"
17
+ #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
18
+ #include <TargetConditionals.h>
19
+
20
+ #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
21
+
22
+ #include "iphone/extconf.h"
23
+
24
+ #else
25
+ #include "macosx/extconf.h"
26
+ #endif
27
+ #elif defined(ANDROID)
28
+ #include "android/extconf.h"
29
+ #endif
30
+ //TAU
31
+
32
+
33
+ #if 0
34
+ mOSSL = rb_define_module("OpenSSL");
35
+ mX509 = rb_define_module_under(mOSSL, "X509");
36
+ #endif
37
+
38
+ /*
39
+ * OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!
40
+ */
41
+ #if defined(RFILE) /*&& !defined(OSSL_DEBUG)*/
42
+ # undef RFILE
43
+ #endif
44
+ #include <ruby.h>
45
+ #include <ruby/io.h>
46
+
47
+ //TAU
48
+ //#include <ruby/thread.h>
49
+
50
+ #include <openssl/opensslv.h>
51
+
52
+ #ifdef HAVE_ASSERT_H
53
+ # include <assert.h>
54
+ #else
55
+ # define assert(condition)
56
+ #endif
57
+
58
+ #if defined(_WIN32) && !defined(LIBRESSL_VERSION_NUMBER)
59
+ # include <openssl/e_os2.h>
60
+ # if !defined(OPENSSL_SYS_WIN32)
61
+ # define OPENSSL_SYS_WIN32 1
62
+ # endif
63
+ # include <winsock2.h>
64
+ #endif
65
+ #include <errno.h>
66
+ #include <openssl/err.h>
67
+ #include <openssl/asn1.h>
68
+ #include <openssl/x509v3.h>
69
+ #include <openssl/ssl.h>
70
+ #include <openssl/pkcs12.h>
71
+ #include <openssl/pkcs7.h>
72
+ #include <openssl/hmac.h>
73
+ #include <openssl/rand.h>
74
+ #include <openssl/conf.h>
75
+ #include <openssl/conf_api.h>
76
+ #if !defined(_WIN32)
77
+ # include <openssl/crypto.h>
78
+ #endif
79
+ #if !defined(OPENSSL_NO_ENGINE)
80
+ # include <openssl/engine.h>
81
+ #endif
82
+ #if !defined(OPENSSL_NO_OCSP)
83
+ # include <openssl/ocsp.h>
84
+ #endif
85
+
86
+ /*
87
+ * Common Module
88
+ */
89
+ extern VALUE mOSSL;
90
+
91
+ /*
92
+ * Common Error Class
93
+ */
94
+ extern VALUE eOSSLError;
95
+
96
+ /*
97
+ * CheckTypes
98
+ */
99
+ #define OSSL_Check_Kind(obj, klass) do {\
100
+ if (!rb_obj_is_kind_of((obj), (klass))) {\
101
+ ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
102
+ rb_obj_class(obj), (klass));\
103
+ }\
104
+ } while (0)
105
+
106
+ #define OSSL_Check_Instance(obj, klass) do {\
107
+ if (!rb_obj_is_instance_of((obj), (klass))) {\
108
+ ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected instance of %"PRIsVALUE")",\
109
+ rb_obj_class(obj), (klass));\
110
+ }\
111
+ } while (0)
112
+
113
+ #define OSSL_Check_Same_Class(obj1, obj2) do {\
114
+ if (!rb_obj_is_instance_of((obj1), rb_obj_class(obj2))) {\
115
+ ossl_raise(rb_eTypeError, "wrong argument type");\
116
+ }\
117
+ } while (0)
118
+
119
+ /*
120
+ * Data Conversion
121
+ */
122
+ STACK_OF(X509) *ossl_x509_ary2sk0(VALUE);
123
+ STACK_OF(X509) *ossl_x509_ary2sk(VALUE);
124
+ STACK_OF(X509) *ossl_protect_x509_ary2sk(VALUE,int*);
125
+ VALUE ossl_x509_sk2ary(const STACK_OF(X509) *certs);
126
+ VALUE ossl_x509crl_sk2ary(const STACK_OF(X509_CRL) *crl);
127
+ VALUE ossl_x509name_sk2ary(const STACK_OF(X509_NAME) *names);
128
+ VALUE ossl_buf2str(char *buf, int len);
129
+ #define ossl_str_adjust(str, p) \
130
+ do{\
131
+ long len = RSTRING_LEN(str);\
132
+ long newlen = (long)((p) - (unsigned char*)RSTRING_PTR(str));\
133
+ assert(newlen <= len);\
134
+ rb_str_set_len((str), newlen);\
135
+ }while(0)
136
+ /*
137
+ * Convert binary string to hex string. The caller is responsible for
138
+ * ensuring out has (2 * len) bytes of capacity.
139
+ */
140
+ void ossl_bin2hex(unsigned char *in, char *out, size_t len);
141
+
142
+ /*
143
+ * Our default PEM callback
144
+ */
145
+ /* Convert the argument to String and validate the length. Note this may raise. */
146
+ VALUE ossl_pem_passwd_value(VALUE);
147
+ /* Can be casted to pem_password_cb. If a password (String) is passed as the
148
+ * "arbitrary data" (typically the last parameter of PEM_{read,write}_
149
+ * functions), uses the value. If not, but a block is given, yields to it.
150
+ * If not either, fallbacks to PEM_def_callback() which reads from stdin. */
151
+ int ossl_pem_passwd_cb(char *, int, int, void *);
152
+
153
+ /*
154
+ * Clear BIO* with this in PEM/DER fallback scenarios to avoid decoding
155
+ * errors piling up in OpenSSL::Errors
156
+ */
157
+ #define OSSL_BIO_reset(bio) do { \
158
+ (void)BIO_reset((bio)); \
159
+ ossl_clear_error(); \
160
+ } while (0)
161
+
162
+ /*
163
+ * ERRor messages
164
+ */
165
+ #define OSSL_ErrMsg() ERR_reason_error_string(ERR_get_error())
166
+ NORETURN(void ossl_raise(VALUE, const char *, ...));
167
+ VALUE ossl_exc_new(VALUE, const char *, ...);
168
+ /* Clear OpenSSL error queue. If dOSSL is set, rb_warn() them. */
169
+ void ossl_clear_error(void);
170
+
171
+ /*
172
+ * Verify callback
173
+ */
174
+ extern int ossl_store_ctx_ex_verify_cb_idx;
175
+ extern int ossl_store_ex_verify_cb_idx;
176
+
177
+ int ossl_verify_cb_call(VALUE, int, X509_STORE_CTX *);
178
+
179
+ /*
180
+ * String to DER String
181
+ */
182
+ extern ID ossl_s_to_der;
183
+ VALUE ossl_to_der(VALUE);
184
+ VALUE ossl_to_der_if_possible(VALUE);
185
+
186
+ /*
187
+ * Debug
188
+ */
189
+ extern VALUE dOSSL;
190
+
191
+ #if defined(HAVE_VA_ARGS_MACRO)
192
+ #define OSSL_Debug(...) do { \
193
+ if (dOSSL == Qtrue) { \
194
+ fprintf(stderr, "OSSL_DEBUG: "); \
195
+ fprintf(stderr, __VA_ARGS__); \
196
+ fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \
197
+ } \
198
+ } while (0)
199
+
200
+ #define OSSL_Warning(fmt, ...) do { \
201
+ OSSL_Debug((fmt), ##__VA_ARGS__); \
202
+ rb_warning((fmt), ##__VA_ARGS__); \
203
+ } while (0)
204
+
205
+ #define OSSL_Warn(fmt, ...) do { \
206
+ OSSL_Debug((fmt), ##__VA_ARGS__); \
207
+ rb_warn((fmt), ##__VA_ARGS__); \
208
+ } while (0)
209
+ #else
210
+ void ossl_debug(const char *, ...);
211
+ #define OSSL_Debug ossl_debug
212
+ #define OSSL_Warning rb_warning
213
+ #define OSSL_Warn rb_warn
214
+ #endif
215
+
216
+ /*
217
+ * Include all parts
218
+ */
219
+ #include "openssl_missing.h"
220
+ #include "ruby_missing.h"
221
+ #include "ossl_asn1.h"
222
+ #include "ossl_bio.h"
223
+ #include "ossl_bn.h"
224
+ #include "ossl_cipher.h"
225
+ #include "ossl_config.h"
226
+ #include "ossl_digest.h"
227
+ #include "ossl_hmac.h"
228
+ #include "ossl_ns_spki.h"
229
+ #include "ossl_ocsp.h"
230
+ #include "ossl_pkcs12.h"
231
+ #include "ossl_pkcs7.h"
232
+ #include "ossl_pkcs5.h"
233
+ #include "ossl_pkey.h"
234
+ #include "ossl_rand.h"
235
+ #include "ossl_ssl.h"
236
+ #include "ossl_version.h"
237
+ #include "ossl_x509.h"
238
+ #include "ossl_engine.h"
239
+
240
+ void Init_openssl(void);
241
+
242
+ #endif /* _OSSL_H_ */
@@ -0,0 +1,2008 @@
1
+ /*
2
+ * 'OpenSSL for Ruby' team members
3
+ * Copyright (C) 2003
4
+ * All rights reserved.
5
+ */
6
+ /*
7
+ * This program is licensed under the same licence as Ruby.
8
+ * (See the file 'LICENCE'.)
9
+ */
10
+ #include "ossl.h"
11
+
12
+ #if defined(HAVE_SYS_TIME_H)
13
+ # include <sys/time.h>
14
+ #elif !defined(NT) && !defined(_WIN32)
15
+ struct timeval {
16
+ long tv_sec; /* seconds */
17
+ long tv_usec; /* and microseconds */
18
+ };
19
+ #endif
20
+
21
+ static VALUE join_der(VALUE enumerable);
22
+ static VALUE ossl_asn1_decode0(unsigned char **pp, long length, long *offset,
23
+ int depth, int yield, long *num_read);
24
+ static VALUE ossl_asn1_initialize(int argc, VALUE *argv, VALUE self);
25
+ static VALUE ossl_asn1eoc_initialize(VALUE self);
26
+
27
+ /*
28
+ * DATE conversion
29
+ */
30
+ VALUE
31
+ asn1time_to_time(const ASN1_TIME *time)
32
+ {
33
+ struct tm tm;
34
+ VALUE argv[6];
35
+ int count;
36
+
37
+ if (!time || !time->data) return Qnil;
38
+ memset(&tm, 0, sizeof(struct tm));
39
+
40
+ switch (time->type) {
41
+ case V_ASN1_UTCTIME:
42
+ count = sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ",
43
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min,
44
+ &tm.tm_sec);
45
+
46
+ if (count == 5) {
47
+ tm.tm_sec = 0;
48
+ } else if (count != 6) {
49
+ ossl_raise(rb_eTypeError, "bad UTCTIME format: \"%s\"",
50
+ time->data);
51
+ }
52
+ if (tm.tm_year < 69) {
53
+ tm.tm_year += 2000;
54
+ } else {
55
+ tm.tm_year += 1900;
56
+ }
57
+ break;
58
+ case V_ASN1_GENERALIZEDTIME:
59
+ if (sscanf((const char *)time->data, "%4d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
60
+ &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
61
+ ossl_raise(rb_eTypeError, "bad GENERALIZEDTIME format" );
62
+ }
63
+ break;
64
+ default:
65
+ rb_warning("unknown time format");
66
+ return Qnil;
67
+ }
68
+ argv[0] = INT2NUM(tm.tm_year);
69
+ argv[1] = INT2NUM(tm.tm_mon);
70
+ argv[2] = INT2NUM(tm.tm_mday);
71
+ argv[3] = INT2NUM(tm.tm_hour);
72
+ argv[4] = INT2NUM(tm.tm_min);
73
+ argv[5] = INT2NUM(tm.tm_sec);
74
+
75
+ return rb_funcall2(rb_cTime, rb_intern("utc"), 6, argv);
76
+ }
77
+
78
+ #if defined(HAVE_ASN1_TIME_ADJ)
79
+ void
80
+ ossl_time_split(VALUE time, time_t *sec, int *days)
81
+ {
82
+ VALUE num = rb_Integer(time);
83
+
84
+ if (FIXNUM_P(num)) {
85
+ time_t t = FIX2LONG(num);
86
+ *sec = t % 86400;
87
+ *days = rb_long2int(t / 86400);
88
+ }
89
+ else {
90
+ *days = NUM2INT(rb_funcall(num, rb_intern("/"), 1, INT2FIX(86400)));
91
+ *sec = NUM2TIMET(rb_funcall(num, rb_intern("%"), 1, INT2FIX(86400)));
92
+ }
93
+ }
94
+ #else
95
+ time_t
96
+ time_to_time_t(VALUE time)
97
+ {
98
+ return (time_t)NUM2TIMET(rb_Integer(time));
99
+ }
100
+ #endif
101
+
102
+ /*
103
+ * STRING conversion
104
+ */
105
+ VALUE
106
+ asn1str_to_str(const ASN1_STRING *str)
107
+ {
108
+ return rb_str_new((const char *)str->data, str->length);
109
+ }
110
+
111
+ /*
112
+ * ASN1_INTEGER conversions
113
+ * TODO: Make a decision what's the right way to do this.
114
+ */
115
+ #define DO_IT_VIA_RUBY 0
116
+ VALUE
117
+ asn1integer_to_num(const ASN1_INTEGER *ai)
118
+ {
119
+ BIGNUM *bn;
120
+ #if DO_IT_VIA_RUBY
121
+ char *txt;
122
+ #endif
123
+ VALUE num;
124
+
125
+ if (!ai) {
126
+ ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
127
+ }
128
+ if (ai->type == V_ASN1_ENUMERATED)
129
+ /* const_cast: workaround for old OpenSSL */
130
+ bn = ASN1_ENUMERATED_to_BN((ASN1_ENUMERATED *)ai, NULL);
131
+ else
132
+ bn = ASN1_INTEGER_to_BN(ai, NULL);
133
+
134
+ if (!bn)
135
+ ossl_raise(eOSSLError, NULL);
136
+ #if DO_IT_VIA_RUBY
137
+ if (!(txt = BN_bn2dec(bn))) {
138
+ BN_free(bn);
139
+ ossl_raise(eOSSLError, NULL);
140
+ }
141
+ num = rb_cstr_to_inum(txt, 10, Qtrue);
142
+ OPENSSL_free(txt);
143
+ #else
144
+ num = ossl_bn_new(bn);
145
+ #endif
146
+ BN_free(bn);
147
+
148
+ return num;
149
+ }
150
+
151
+ #if DO_IT_VIA_RUBY
152
+ ASN1_INTEGER *
153
+ num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
154
+ {
155
+ BIGNUM *bn = NULL;
156
+
157
+ if (RTEST(rb_obj_is_kind_of(obj, cBN))) {
158
+ bn = GetBNPtr(obj);
159
+ } else {
160
+ obj = rb_String(obj);
161
+ if (!BN_dec2bn(&bn, StringValueCStr(obj))) {
162
+ ossl_raise(eOSSLError, NULL);
163
+ }
164
+ }
165
+ if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) {
166
+ BN_free(bn);
167
+ ossl_raise(eOSSLError, NULL);
168
+ }
169
+ BN_free(bn);
170
+ return ai;
171
+ }
172
+ #else
173
+ ASN1_INTEGER *
174
+ num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
175
+ {
176
+ BIGNUM *bn;
177
+
178
+ if (NIL_P(obj))
179
+ ossl_raise(rb_eTypeError, "Can't convert nil into Integer");
180
+
181
+ bn = GetBNPtr(obj);
182
+
183
+ if (!(ai = BN_to_ASN1_INTEGER(bn, ai)))
184
+ ossl_raise(eOSSLError, NULL);
185
+
186
+ return ai;
187
+ }
188
+ #endif
189
+
190
+ /********/
191
+ /*
192
+ * ASN1 module
193
+ */
194
+ #define ossl_asn1_get_value(o) rb_attr_get((o),sivVALUE)
195
+ #define ossl_asn1_get_tag(o) rb_attr_get((o),sivTAG)
196
+ #define ossl_asn1_get_tagging(o) rb_attr_get((o),sivTAGGING)
197
+ #define ossl_asn1_get_tag_class(o) rb_attr_get((o),sivTAG_CLASS)
198
+ #define ossl_asn1_get_infinite_length(o) rb_attr_get((o),sivINFINITE_LENGTH)
199
+
200
+ #define ossl_asn1_set_value(o,v) rb_ivar_set((o),sivVALUE,(v))
201
+ #define ossl_asn1_set_tag(o,v) rb_ivar_set((o),sivTAG,(v))
202
+ #define ossl_asn1_set_tagging(o,v) rb_ivar_set((o),sivTAGGING,(v))
203
+ #define ossl_asn1_set_tag_class(o,v) rb_ivar_set((o),sivTAG_CLASS,(v))
204
+ #define ossl_asn1_set_infinite_length(o,v) rb_ivar_set((o),sivINFINITE_LENGTH,(v))
205
+
206
+ VALUE mASN1;
207
+ VALUE eASN1Error;
208
+
209
+ VALUE cASN1Data;
210
+ VALUE cASN1Primitive;
211
+ VALUE cASN1Constructive;
212
+
213
+ VALUE cASN1EndOfContent;
214
+ VALUE cASN1Boolean; /* BOOLEAN */
215
+ VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
216
+ VALUE cASN1BitString; /* BIT STRING */
217
+ VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
218
+ VALUE cASN1NumericString, cASN1PrintableString;
219
+ VALUE cASN1T61String, cASN1VideotexString;
220
+ VALUE cASN1IA5String, cASN1GraphicString;
221
+ VALUE cASN1ISO64String, cASN1GeneralString;
222
+ VALUE cASN1UniversalString, cASN1BMPString;
223
+ VALUE cASN1Null; /* NULL */
224
+ VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
225
+ VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
226
+ VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
227
+
228
+ static ID sIMPLICIT, sEXPLICIT;
229
+ static ID sUNIVERSAL, sAPPLICATION, sCONTEXT_SPECIFIC, sPRIVATE;
230
+ static ID sivVALUE, sivTAG, sivTAG_CLASS, sivTAGGING, sivINFINITE_LENGTH, sivUNUSED_BITS;
231
+
232
+ /*
233
+ * Ruby to ASN1 converters
234
+ */
235
+ static ASN1_BOOLEAN
236
+ obj_to_asn1bool(VALUE obj)
237
+ {
238
+ if (NIL_P(obj))
239
+ ossl_raise(rb_eTypeError, "Can't convert nil into Boolean");
240
+
241
+ return RTEST(obj) ? 0xff : 0x0;
242
+ }
243
+
244
+ static ASN1_INTEGER*
245
+ obj_to_asn1int(VALUE obj)
246
+ {
247
+ return num_to_asn1integer(obj, NULL);
248
+ }
249
+
250
+ static ASN1_BIT_STRING*
251
+ obj_to_asn1bstr(VALUE obj, long unused_bits)
252
+ {
253
+ ASN1_BIT_STRING *bstr;
254
+
255
+ if(unused_bits < 0) unused_bits = 0;
256
+ StringValue(obj);
257
+ if(!(bstr = ASN1_BIT_STRING_new()))
258
+ ossl_raise(eASN1Error, NULL);
259
+ ASN1_BIT_STRING_set(bstr, (unsigned char *)RSTRING_PTR(obj), RSTRING_LENINT(obj));
260
+ bstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
261
+ bstr->flags |= ASN1_STRING_FLAG_BITS_LEFT|(unused_bits&0x07);
262
+
263
+ return bstr;
264
+ }
265
+
266
+ static ASN1_STRING*
267
+ obj_to_asn1str(VALUE obj)
268
+ {
269
+ ASN1_STRING *str;
270
+
271
+ StringValue(obj);
272
+ if(!(str = ASN1_STRING_new()))
273
+ ossl_raise(eASN1Error, NULL);
274
+ ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LENINT(obj));
275
+
276
+ return str;
277
+ }
278
+
279
+ static ASN1_NULL*
280
+ obj_to_asn1null(VALUE obj)
281
+ {
282
+ ASN1_NULL *null;
283
+
284
+ if(!NIL_P(obj))
285
+ ossl_raise(eASN1Error, "nil expected");
286
+ if(!(null = ASN1_NULL_new()))
287
+ ossl_raise(eASN1Error, NULL);
288
+
289
+ return null;
290
+ }
291
+
292
+ static ASN1_OBJECT*
293
+ obj_to_asn1obj(VALUE obj)
294
+ {
295
+ ASN1_OBJECT *a1obj;
296
+
297
+ StringValueCStr(obj);
298
+ a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 0);
299
+ if(!a1obj) a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 1);
300
+ if(!a1obj) ossl_raise(eASN1Error, "invalid OBJECT ID %"PRIsVALUE, obj);
301
+
302
+ return a1obj;
303
+ }
304
+
305
+ static ASN1_UTCTIME *
306
+ obj_to_asn1utime(VALUE time)
307
+ {
308
+ time_t sec;
309
+ ASN1_UTCTIME *t;
310
+
311
+ #if defined(HAVE_ASN1_TIME_ADJ)
312
+ int off_days;
313
+
314
+ ossl_time_split(time, &sec, &off_days);
315
+ if (!(t = ASN1_UTCTIME_adj(NULL, sec, off_days, 0)))
316
+ #else
317
+ sec = time_to_time_t(time);
318
+ if (!(t = ASN1_UTCTIME_set(NULL, sec)))
319
+ #endif
320
+ ossl_raise(eASN1Error, NULL);
321
+
322
+ return t;
323
+ }
324
+
325
+ static ASN1_GENERALIZEDTIME *
326
+ obj_to_asn1gtime(VALUE time)
327
+ {
328
+ time_t sec;
329
+ ASN1_GENERALIZEDTIME *t;
330
+
331
+ #if defined(HAVE_ASN1_TIME_ADJ)
332
+ int off_days;
333
+
334
+ ossl_time_split(time, &sec, &off_days);
335
+ if (!(t = ASN1_GENERALIZEDTIME_adj(NULL, sec, off_days, 0)))
336
+ #else
337
+ sec = time_to_time_t(time);
338
+ if (!(t = ASN1_GENERALIZEDTIME_set(NULL, sec)))
339
+ #endif
340
+ ossl_raise(eASN1Error, NULL);
341
+
342
+ return t;
343
+ }
344
+
345
+ static ASN1_STRING*
346
+ obj_to_asn1derstr(VALUE obj)
347
+ {
348
+ ASN1_STRING *a1str;
349
+ VALUE str;
350
+
351
+ str = ossl_to_der(obj);
352
+ if(!(a1str = ASN1_STRING_new()))
353
+ ossl_raise(eASN1Error, NULL);
354
+ ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LENINT(str));
355
+
356
+ return a1str;
357
+ }
358
+
359
+ /*
360
+ * DER to Ruby converters
361
+ */
362
+ static VALUE
363
+ decode_bool(unsigned char* der, long length)
364
+ {
365
+ const unsigned char *p = der;
366
+
367
+ assert(length == 3);
368
+ if (*p++ != 1)
369
+ ossl_raise(eASN1Error, "not a boolean");
370
+ if (*p++ != 1)
371
+ ossl_raise(eASN1Error, "length is not 1");
372
+
373
+ return *p ? Qtrue : Qfalse;
374
+ }
375
+
376
+ static VALUE
377
+ decode_int(unsigned char* der, long length)
378
+ {
379
+ ASN1_INTEGER *ai;
380
+ const unsigned char *p;
381
+ VALUE ret;
382
+ int status = 0;
383
+
384
+ p = der;
385
+ if(!(ai = d2i_ASN1_INTEGER(NULL, &p, length)))
386
+ ossl_raise(eASN1Error, NULL);
387
+ ret = rb_protect((VALUE (*)(VALUE))asn1integer_to_num,
388
+ (VALUE)ai, &status);
389
+ ASN1_INTEGER_free(ai);
390
+ if(status) rb_jump_tag(status);
391
+
392
+ return ret;
393
+ }
394
+
395
+ static VALUE
396
+ decode_bstr(unsigned char* der, long length, long *unused_bits)
397
+ {
398
+ ASN1_BIT_STRING *bstr;
399
+ const unsigned char *p;
400
+ long len;
401
+ VALUE ret;
402
+
403
+ p = der;
404
+ if(!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length)))
405
+ ossl_raise(eASN1Error, NULL);
406
+ len = bstr->length;
407
+ *unused_bits = 0;
408
+ if(bstr->flags & ASN1_STRING_FLAG_BITS_LEFT)
409
+ *unused_bits = bstr->flags & 0x07;
410
+ ret = rb_str_new((const char *)bstr->data, len);
411
+ ASN1_BIT_STRING_free(bstr);
412
+
413
+ return ret;
414
+ }
415
+
416
+ static VALUE
417
+ decode_enum(unsigned char* der, long length)
418
+ {
419
+ ASN1_ENUMERATED *ai;
420
+ const unsigned char *p;
421
+ VALUE ret;
422
+ int status = 0;
423
+
424
+ p = der;
425
+ if(!(ai = d2i_ASN1_ENUMERATED(NULL, &p, length)))
426
+ ossl_raise(eASN1Error, NULL);
427
+ ret = rb_protect((VALUE (*)(VALUE))asn1integer_to_num,
428
+ (VALUE)ai, &status);
429
+ ASN1_ENUMERATED_free(ai);
430
+ if(status) rb_jump_tag(status);
431
+
432
+ return ret;
433
+ }
434
+
435
+ static VALUE
436
+ decode_null(unsigned char* der, long length)
437
+ {
438
+ ASN1_NULL *null;
439
+ const unsigned char *p;
440
+
441
+ p = der;
442
+ if(!(null = d2i_ASN1_NULL(NULL, &p, length)))
443
+ ossl_raise(eASN1Error, NULL);
444
+ ASN1_NULL_free(null);
445
+
446
+ return Qnil;
447
+ }
448
+
449
+ static VALUE
450
+ decode_obj(unsigned char* der, long length)
451
+ {
452
+ ASN1_OBJECT *obj;
453
+ const unsigned char *p;
454
+ VALUE ret;
455
+ int nid;
456
+ BIO *bio;
457
+
458
+ p = der;
459
+ if(!(obj = d2i_ASN1_OBJECT(NULL, &p, length)))
460
+ ossl_raise(eASN1Error, NULL);
461
+ if((nid = OBJ_obj2nid(obj)) != NID_undef){
462
+ ASN1_OBJECT_free(obj);
463
+ ret = rb_str_new2(OBJ_nid2sn(nid));
464
+ }
465
+ else{
466
+ if(!(bio = BIO_new(BIO_s_mem()))){
467
+ ASN1_OBJECT_free(obj);
468
+ ossl_raise(eASN1Error, NULL);
469
+ }
470
+ i2a_ASN1_OBJECT(bio, obj);
471
+ ASN1_OBJECT_free(obj);
472
+ ret = ossl_membio2str(bio);
473
+ }
474
+
475
+ return ret;
476
+ }
477
+
478
+ static VALUE
479
+ decode_time(unsigned char* der, long length)
480
+ {
481
+ ASN1_TIME *time;
482
+ const unsigned char *p;
483
+ VALUE ret;
484
+ int status = 0;
485
+
486
+ p = der;
487
+ if(!(time = d2i_ASN1_TIME(NULL, &p, length)))
488
+ ossl_raise(eASN1Error, NULL);
489
+ ret = rb_protect((VALUE (*)(VALUE))asn1time_to_time,
490
+ (VALUE)time, &status);
491
+ ASN1_TIME_free(time);
492
+ if(status) rb_jump_tag(status);
493
+
494
+ return ret;
495
+ }
496
+
497
+ static VALUE
498
+ decode_eoc(unsigned char *der, long length)
499
+ {
500
+ if (length != 2 || !(der[0] == 0x00 && der[1] == 0x00))
501
+ ossl_raise(eASN1Error, NULL);
502
+
503
+ return rb_str_new("", 0);
504
+ }
505
+
506
+ /********/
507
+
508
+ typedef struct {
509
+ const char *name;
510
+ VALUE *klass;
511
+ } ossl_asn1_info_t;
512
+
513
+ static const ossl_asn1_info_t ossl_asn1_info[] = {
514
+ { "EOC", &cASN1EndOfContent, }, /* 0 */
515
+ { "BOOLEAN", &cASN1Boolean, }, /* 1 */
516
+ { "INTEGER", &cASN1Integer, }, /* 2 */
517
+ { "BIT_STRING", &cASN1BitString, }, /* 3 */
518
+ { "OCTET_STRING", &cASN1OctetString, }, /* 4 */
519
+ { "NULL", &cASN1Null, }, /* 5 */
520
+ { "OBJECT", &cASN1ObjectId, }, /* 6 */
521
+ { "OBJECT_DESCRIPTOR", NULL, }, /* 7 */
522
+ { "EXTERNAL", NULL, }, /* 8 */
523
+ { "REAL", NULL, }, /* 9 */
524
+ { "ENUMERATED", &cASN1Enumerated, }, /* 10 */
525
+ { "EMBEDDED_PDV", NULL, }, /* 11 */
526
+ { "UTF8STRING", &cASN1UTF8String, }, /* 12 */
527
+ { "RELATIVE_OID", NULL, }, /* 13 */
528
+ { "[UNIVERSAL 14]", NULL, }, /* 14 */
529
+ { "[UNIVERSAL 15]", NULL, }, /* 15 */
530
+ { "SEQUENCE", &cASN1Sequence, }, /* 16 */
531
+ { "SET", &cASN1Set, }, /* 17 */
532
+ { "NUMERICSTRING", &cASN1NumericString, }, /* 18 */
533
+ { "PRINTABLESTRING", &cASN1PrintableString, }, /* 19 */
534
+ { "T61STRING", &cASN1T61String, }, /* 20 */
535
+ { "VIDEOTEXSTRING", &cASN1VideotexString, }, /* 21 */
536
+ { "IA5STRING", &cASN1IA5String, }, /* 22 */
537
+ { "UTCTIME", &cASN1UTCTime, }, /* 23 */
538
+ { "GENERALIZEDTIME", &cASN1GeneralizedTime, }, /* 24 */
539
+ { "GRAPHICSTRING", &cASN1GraphicString, }, /* 25 */
540
+ { "ISO64STRING", &cASN1ISO64String, }, /* 26 */
541
+ { "GENERALSTRING", &cASN1GeneralString, }, /* 27 */
542
+ { "UNIVERSALSTRING", &cASN1UniversalString, }, /* 28 */
543
+ { "CHARACTER_STRING", NULL, }, /* 29 */
544
+ { "BMPSTRING", &cASN1BMPString, }, /* 30 */
545
+ };
546
+
547
+ enum {ossl_asn1_info_size = (sizeof(ossl_asn1_info)/sizeof(ossl_asn1_info[0]))};
548
+
549
+ static VALUE class_tag_map;
550
+
551
+ static int ossl_asn1_default_tag(VALUE obj);
552
+
553
+ ASN1_TYPE*
554
+ ossl_asn1_get_asn1type(VALUE obj)
555
+ {
556
+ ASN1_TYPE *ret;
557
+ VALUE value, rflag;
558
+ void *ptr;
559
+ void (*free_func)();
560
+ int tag, flag;
561
+
562
+ tag = ossl_asn1_default_tag(obj);
563
+ value = ossl_asn1_get_value(obj);
564
+ switch(tag){
565
+ case V_ASN1_BOOLEAN:
566
+ ptr = (void*)(VALUE)obj_to_asn1bool(value);
567
+ free_func = NULL;
568
+ break;
569
+ case V_ASN1_INTEGER: /* FALLTHROUGH */
570
+ case V_ASN1_ENUMERATED:
571
+ ptr = obj_to_asn1int(value);
572
+ free_func = ASN1_INTEGER_free;
573
+ break;
574
+ case V_ASN1_BIT_STRING:
575
+ rflag = rb_attr_get(obj, sivUNUSED_BITS);
576
+ flag = NIL_P(rflag) ? -1 : NUM2INT(rflag);
577
+ ptr = obj_to_asn1bstr(value, flag);
578
+ free_func = ASN1_BIT_STRING_free;
579
+ break;
580
+ case V_ASN1_NULL:
581
+ ptr = obj_to_asn1null(value);
582
+ free_func = ASN1_NULL_free;
583
+ break;
584
+ case V_ASN1_OCTET_STRING: /* FALLTHROUGH */
585
+ case V_ASN1_UTF8STRING: /* FALLTHROUGH */
586
+ case V_ASN1_NUMERICSTRING: /* FALLTHROUGH */
587
+ case V_ASN1_PRINTABLESTRING: /* FALLTHROUGH */
588
+ case V_ASN1_T61STRING: /* FALLTHROUGH */
589
+ case V_ASN1_VIDEOTEXSTRING: /* FALLTHROUGH */
590
+ case V_ASN1_IA5STRING: /* FALLTHROUGH */
591
+ case V_ASN1_GRAPHICSTRING: /* FALLTHROUGH */
592
+ case V_ASN1_ISO64STRING: /* FALLTHROUGH */
593
+ case V_ASN1_GENERALSTRING: /* FALLTHROUGH */
594
+ case V_ASN1_UNIVERSALSTRING: /* FALLTHROUGH */
595
+ case V_ASN1_BMPSTRING:
596
+ ptr = obj_to_asn1str(value);
597
+ free_func = ASN1_STRING_free;
598
+ break;
599
+ case V_ASN1_OBJECT:
600
+ ptr = obj_to_asn1obj(value);
601
+ free_func = ASN1_OBJECT_free;
602
+ break;
603
+ case V_ASN1_UTCTIME:
604
+ ptr = obj_to_asn1utime(value);
605
+ free_func = ASN1_TIME_free;
606
+ break;
607
+ case V_ASN1_GENERALIZEDTIME:
608
+ ptr = obj_to_asn1gtime(value);
609
+ free_func = ASN1_TIME_free;
610
+ break;
611
+ case V_ASN1_SET: /* FALLTHROUGH */
612
+ case V_ASN1_SEQUENCE:
613
+ ptr = obj_to_asn1derstr(obj);
614
+ free_func = ASN1_STRING_free;
615
+ break;
616
+ default:
617
+ ossl_raise(eASN1Error, "unsupported ASN.1 type");
618
+ }
619
+ if(!(ret = OPENSSL_malloc(sizeof(ASN1_TYPE)))){
620
+ if(free_func) free_func(ptr);
621
+ ossl_raise(eASN1Error, "ASN1_TYPE alloc failure");
622
+ }
623
+ memset(ret, 0, sizeof(ASN1_TYPE));
624
+ ASN1_TYPE_set(ret, tag, ptr);
625
+
626
+ return ret;
627
+ }
628
+
629
+ static int
630
+ ossl_asn1_default_tag(VALUE obj)
631
+ {
632
+ //TAU
633
+ /*
634
+ VALUE tmp_class, tag;
635
+
636
+ tmp_class = CLASS_OF(obj);
637
+ while (tmp_class) {
638
+ tag = rb_hash_lookup(class_tag_map, tmp_class);
639
+ if (tag != Qnil) {
640
+ return NUM2INT(tag);
641
+ }
642
+ tmp_class = rb_class_superclass(tmp_class);
643
+ }
644
+ ossl_raise(eASN1Error, "universal tag for %"PRIsVALUE" not found",
645
+ rb_obj_class(obj));
646
+ */
647
+
648
+ int i;
649
+
650
+ for(i = 0; i < ossl_asn1_info_size; i++){
651
+ if(ossl_asn1_info[i].klass &&
652
+ rb_obj_is_kind_of(obj, *ossl_asn1_info[i].klass)){
653
+ return i;
654
+ }
655
+ }
656
+
657
+ ossl_raise(eASN1Error, "universal tag for %s not found",
658
+ rb_class2name(CLASS_OF(obj)));
659
+
660
+
661
+ return -1; /* dummy */
662
+ }
663
+
664
+ static int
665
+ ossl_asn1_tag(VALUE obj)
666
+ {
667
+ VALUE tag;
668
+
669
+ tag = ossl_asn1_get_tag(obj);
670
+ if(NIL_P(tag))
671
+ ossl_raise(eASN1Error, "tag number not specified");
672
+
673
+ return NUM2INT(tag);
674
+ }
675
+
676
+ static int
677
+ ossl_asn1_is_explicit(VALUE obj)
678
+ {
679
+ VALUE s;
680
+ int ret = -1;
681
+
682
+ s = ossl_asn1_get_tagging(obj);
683
+ if(NIL_P(s)) return 0;
684
+ else if(SYMBOL_P(s)){
685
+ if (SYM2ID(s) == sIMPLICIT)
686
+ ret = 0;
687
+ else if (SYM2ID(s) == sEXPLICIT)
688
+ ret = 1;
689
+ }
690
+ if(ret < 0){
691
+ ossl_raise(eASN1Error, "invalid tag default");
692
+ }
693
+
694
+ return ret;
695
+ }
696
+
697
+ static int
698
+ ossl_asn1_tag_class(VALUE obj)
699
+ {
700
+ VALUE s;
701
+ int ret = -1;
702
+
703
+ s = ossl_asn1_get_tag_class(obj);
704
+ if(NIL_P(s)) ret = V_ASN1_UNIVERSAL;
705
+ else if(SYMBOL_P(s)){
706
+ if (SYM2ID(s) == sUNIVERSAL)
707
+ ret = V_ASN1_UNIVERSAL;
708
+ else if (SYM2ID(s) == sAPPLICATION)
709
+ ret = V_ASN1_APPLICATION;
710
+ else if (SYM2ID(s) == sCONTEXT_SPECIFIC)
711
+ ret = V_ASN1_CONTEXT_SPECIFIC;
712
+ else if (SYM2ID(s) == sPRIVATE)
713
+ ret = V_ASN1_PRIVATE;
714
+ }
715
+ if(ret < 0){
716
+ ossl_raise(eASN1Error, "invalid tag class");
717
+ }
718
+
719
+ return ret;
720
+ }
721
+
722
+ static VALUE
723
+ ossl_asn1_class2sym(int tc)
724
+ {
725
+ if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
726
+ return ID2SYM(sPRIVATE);
727
+ else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
728
+ return ID2SYM(sCONTEXT_SPECIFIC);
729
+ else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
730
+ return ID2SYM(sAPPLICATION);
731
+ else
732
+ return ID2SYM(sUNIVERSAL);
733
+ }
734
+
735
+ /*
736
+ * call-seq:
737
+ * OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) => ASN1Data
738
+ *
739
+ * +value+: Please have a look at Constructive and Primitive to see how Ruby
740
+ * types are mapped to ASN.1 types and vice versa.
741
+ *
742
+ * +tag+: A +Number+ indicating the tag number.
743
+ *
744
+ * +tag_class+: A +Symbol+ indicating the tag class. Please cf. ASN1 for
745
+ * possible values.
746
+ *
747
+ * == Example
748
+ * asn1_int = OpenSSL::ASN1Data.new(42, 2, :UNIVERSAL) # => Same as OpenSSL::ASN1::Integer.new(42)
749
+ * tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER
750
+ */
751
+ static VALUE
752
+ ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
753
+ {
754
+ if(!SYMBOL_P(tag_class))
755
+ ossl_raise(eASN1Error, "invalid tag class");
756
+ if((SYM2ID(tag_class) == sUNIVERSAL) && NUM2INT(tag) > 31)
757
+ ossl_raise(eASN1Error, "tag number for Universal too large");
758
+ ossl_asn1_set_tag(self, tag);
759
+ ossl_asn1_set_value(self, value);
760
+ ossl_asn1_set_tag_class(self, tag_class);
761
+ ossl_asn1_set_infinite_length(self, Qfalse);
762
+
763
+ return self;
764
+ }
765
+
766
+ static VALUE
767
+ join_der_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, str))
768
+ {
769
+ i = ossl_to_der_if_possible(i);
770
+ StringValue(i);
771
+ rb_str_append(str, i);
772
+ return Qnil;
773
+ }
774
+
775
+ static VALUE
776
+ join_der(VALUE enumerable)
777
+ {
778
+ VALUE str = rb_str_new(0, 0);
779
+ rb_block_call(enumerable, rb_intern("each"), 0, 0, join_der_i, str);
780
+ return str;
781
+ }
782
+
783
+ /*
784
+ * call-seq:
785
+ * asn1.to_der => DER-encoded String
786
+ *
787
+ * Encodes this ASN1Data into a DER-encoded String value. The result is
788
+ * DER-encoded except for the possibility of infinite length encodings.
789
+ * Infinite length encodings are not allowed in strict DER, so strictly
790
+ * speaking the result of such an encoding would be a BER-encoding.
791
+ */
792
+ static VALUE
793
+ ossl_asn1data_to_der(VALUE self)
794
+ {
795
+ VALUE value, der, inf_length;
796
+ int tag, tag_class, is_cons = 0;
797
+ long length;
798
+ unsigned char *p;
799
+
800
+ value = ossl_asn1_get_value(self);
801
+ if(rb_obj_is_kind_of(value, rb_cArray)){
802
+ is_cons = 1;
803
+ value = join_der(value);
804
+ }
805
+ StringValue(value);
806
+
807
+ tag = ossl_asn1_tag(self);
808
+ tag_class = ossl_asn1_tag_class(self);
809
+ inf_length = ossl_asn1_get_infinite_length(self);
810
+ if (inf_length == Qtrue) {
811
+ is_cons = 2;
812
+ }
813
+ if((length = ASN1_object_size(is_cons, RSTRING_LENINT(value), tag)) <= 0)
814
+ ossl_raise(eASN1Error, NULL);
815
+ der = rb_str_new(0, length);
816
+ p = (unsigned char *)RSTRING_PTR(der);
817
+ ASN1_put_object(&p, is_cons, RSTRING_LENINT(value), tag, tag_class);
818
+ memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
819
+ p += RSTRING_LEN(value);
820
+ ossl_str_adjust(der, p);
821
+
822
+ return der;
823
+ }
824
+
825
+ static VALUE
826
+ int_ossl_asn1_decode0_prim(unsigned char **pp, long length, long hlen, int tag,
827
+ VALUE tc, long *num_read)
828
+ {
829
+ VALUE value, asn1data;
830
+ unsigned char *p;
831
+ long flag = 0;
832
+
833
+ p = *pp;
834
+
835
+ if(tc == sUNIVERSAL && tag < ossl_asn1_info_size) {
836
+ switch(tag){
837
+ case V_ASN1_EOC:
838
+ value = decode_eoc(p, hlen+length);
839
+ break;
840
+ case V_ASN1_BOOLEAN:
841
+ value = decode_bool(p, hlen+length);
842
+ break;
843
+ case V_ASN1_INTEGER:
844
+ value = decode_int(p, hlen+length);
845
+ break;
846
+ case V_ASN1_BIT_STRING:
847
+ value = decode_bstr(p, hlen+length, &flag);
848
+ break;
849
+ case V_ASN1_NULL:
850
+ value = decode_null(p, hlen+length);
851
+ break;
852
+ case V_ASN1_ENUMERATED:
853
+ value = decode_enum(p, hlen+length);
854
+ break;
855
+ case V_ASN1_OBJECT:
856
+ value = decode_obj(p, hlen+length);
857
+ break;
858
+ case V_ASN1_UTCTIME: /* FALLTHROUGH */
859
+ case V_ASN1_GENERALIZEDTIME:
860
+ value = decode_time(p, hlen+length);
861
+ break;
862
+ default:
863
+ /* use original value */
864
+ p += hlen;
865
+ value = rb_str_new((const char *)p, length);
866
+ break;
867
+ }
868
+ }
869
+ else {
870
+ p += hlen;
871
+ value = rb_str_new((const char *)p, length);
872
+ }
873
+
874
+ *pp += hlen + length;
875
+ *num_read = hlen + length;
876
+
877
+ if (tc == sUNIVERSAL && tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass) {
878
+ VALUE klass = *ossl_asn1_info[tag].klass;
879
+ VALUE args[4];
880
+ args[0] = value;
881
+ args[1] = INT2NUM(tag);
882
+ args[2] = Qnil;
883
+ args[3] = ID2SYM(tc);
884
+ asn1data = rb_obj_alloc(klass);
885
+ ossl_asn1_initialize(4, args, asn1data);
886
+ if(tag == V_ASN1_BIT_STRING){
887
+ rb_ivar_set(asn1data, sivUNUSED_BITS, LONG2NUM(flag));
888
+ }
889
+ }
890
+ else {
891
+ asn1data = rb_obj_alloc(cASN1Data);
892
+ ossl_asn1data_initialize(asn1data, value, INT2NUM(tag), ID2SYM(tc));
893
+ }
894
+
895
+ return asn1data;
896
+ }
897
+
898
+ static VALUE
899
+ int_ossl_asn1_decode0_cons(unsigned char **pp, long max_len, long length,
900
+ long *offset, int depth, int yield, int j,
901
+ int tag, VALUE tc, long *num_read)
902
+ {
903
+ VALUE value, asn1data, ary;
904
+ int infinite;
905
+ long off = *offset;
906
+
907
+ infinite = (j == 0x21);
908
+ ary = rb_ary_new();
909
+
910
+ while (length > 0 || infinite) {
911
+ long inner_read = 0;
912
+ value = ossl_asn1_decode0(pp, max_len, &off, depth + 1, yield, &inner_read);
913
+ *num_read += inner_read;
914
+ max_len -= inner_read;
915
+ rb_ary_push(ary, value);
916
+ if (length > 0)
917
+ length -= inner_read;
918
+
919
+ if (infinite &&
920
+ NUM2INT(ossl_asn1_get_tag(value)) == V_ASN1_EOC &&
921
+ SYM2ID(ossl_asn1_get_tag_class(value)) == sUNIVERSAL) {
922
+ break;
923
+ }
924
+ }
925
+
926
+ if (tc == sUNIVERSAL) {
927
+ VALUE args[4];
928
+ int not_sequence_or_set;
929
+
930
+ not_sequence_or_set = tag != V_ASN1_SEQUENCE && tag != V_ASN1_SET;
931
+
932
+ if (not_sequence_or_set) {
933
+ if (infinite) {
934
+ asn1data = rb_obj_alloc(cASN1Constructive);
935
+ }
936
+ else {
937
+ ossl_raise(eASN1Error, "invalid non-infinite tag");
938
+ return Qnil;
939
+ }
940
+ }
941
+ else {
942
+ VALUE klass = *ossl_asn1_info[tag].klass;
943
+ asn1data = rb_obj_alloc(klass);
944
+ }
945
+ args[0] = ary;
946
+ args[1] = INT2NUM(tag);
947
+ args[2] = Qnil;
948
+ args[3] = ID2SYM(tc);
949
+ ossl_asn1_initialize(4, args, asn1data);
950
+ }
951
+ else {
952
+ asn1data = rb_obj_alloc(cASN1Data);
953
+ ossl_asn1data_initialize(asn1data, ary, INT2NUM(tag), ID2SYM(tc));
954
+ }
955
+
956
+ if (infinite)
957
+ ossl_asn1_set_infinite_length(asn1data, Qtrue);
958
+ else
959
+ ossl_asn1_set_infinite_length(asn1data, Qfalse);
960
+
961
+ *offset = off;
962
+ return asn1data;
963
+ }
964
+
965
+ static VALUE
966
+ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, int depth,
967
+ int yield, long *num_read)
968
+ {
969
+ unsigned char *start, *p;
970
+ const unsigned char *p0;
971
+ long len = 0, inner_read = 0, off = *offset, hlen;
972
+ int tag, tc, j;
973
+ VALUE asn1data, tag_class;
974
+
975
+ p = *pp;
976
+ start = p;
977
+ p0 = p;
978
+ j = ASN1_get_object(&p0, &len, &tag, &tc, length);
979
+ p = (unsigned char *)p0;
980
+ if(j & 0x80) ossl_raise(eASN1Error, NULL);
981
+ if(len > length) ossl_raise(eASN1Error, "value is too short");
982
+ if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
983
+ tag_class = sPRIVATE;
984
+ else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
985
+ tag_class = sCONTEXT_SPECIFIC;
986
+ else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
987
+ tag_class = sAPPLICATION;
988
+ else
989
+ tag_class = sUNIVERSAL;
990
+
991
+ hlen = p - start;
992
+
993
+ if(yield) {
994
+ VALUE arg = rb_ary_new();
995
+ rb_ary_push(arg, LONG2NUM(depth));
996
+ rb_ary_push(arg, LONG2NUM(*offset));
997
+ rb_ary_push(arg, LONG2NUM(hlen));
998
+ rb_ary_push(arg, LONG2NUM(len));
999
+ rb_ary_push(arg, (j & V_ASN1_CONSTRUCTED) ? Qtrue : Qfalse);
1000
+ rb_ary_push(arg, ossl_asn1_class2sym(tc));
1001
+ rb_ary_push(arg, INT2NUM(tag));
1002
+ rb_yield(arg);
1003
+ }
1004
+
1005
+ if(j & V_ASN1_CONSTRUCTED) {
1006
+ *pp += hlen;
1007
+ off += hlen;
1008
+ asn1data = int_ossl_asn1_decode0_cons(pp, length, len, &off, depth, yield, j, tag, tag_class, &inner_read);
1009
+ inner_read += hlen;
1010
+ }
1011
+ else {
1012
+ if ((j & 0x01) && (len == 0)) ossl_raise(eASN1Error, "Infinite length for primitive value");
1013
+ asn1data = int_ossl_asn1_decode0_prim(pp, len, hlen, tag, tag_class, &inner_read);
1014
+ off += hlen + len;
1015
+ }
1016
+ if (num_read)
1017
+ *num_read = inner_read;
1018
+ if (len != 0 && inner_read != hlen + len) {
1019
+ ossl_raise(eASN1Error,
1020
+ "Type mismatch. Bytes read: %ld Bytes available: %ld",
1021
+ inner_read, hlen + len);
1022
+ }
1023
+
1024
+ *offset = off;
1025
+ return asn1data;
1026
+ }
1027
+
1028
+ static void
1029
+ int_ossl_decode_sanity_check(long len, long read, long offset)
1030
+ {
1031
+ if (len != 0 && (read != len || offset != len)) {
1032
+ ossl_raise(eASN1Error,
1033
+ "Type mismatch. Total bytes read: %ld Bytes available: %ld Offset: %ld",
1034
+ read, len, offset);
1035
+ }
1036
+ }
1037
+
1038
+ /*
1039
+ * call-seq:
1040
+ * OpenSSL::ASN1.traverse(asn1) -> nil
1041
+ *
1042
+ * If a block is given, it prints out each of the elements encountered.
1043
+ * Block parameters are (in that order):
1044
+ * * depth: The recursion depth, plus one with each constructed value being encountered (Number)
1045
+ * * offset: Current byte offset (Number)
1046
+ * * header length: Combined length in bytes of the Tag and Length headers. (Number)
1047
+ * * length: The overall remaining length of the entire data (Number)
1048
+ * * constructed: Whether this value is constructed or not (Boolean)
1049
+ * * tag_class: Current tag class (Symbol)
1050
+ * * tag: The current tag (Number)
1051
+ *
1052
+ * == Example
1053
+ * der = File.binread('asn1data.der')
1054
+ * OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag|
1055
+ * puts "Depth: #{depth} Offset: #{offset} Length: #{length}"
1056
+ * puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}"
1057
+ * end
1058
+ */
1059
+ static VALUE
1060
+ ossl_asn1_traverse(VALUE self, VALUE obj)
1061
+ {
1062
+ unsigned char *p;
1063
+ VALUE tmp;
1064
+ long len, read = 0, offset = 0;
1065
+
1066
+ obj = ossl_to_der_if_possible(obj);
1067
+ tmp = rb_str_new4(StringValue(obj));
1068
+ p = (unsigned char *)RSTRING_PTR(tmp);
1069
+ len = RSTRING_LEN(tmp);
1070
+ ossl_asn1_decode0(&p, len, &offset, 0, 1, &read);
1071
+ RB_GC_GUARD(tmp);
1072
+ int_ossl_decode_sanity_check(len, read, offset);
1073
+ return Qnil;
1074
+ }
1075
+
1076
+ /*
1077
+ * call-seq:
1078
+ * OpenSSL::ASN1.decode(der) -> ASN1Data
1079
+ *
1080
+ * Decodes a BER- or DER-encoded value and creates an ASN1Data instance. +der+
1081
+ * may be a +String+ or any object that features a +#to_der+ method transforming
1082
+ * it into a BER-/DER-encoded +String+.
1083
+ *
1084
+ * == Example
1085
+ * der = File.binread('asn1data')
1086
+ * asn1 = OpenSSL::ASN1.decode(der)
1087
+ */
1088
+ static VALUE
1089
+ ossl_asn1_decode(VALUE self, VALUE obj)
1090
+ {
1091
+ VALUE ret;
1092
+ unsigned char *p;
1093
+ VALUE tmp;
1094
+ long len, read = 0, offset = 0;
1095
+
1096
+ obj = ossl_to_der_if_possible(obj);
1097
+ tmp = rb_str_new4(StringValue(obj));
1098
+ p = (unsigned char *)RSTRING_PTR(tmp);
1099
+ len = RSTRING_LEN(tmp);
1100
+ ret = ossl_asn1_decode0(&p, len, &offset, 0, 0, &read);
1101
+ RB_GC_GUARD(tmp);
1102
+ int_ossl_decode_sanity_check(len, read, offset);
1103
+ return ret;
1104
+ }
1105
+
1106
+ /*
1107
+ * call-seq:
1108
+ * OpenSSL::ASN1.decode_all(der) -> Array of ASN1Data
1109
+ *
1110
+ * Similar to +decode+ with the difference that +decode+ expects one
1111
+ * distinct value represented in +der+. +decode_all+ on the contrary
1112
+ * decodes a sequence of sequential BER/DER values lined up in +der+
1113
+ * and returns them as an array.
1114
+ *
1115
+ * == Example
1116
+ * ders = File.binread('asn1data_seq')
1117
+ * asn1_ary = OpenSSL::ASN1.decode_all(ders)
1118
+ */
1119
+ static VALUE
1120
+ ossl_asn1_decode_all(VALUE self, VALUE obj)
1121
+ {
1122
+ VALUE ary, val;
1123
+ unsigned char *p;
1124
+ long len, tmp_len = 0, read = 0, offset = 0;
1125
+ VALUE tmp;
1126
+
1127
+ obj = ossl_to_der_if_possible(obj);
1128
+ tmp = rb_str_new4(StringValue(obj));
1129
+ p = (unsigned char *)RSTRING_PTR(tmp);
1130
+ len = RSTRING_LEN(tmp);
1131
+ tmp_len = len;
1132
+ ary = rb_ary_new();
1133
+ while (tmp_len > 0) {
1134
+ long tmp_read = 0;
1135
+ val = ossl_asn1_decode0(&p, tmp_len, &offset, 0, 0, &tmp_read);
1136
+ rb_ary_push(ary, val);
1137
+ read += tmp_read;
1138
+ tmp_len -= tmp_read;
1139
+ }
1140
+ RB_GC_GUARD(tmp);
1141
+ int_ossl_decode_sanity_check(len, read, offset);
1142
+ return ary;
1143
+ }
1144
+
1145
+ /*
1146
+ * call-seq:
1147
+ * OpenSSL::ASN1::Primitive.new( value [, tag, tagging, tag_class ]) => Primitive
1148
+ *
1149
+ * +value+: is mandatory.
1150
+ *
1151
+ * +tag+: optional, may be specified for tagged values. If no +tag+ is
1152
+ * specified, the UNIVERSAL tag corresponding to the Primitive sub-class
1153
+ * is used by default.
1154
+ *
1155
+ * +tagging+: may be used as an encoding hint to encode a value either
1156
+ * explicitly or implicitly, see ASN1 for possible values.
1157
+ *
1158
+ * +tag_class+: if +tag+ and +tagging+ are +nil+ then this is set to
1159
+ * +:UNIVERSAL+ by default. If either +tag+ or +tagging+ are set then
1160
+ * +:CONTEXT_SPECIFIC+ is used as the default. For possible values please
1161
+ * cf. ASN1.
1162
+ *
1163
+ * == Example
1164
+ * int = OpenSSL::ASN1::Integer.new(42)
1165
+ * zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT)
1166
+ * private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE)
1167
+ */
1168
+ static VALUE
1169
+ ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
1170
+ {
1171
+ VALUE value, tag, tagging, tag_class;
1172
+
1173
+ rb_scan_args(argc, argv, "13", &value, &tag, &tagging, &tag_class);
1174
+ if(argc > 1){
1175
+ if(NIL_P(tag))
1176
+ ossl_raise(eASN1Error, "must specify tag number");
1177
+ if(!NIL_P(tagging) && !SYMBOL_P(tagging))
1178
+ ossl_raise(eASN1Error, "invalid tagging method");
1179
+ if(NIL_P(tag_class)) {
1180
+ if (NIL_P(tagging))
1181
+ tag_class = ID2SYM(sUNIVERSAL);
1182
+ else
1183
+ tag_class = ID2SYM(sCONTEXT_SPECIFIC);
1184
+ }
1185
+ if(!SYMBOL_P(tag_class))
1186
+ ossl_raise(eASN1Error, "invalid tag class");
1187
+ if(!NIL_P(tagging) && SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31)
1188
+ ossl_raise(eASN1Error, "tag number for Universal too large");
1189
+ }
1190
+ else{
1191
+ tag = INT2NUM(ossl_asn1_default_tag(self));
1192
+ tagging = Qnil;
1193
+ tag_class = ID2SYM(sUNIVERSAL);
1194
+ }
1195
+ ossl_asn1_set_tag(self, tag);
1196
+ ossl_asn1_set_value(self, value);
1197
+ ossl_asn1_set_tagging(self, tagging);
1198
+ ossl_asn1_set_tag_class(self, tag_class);
1199
+ ossl_asn1_set_infinite_length(self, Qfalse);
1200
+
1201
+ return self;
1202
+ }
1203
+
1204
+ static VALUE
1205
+ ossl_asn1eoc_initialize(VALUE self) {
1206
+ VALUE tag, tagging, tag_class, value;
1207
+ tag = INT2NUM(ossl_asn1_default_tag(self));
1208
+ tagging = Qnil;
1209
+ tag_class = ID2SYM(sUNIVERSAL);
1210
+ value = rb_str_new("", 0);
1211
+ ossl_asn1_set_tag(self, tag);
1212
+ ossl_asn1_set_value(self, value);
1213
+ ossl_asn1_set_tagging(self, tagging);
1214
+ ossl_asn1_set_tag_class(self, tag_class);
1215
+ ossl_asn1_set_infinite_length(self, Qfalse);
1216
+ return self;
1217
+ }
1218
+
1219
+ /*
1220
+ * call-seq:
1221
+ * asn1.to_der => DER-encoded String
1222
+ *
1223
+ * See ASN1Data#to_der for details. *
1224
+ */
1225
+ static VALUE
1226
+ ossl_asn1prim_to_der(VALUE self)
1227
+ {
1228
+ ASN1_TYPE *asn1;
1229
+ int tn, tc, explicit;
1230
+ long len, reallen;
1231
+ unsigned char *buf, *p;
1232
+ VALUE str;
1233
+
1234
+ tn = NUM2INT(ossl_asn1_get_tag(self));
1235
+ tc = ossl_asn1_tag_class(self);
1236
+ explicit = ossl_asn1_is_explicit(self);
1237
+ asn1 = ossl_asn1_get_asn1type(self);
1238
+
1239
+ len = ASN1_object_size(1, i2d_ASN1_TYPE(asn1, NULL), tn);
1240
+ if(!(buf = OPENSSL_malloc(len))){
1241
+ ASN1_TYPE_free(asn1);
1242
+ ossl_raise(eASN1Error, "cannot alloc buffer");
1243
+ }
1244
+ p = buf;
1245
+ if (tc == V_ASN1_UNIVERSAL) {
1246
+ i2d_ASN1_TYPE(asn1, &p);
1247
+ } else if (explicit) {
1248
+ ASN1_put_object(&p, 1, i2d_ASN1_TYPE(asn1, NULL), tn, tc);
1249
+ i2d_ASN1_TYPE(asn1, &p);
1250
+ } else {
1251
+ i2d_ASN1_TYPE(asn1, &p);
1252
+ *buf = tc | tn | (*buf & V_ASN1_CONSTRUCTED);
1253
+ }
1254
+ ASN1_TYPE_free(asn1);
1255
+ reallen = p - buf;
1256
+ assert(reallen <= len);
1257
+ str = ossl_buf2str((char *)buf, rb_long2int(reallen)); /* buf will be free in ossl_buf2str */
1258
+
1259
+ return str;
1260
+ }
1261
+
1262
+ /*
1263
+ * call-seq:
1264
+ * asn1.to_der => DER-encoded String
1265
+ *
1266
+ * See ASN1Data#to_der for details.
1267
+ */
1268
+ static VALUE
1269
+ ossl_asn1cons_to_der(VALUE self)
1270
+ {
1271
+ int tag, tn, tc, explicit, constructed = 1;
1272
+ int found_prim = 0, seq_len;
1273
+ long length;
1274
+ unsigned char *p;
1275
+ VALUE value, str, inf_length;
1276
+
1277
+ tn = NUM2INT(ossl_asn1_get_tag(self));
1278
+ tc = ossl_asn1_tag_class(self);
1279
+ inf_length = ossl_asn1_get_infinite_length(self);
1280
+ if (inf_length == Qtrue) {
1281
+ VALUE ary, example;
1282
+ constructed = 2;
1283
+ if (CLASS_OF(self) == cASN1Sequence ||
1284
+ CLASS_OF(self) == cASN1Set) {
1285
+ tag = ossl_asn1_default_tag(self);
1286
+ }
1287
+ else { /* must be a constructive encoding of a primitive value */
1288
+ ary = ossl_asn1_get_value(self);
1289
+ if (!rb_obj_is_kind_of(ary, rb_cArray))
1290
+ ossl_raise(eASN1Error, "Constructive value must be an Array");
1291
+ /* Recursively descend until a primitive value is found.
1292
+ The overall value of the entire constructed encoding
1293
+ is of the type of the first primitive encoding to be
1294
+ found. */
1295
+ while (!found_prim){
1296
+ example = rb_ary_entry(ary, 0);
1297
+ if (rb_obj_is_kind_of(example, cASN1Primitive)){
1298
+ found_prim = 1;
1299
+ }
1300
+ else {
1301
+ /* example is another ASN1Constructive */
1302
+ if (!rb_obj_is_kind_of(example, cASN1Constructive)){
1303
+ ossl_raise(eASN1Error, "invalid constructed encoding");
1304
+ return Qnil; /* dummy */
1305
+ }
1306
+ ary = ossl_asn1_get_value(example);
1307
+ }
1308
+ }
1309
+ tag = ossl_asn1_default_tag(example);
1310
+ }
1311
+ }
1312
+ else {
1313
+ if (CLASS_OF(self) == cASN1Constructive)
1314
+ ossl_raise(eASN1Error, "Constructive shall only be used with infinite length");
1315
+ tag = ossl_asn1_default_tag(self);
1316
+ }
1317
+ explicit = ossl_asn1_is_explicit(self);
1318
+ value = join_der(ossl_asn1_get_value(self));
1319
+
1320
+ seq_len = ASN1_object_size(constructed, RSTRING_LENINT(value), tag);
1321
+ length = ASN1_object_size(constructed, seq_len, tn);
1322
+ str = rb_str_new(0, length);
1323
+ p = (unsigned char *)RSTRING_PTR(str);
1324
+ if(tc == V_ASN1_UNIVERSAL)
1325
+ ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
1326
+ else{
1327
+ if(explicit){
1328
+ ASN1_put_object(&p, constructed, seq_len, tn, tc);
1329
+ ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tag, V_ASN1_UNIVERSAL);
1330
+ }
1331
+ else{
1332
+ ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
1333
+ }
1334
+ }
1335
+ memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
1336
+ p += RSTRING_LEN(value);
1337
+
1338
+ /* In this case we need an additional EOC (one for the explicit part and
1339
+ * one for the Constructive itself. The EOC for the Constructive is
1340
+ * supplied by the user, but that for the "explicit wrapper" must be
1341
+ * added here.
1342
+ */
1343
+ if (explicit && inf_length == Qtrue) {
1344
+ ASN1_put_eoc(&p);
1345
+ }
1346
+ ossl_str_adjust(str, p);
1347
+
1348
+ return str;
1349
+ }
1350
+
1351
+ /*
1352
+ * call-seq:
1353
+ * asn1_ary.each { |asn1| block } => asn1_ary
1354
+ *
1355
+ * Calls <i>block</i> once for each element in +self+, passing that element
1356
+ * as parameter +asn1+. If no block is given, an enumerator is returned
1357
+ * instead.
1358
+ *
1359
+ * == Example
1360
+ * asn1_ary.each do |asn1|
1361
+ * puts asn1
1362
+ * end
1363
+ */
1364
+ static VALUE
1365
+ ossl_asn1cons_each(VALUE self)
1366
+ {
1367
+ rb_ary_each(ossl_asn1_get_value(self));
1368
+ return self;
1369
+ }
1370
+
1371
+ /*
1372
+ * call-seq:
1373
+ * OpenSSL::ASN1::ObjectId.register(object_id, short_name, long_name)
1374
+ *
1375
+ * This adds a new ObjectId to the internal tables. Where +object_id+ is the
1376
+ * numerical form, +short_name+ is the short name, and +long_name+ is the long
1377
+ * name.
1378
+ *
1379
+ * Returns +true+ if successful. Raises an OpenSSL::ASN1::ASN1Error if it fails.
1380
+ *
1381
+ */
1382
+ static VALUE
1383
+ ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
1384
+ {
1385
+ StringValueCStr(oid);
1386
+ StringValueCStr(sn);
1387
+ StringValueCStr(ln);
1388
+
1389
+ if(!OBJ_create(RSTRING_PTR(oid), RSTRING_PTR(sn), RSTRING_PTR(ln)))
1390
+ ossl_raise(eASN1Error, NULL);
1391
+
1392
+ return Qtrue;
1393
+ }
1394
+
1395
+ /* Document-method: OpenSSL::ASN1::ObjectId#sn
1396
+ *
1397
+ * The short name of the ObjectId, as defined in <openssl/objects.h>.
1398
+ */
1399
+ /* Document-method: OpenSSL::ASN1::ObjectId#short_name
1400
+ *
1401
+ * +short_name+ is an alias to +sn+
1402
+ */
1403
+ static VALUE
1404
+ ossl_asn1obj_get_sn(VALUE self)
1405
+ {
1406
+ VALUE val, ret = Qnil;
1407
+ int nid;
1408
+
1409
+ val = ossl_asn1_get_value(self);
1410
+ if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef)
1411
+ ret = rb_str_new2(OBJ_nid2sn(nid));
1412
+
1413
+ return ret;
1414
+ }
1415
+
1416
+ /* Document-method: OpenSSL::ASN1::ObjectId#ln
1417
+ *
1418
+ * The long name of the ObjectId, as defined in <openssl/objects.h>.
1419
+ */
1420
+ /* Document-method: OpenSSL::ASN1::ObjectId#long_name
1421
+ *
1422
+ * +long_name+ is an alias to +ln+
1423
+ */
1424
+ static VALUE
1425
+ ossl_asn1obj_get_ln(VALUE self)
1426
+ {
1427
+ VALUE val, ret = Qnil;
1428
+ int nid;
1429
+
1430
+ val = ossl_asn1_get_value(self);
1431
+ if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef)
1432
+ ret = rb_str_new2(OBJ_nid2ln(nid));
1433
+
1434
+ return ret;
1435
+ }
1436
+
1437
+ /* Document-method: OpenSSL::ASN1::ObjectId#oid
1438
+ *
1439
+ * The object identifier as a +String+, e.g. "1.2.3.4.5"
1440
+ */
1441
+ static VALUE
1442
+ ossl_asn1obj_get_oid(VALUE self)
1443
+ {
1444
+ VALUE val;
1445
+ ASN1_OBJECT *a1obj;
1446
+ char buf[128];
1447
+
1448
+ val = ossl_asn1_get_value(self);
1449
+ a1obj = obj_to_asn1obj(val);
1450
+ OBJ_obj2txt(buf, sizeof(buf), a1obj, 1);
1451
+ ASN1_OBJECT_free(a1obj);
1452
+
1453
+ return rb_str_new2(buf);
1454
+ }
1455
+
1456
+ #define OSSL_ASN1_IMPL_FACTORY_METHOD(klass) \
1457
+ static VALUE ossl_asn1_##klass(int argc, VALUE *argv, VALUE self)\
1458
+ { return rb_funcall3(cASN1##klass, rb_intern("new"), argc, argv); }
1459
+
1460
+ OSSL_ASN1_IMPL_FACTORY_METHOD(Boolean)
1461
+ OSSL_ASN1_IMPL_FACTORY_METHOD(Integer)
1462
+ OSSL_ASN1_IMPL_FACTORY_METHOD(Enumerated)
1463
+ OSSL_ASN1_IMPL_FACTORY_METHOD(BitString)
1464
+ OSSL_ASN1_IMPL_FACTORY_METHOD(OctetString)
1465
+ OSSL_ASN1_IMPL_FACTORY_METHOD(UTF8String)
1466
+ OSSL_ASN1_IMPL_FACTORY_METHOD(NumericString)
1467
+ OSSL_ASN1_IMPL_FACTORY_METHOD(PrintableString)
1468
+ OSSL_ASN1_IMPL_FACTORY_METHOD(T61String)
1469
+ OSSL_ASN1_IMPL_FACTORY_METHOD(VideotexString)
1470
+ OSSL_ASN1_IMPL_FACTORY_METHOD(IA5String)
1471
+ OSSL_ASN1_IMPL_FACTORY_METHOD(GraphicString)
1472
+ OSSL_ASN1_IMPL_FACTORY_METHOD(ISO64String)
1473
+ OSSL_ASN1_IMPL_FACTORY_METHOD(GeneralString)
1474
+ OSSL_ASN1_IMPL_FACTORY_METHOD(UniversalString)
1475
+ OSSL_ASN1_IMPL_FACTORY_METHOD(BMPString)
1476
+ OSSL_ASN1_IMPL_FACTORY_METHOD(Null)
1477
+ OSSL_ASN1_IMPL_FACTORY_METHOD(ObjectId)
1478
+ OSSL_ASN1_IMPL_FACTORY_METHOD(UTCTime)
1479
+ OSSL_ASN1_IMPL_FACTORY_METHOD(GeneralizedTime)
1480
+ OSSL_ASN1_IMPL_FACTORY_METHOD(Sequence)
1481
+ OSSL_ASN1_IMPL_FACTORY_METHOD(Set)
1482
+ OSSL_ASN1_IMPL_FACTORY_METHOD(EndOfContent)
1483
+
1484
+ void
1485
+ Init_ossl_asn1(void)
1486
+ {
1487
+ VALUE ary;
1488
+ int i;
1489
+
1490
+ #if 0
1491
+ mOSSL = rb_define_module("OpenSSL");
1492
+ eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
1493
+ #endif
1494
+
1495
+ sUNIVERSAL = rb_intern("UNIVERSAL");
1496
+ sCONTEXT_SPECIFIC = rb_intern("CONTEXT_SPECIFIC");
1497
+ sAPPLICATION = rb_intern("APPLICATION");
1498
+ sPRIVATE = rb_intern("PRIVATE");
1499
+ sEXPLICIT = rb_intern("EXPLICIT");
1500
+ sIMPLICIT = rb_intern("IMPLICIT");
1501
+
1502
+ sivVALUE = rb_intern("@value");
1503
+ sivTAG = rb_intern("@tag");
1504
+ sivTAGGING = rb_intern("@tagging");
1505
+ sivTAG_CLASS = rb_intern("@tag_class");
1506
+ sivINFINITE_LENGTH = rb_intern("@infinite_length");
1507
+ sivUNUSED_BITS = rb_intern("@unused_bits");
1508
+
1509
+ /*
1510
+ * Document-module: OpenSSL::ASN1
1511
+ *
1512
+ * Abstract Syntax Notation One (or ASN.1) is a notation syntax to
1513
+ * describe data structures and is defined in ITU-T X.680. ASN.1 itself
1514
+ * does not mandate any encoding or parsing rules, but usually ASN.1 data
1515
+ * structures are encoded using the Distinguished Encoding Rules (DER) or
1516
+ * less often the Basic Encoding Rules (BER) described in ITU-T X.690. DER
1517
+ * and BER encodings are binary Tag-Length-Value (TLV) encodings that are
1518
+ * quite concise compared to other popular data description formats such
1519
+ * as XML, JSON etc.
1520
+ * ASN.1 data structures are very common in cryptographic applications,
1521
+ * e.g. X.509 public key certificates or certificate revocation lists
1522
+ * (CRLs) are all defined in ASN.1 and DER-encoded. ASN.1, DER and BER are
1523
+ * the building blocks of applied cryptography.
1524
+ * The ASN1 module provides the necessary classes that allow generation
1525
+ * of ASN.1 data structures and the methods to encode them using a DER
1526
+ * encoding. The decode method allows parsing arbitrary BER-/DER-encoded
1527
+ * data to a Ruby object that can then be modified and re-encoded at will.
1528
+ *
1529
+ * == ASN.1 class hierarchy
1530
+ *
1531
+ * The base class representing ASN.1 structures is ASN1Data. ASN1Data offers
1532
+ * attributes to read and set the +tag+, the +tag_class+ and finally the
1533
+ * +value+ of a particular ASN.1 item. Upon parsing, any tagged values
1534
+ * (implicit or explicit) will be represented by ASN1Data instances because
1535
+ * their "real type" can only be determined using out-of-band information
1536
+ * from the ASN.1 type declaration. Since this information is normally
1537
+ * known when encoding a type, all sub-classes of ASN1Data offer an
1538
+ * additional attribute +tagging+ that allows to encode a value implicitly
1539
+ * (+:IMPLICIT+) or explicitly (+:EXPLICIT+).
1540
+ *
1541
+ * === Constructive
1542
+ *
1543
+ * Constructive is, as its name implies, the base class for all
1544
+ * constructed encodings, i.e. those that consist of several values,
1545
+ * opposed to "primitive" encodings with just one single value.
1546
+ * Primitive values that are encoded with "infinite length" are typically
1547
+ * constructed (their values come in multiple chunks) and are therefore
1548
+ * represented by instances of Constructive. The value of an Constructive
1549
+ * is always an Array.
1550
+ *
1551
+ * ==== ASN1::Set and ASN1::Sequence
1552
+ *
1553
+ * The most common constructive encodings are SETs and SEQUENCEs, which is
1554
+ * why there are two sub-classes of Constructive representing each of
1555
+ * them.
1556
+ *
1557
+ * === Primitive
1558
+ *
1559
+ * This is the super class of all primitive values. Primitive
1560
+ * itself is not used when parsing ASN.1 data, all values are either
1561
+ * instances of a corresponding sub-class of Primitive or they are
1562
+ * instances of ASN1Data if the value was tagged implicitly or explicitly.
1563
+ * Please cf. Primitive documentation for details on sub-classes and
1564
+ * their respective mappings of ASN.1 data types to Ruby objects.
1565
+ *
1566
+ * == Possible values for +tagging+
1567
+ *
1568
+ * When constructing an ASN1Data object the ASN.1 type definition may
1569
+ * require certain elements to be either implicitly or explicitly tagged.
1570
+ * This can be achieved by setting the +tagging+ attribute manually for
1571
+ * sub-classes of ASN1Data. Use the symbol +:IMPLICIT+ for implicit
1572
+ * tagging and +:EXPLICIT+ if the element requires explicit tagging.
1573
+ *
1574
+ * == Possible values for +tag_class+
1575
+ *
1576
+ * It is possible to create arbitrary ASN1Data objects that also support
1577
+ * a PRIVATE or APPLICATION tag class. Possible values for the +tag_class+
1578
+ * attribute are:
1579
+ * * +:UNIVERSAL+ (the default for untagged values)
1580
+ * * +:CONTEXT_SPECIFIC+ (the default for tagged values)
1581
+ * * +:APPLICATION+
1582
+ * * +:PRIVATE+
1583
+ *
1584
+ * == Tag constants
1585
+ *
1586
+ * There is a constant defined for each universal tag:
1587
+ * * OpenSSL::ASN1::EOC (0)
1588
+ * * OpenSSL::ASN1::BOOLEAN (1)
1589
+ * * OpenSSL::ASN1::INTEGER (2)
1590
+ * * OpenSSL::ASN1::BIT_STRING (3)
1591
+ * * OpenSSL::ASN1::OCTET_STRING (4)
1592
+ * * OpenSSL::ASN1::NULL (5)
1593
+ * * OpenSSL::ASN1::OBJECT (6)
1594
+ * * OpenSSL::ASN1::ENUMERATED (10)
1595
+ * * OpenSSL::ASN1::UTF8STRING (12)
1596
+ * * OpenSSL::ASN1::SEQUENCE (16)
1597
+ * * OpenSSL::ASN1::SET (17)
1598
+ * * OpenSSL::ASN1::NUMERICSTRING (18)
1599
+ * * OpenSSL::ASN1::PRINTABLESTRING (19)
1600
+ * * OpenSSL::ASN1::T61STRING (20)
1601
+ * * OpenSSL::ASN1::VIDEOTEXSTRING (21)
1602
+ * * OpenSSL::ASN1::IA5STRING (22)
1603
+ * * OpenSSL::ASN1::UTCTIME (23)
1604
+ * * OpenSSL::ASN1::GENERALIZEDTIME (24)
1605
+ * * OpenSSL::ASN1::GRAPHICSTRING (25)
1606
+ * * OpenSSL::ASN1::ISO64STRING (26)
1607
+ * * OpenSSL::ASN1::GENERALSTRING (27)
1608
+ * * OpenSSL::ASN1::UNIVERSALSTRING (28)
1609
+ * * OpenSSL::ASN1::BMPSTRING (30)
1610
+ *
1611
+ * == UNIVERSAL_TAG_NAME constant
1612
+ *
1613
+ * An Array that stores the name of a given tag number. These names are
1614
+ * the same as the name of the tag constant that is additionally defined,
1615
+ * e.g. UNIVERSAL_TAG_NAME[2] = "INTEGER" and OpenSSL::ASN1::INTEGER = 2.
1616
+ *
1617
+ * == Example usage
1618
+ *
1619
+ * === Decoding and viewing a DER-encoded file
1620
+ * require 'openssl'
1621
+ * require 'pp'
1622
+ * der = File.binread('data.der')
1623
+ * asn1 = OpenSSL::ASN1.decode(der)
1624
+ * pp der
1625
+ *
1626
+ * === Creating an ASN.1 structure and DER-encoding it
1627
+ * require 'openssl'
1628
+ * version = OpenSSL::ASN1::Integer.new(1)
1629
+ * # Explicitly 0-tagged implies context-specific tag class
1630
+ * serial = OpenSSL::ASN1::Integer.new(12345, 0, :EXPLICIT, :CONTEXT_SPECIFIC)
1631
+ * name = OpenSSL::ASN1::PrintableString.new('Data 1')
1632
+ * sequence = OpenSSL::ASN1::Sequence.new( [ version, serial, name ] )
1633
+ * der = sequence.to_der
1634
+ */
1635
+ mASN1 = rb_define_module_under(mOSSL, "ASN1");
1636
+
1637
+ /* Document-class: OpenSSL::ASN1::ASN1Error
1638
+ *
1639
+ * Generic error class for all errors raised in ASN1 and any of the
1640
+ * classes defined in it.
1641
+ */
1642
+ eASN1Error = rb_define_class_under(mASN1, "ASN1Error", eOSSLError);
1643
+ rb_define_module_function(mASN1, "traverse", ossl_asn1_traverse, 1);
1644
+ rb_define_module_function(mASN1, "decode", ossl_asn1_decode, 1);
1645
+ rb_define_module_function(mASN1, "decode_all", ossl_asn1_decode_all, 1);
1646
+ ary = rb_ary_new();
1647
+
1648
+ /*
1649
+ * Array storing tag names at the tag's index.
1650
+ */
1651
+ rb_define_const(mASN1, "UNIVERSAL_TAG_NAME", ary);
1652
+ for(i = 0; i < ossl_asn1_info_size; i++){
1653
+ if(ossl_asn1_info[i].name[0] == '[') continue;
1654
+ rb_define_const(mASN1, ossl_asn1_info[i].name, INT2NUM(i));
1655
+ rb_ary_store(ary, i, rb_str_new2(ossl_asn1_info[i].name));
1656
+ }
1657
+
1658
+ /* Document-class: OpenSSL::ASN1::ASN1Data
1659
+ *
1660
+ * The top-level class representing any ASN.1 object. When parsed by
1661
+ * ASN1.decode, tagged values are always represented by an instance
1662
+ * of ASN1Data.
1663
+ *
1664
+ * == The role of ASN1Data for parsing tagged values
1665
+ *
1666
+ * When encoding an ASN.1 type it is inherently clear what original
1667
+ * type (e.g. INTEGER, OCTET STRING etc.) this value has, regardless
1668
+ * of its tagging.
1669
+ * But opposed to the time an ASN.1 type is to be encoded, when parsing
1670
+ * them it is not possible to deduce the "real type" of tagged
1671
+ * values. This is why tagged values are generally parsed into ASN1Data
1672
+ * instances, but with a different outcome for implicit and explicit
1673
+ * tagging.
1674
+ *
1675
+ * === Example of a parsed implicitly tagged value
1676
+ *
1677
+ * An implicitly 1-tagged INTEGER value will be parsed as an
1678
+ * ASN1Data with
1679
+ * * +tag+ equal to 1
1680
+ * * +tag_class+ equal to +:CONTEXT_SPECIFIC+
1681
+ * * +value+ equal to a +String+ that carries the raw encoding
1682
+ * of the INTEGER.
1683
+ * This implies that a subsequent decoding step is required to
1684
+ * completely decode implicitly tagged values.
1685
+ *
1686
+ * === Example of a parsed explicitly tagged value
1687
+ *
1688
+ * An explicitly 1-tagged INTEGER value will be parsed as an
1689
+ * ASN1Data with
1690
+ * * +tag+ equal to 1
1691
+ * * +tag_class+ equal to +:CONTEXT_SPECIFIC+
1692
+ * * +value+ equal to an +Array+ with one single element, an
1693
+ * instance of OpenSSL::ASN1::Integer, i.e. the inner element
1694
+ * is the non-tagged primitive value, and the tagging is represented
1695
+ * in the outer ASN1Data
1696
+ *
1697
+ * == Example - Decoding an implicitly tagged INTEGER
1698
+ * int = OpenSSL::ASN1::Integer.new(1, 0, :IMPLICIT) # implicit 0-tagged
1699
+ * seq = OpenSSL::ASN1::Sequence.new( [int] )
1700
+ * der = seq.to_der
1701
+ * asn1 = OpenSSL::ASN1.decode(der)
1702
+ * # pp asn1 => #<OpenSSL::ASN1::Sequence:0x87326e0
1703
+ * # @infinite_length=false,
1704
+ * # @tag=16,
1705
+ * # @tag_class=:UNIVERSAL,
1706
+ * # @tagging=nil,
1707
+ * # @value=
1708
+ * # [#<OpenSSL::ASN1::ASN1Data:0x87326f4
1709
+ * # @infinite_length=false,
1710
+ * # @tag=0,
1711
+ * # @tag_class=:CONTEXT_SPECIFIC,
1712
+ * # @value="\x01">]>
1713
+ * raw_int = asn1.value[0]
1714
+ * # manually rewrite tag and tag class to make it an UNIVERSAL value
1715
+ * raw_int.tag = OpenSSL::ASN1::INTEGER
1716
+ * raw_int.tag_class = :UNIVERSAL
1717
+ * int2 = OpenSSL::ASN1.decode(raw_int)
1718
+ * puts int2.value # => 1
1719
+ *
1720
+ * == Example - Decoding an explicitly tagged INTEGER
1721
+ * int = OpenSSL::ASN1::Integer.new(1, 0, :EXPLICIT) # explicit 0-tagged
1722
+ * seq = OpenSSL::ASN1::Sequence.new( [int] )
1723
+ * der = seq.to_der
1724
+ * asn1 = OpenSSL::ASN1.decode(der)
1725
+ * # pp asn1 => #<OpenSSL::ASN1::Sequence:0x87326e0
1726
+ * # @infinite_length=false,
1727
+ * # @tag=16,
1728
+ * # @tag_class=:UNIVERSAL,
1729
+ * # @tagging=nil,
1730
+ * # @value=
1731
+ * # [#<OpenSSL::ASN1::ASN1Data:0x87326f4
1732
+ * # @infinite_length=false,
1733
+ * # @tag=0,
1734
+ * # @tag_class=:CONTEXT_SPECIFIC,
1735
+ * # @value=
1736
+ * # [#<OpenSSL::ASN1::Integer:0x85bf308
1737
+ * # @infinite_length=false,
1738
+ * # @tag=2,
1739
+ * # @tag_class=:UNIVERSAL
1740
+ * # @tagging=nil,
1741
+ * # @value=1>]>]>
1742
+ * int2 = asn1.value[0].value[0]
1743
+ * puts int2.value # => 1
1744
+ */
1745
+ cASN1Data = rb_define_class_under(mASN1, "ASN1Data", rb_cObject);
1746
+ /*
1747
+ * Carries the value of a ASN.1 type.
1748
+ * Please confer Constructive and Primitive for the mappings between
1749
+ * ASN.1 data types and Ruby classes.
1750
+ */
1751
+ rb_attr(cASN1Data, rb_intern("value"), 1, 1, 0);
1752
+ /*
1753
+ * A +Number+ representing the tag number of this ASN1Data. Never +nil+.
1754
+ */
1755
+ rb_attr(cASN1Data, rb_intern("tag"), 1, 1, 0);
1756
+ /*
1757
+ * A +Symbol+ representing the tag class of this ASN1Data. Never +nil+.
1758
+ * See ASN1Data for possible values.
1759
+ */
1760
+ rb_attr(cASN1Data, rb_intern("tag_class"), 1, 1, 0);
1761
+ /*
1762
+ * Never +nil+. A +Boolean+ indicating whether the encoding was infinite
1763
+ * length (in the case of parsing) or whether an infinite length encoding
1764
+ * shall be used (in the encoding case).
1765
+ * In DER, every value has a finite length associated with it. But in
1766
+ * scenarios where large amounts of data need to be transferred it
1767
+ * might be desirable to have some kind of streaming support available.
1768
+ * For example, huge OCTET STRINGs are preferably sent in smaller-sized
1769
+ * chunks, each at a time.
1770
+ * This is possible in BER by setting the length bytes of an encoding
1771
+ * to zero and by this indicating that the following value will be
1772
+ * sent in chunks. Infinite length encodings are always constructed.
1773
+ * The end of such a stream of chunks is indicated by sending a EOC
1774
+ * (End of Content) tag. SETs and SEQUENCEs may use an infinite length
1775
+ * encoding, but also primitive types such as e.g. OCTET STRINGS or
1776
+ * BIT STRINGS may leverage this functionality (cf. ITU-T X.690).
1777
+ */
1778
+ rb_attr(cASN1Data, rb_intern("infinite_length"), 1, 1, 0);
1779
+ rb_define_method(cASN1Data, "initialize", ossl_asn1data_initialize, 3);
1780
+ rb_define_method(cASN1Data, "to_der", ossl_asn1data_to_der, 0);
1781
+
1782
+ /* Document-class: OpenSSL::ASN1::Primitive
1783
+ *
1784
+ * The parent class for all primitive encodings. Attributes are the same as
1785
+ * for ASN1Data, with the addition of +tagging+.
1786
+ * Primitive values can never be infinite length encodings, thus it is not
1787
+ * possible to set the +infinite_length+ attribute for Primitive and its
1788
+ * sub-classes.
1789
+ *
1790
+ * == Primitive sub-classes and their mapping to Ruby classes
1791
+ * * OpenSSL::ASN1::EndOfContent <=> +value+ is always +nil+
1792
+ * * OpenSSL::ASN1::Boolean <=> +value+ is a +Boolean+
1793
+ * * OpenSSL::ASN1::Integer <=> +value+ is a +Number+
1794
+ * * OpenSSL::ASN1::BitString <=> +value+ is a +String+
1795
+ * * OpenSSL::ASN1::OctetString <=> +value+ is a +String+
1796
+ * * OpenSSL::ASN1::Null <=> +value+ is always +nil+
1797
+ * * OpenSSL::ASN1::Object <=> +value+ is a +String+
1798
+ * * OpenSSL::ASN1::Enumerated <=> +value+ is a +Number+
1799
+ * * OpenSSL::ASN1::UTF8String <=> +value+ is a +String+
1800
+ * * OpenSSL::ASN1::NumericString <=> +value+ is a +String+
1801
+ * * OpenSSL::ASN1::PrintableString <=> +value+ is a +String+
1802
+ * * OpenSSL::ASN1::T61String <=> +value+ is a +String+
1803
+ * * OpenSSL::ASN1::VideotexString <=> +value+ is a +String+
1804
+ * * OpenSSL::ASN1::IA5String <=> +value+ is a +String+
1805
+ * * OpenSSL::ASN1::UTCTime <=> +value+ is a +Time+
1806
+ * * OpenSSL::ASN1::GeneralizedTime <=> +value+ is a +Time+
1807
+ * * OpenSSL::ASN1::GraphicString <=> +value+ is a +String+
1808
+ * * OpenSSL::ASN1::ISO64String <=> +value+ is a +String+
1809
+ * * OpenSSL::ASN1::GeneralString <=> +value+ is a +String+
1810
+ * * OpenSSL::ASN1::UniversalString <=> +value+ is a +String+
1811
+ * * OpenSSL::ASN1::BMPString <=> +value+ is a +String+
1812
+ *
1813
+ * == OpenSSL::ASN1::BitString
1814
+ *
1815
+ * === Additional attributes
1816
+ * +unused_bits+: if the underlying BIT STRING's
1817
+ * length is a multiple of 8 then +unused_bits+ is 0. Otherwise
1818
+ * +unused_bits+ indicates the number of bits that are to be ignored in
1819
+ * the final octet of the +BitString+'s +value+.
1820
+ *
1821
+ * == OpenSSL::ASN1::ObjectId
1822
+ *
1823
+ * NOTE: While OpenSSL::ASN1::ObjectId.new will allocate a new ObjectId,
1824
+ * it is not typically allocated this way, but rather that are received from
1825
+ * parsed ASN1 encodings.
1826
+ *
1827
+ * === Additional attributes
1828
+ * * +sn+: the short name as defined in <openssl/objects.h>.
1829
+ * * +ln+: the long name as defined in <openssl/objects.h>.
1830
+ * * +oid+: the object identifier as a +String+, e.g. "1.2.3.4.5"
1831
+ * * +short_name+: alias for +sn+.
1832
+ * * +long_name+: alias for +ln+.
1833
+ *
1834
+ * == Examples
1835
+ * With the Exception of OpenSSL::ASN1::EndOfContent, each Primitive class
1836
+ * constructor takes at least one parameter, the +value+.
1837
+ *
1838
+ * === Creating EndOfContent
1839
+ * eoc = OpenSSL::ASN1::EndOfContent.new
1840
+ *
1841
+ * === Creating any other Primitive
1842
+ * prim = <class>.new(value) # <class> being one of the sub-classes except EndOfContent
1843
+ * prim_zero_tagged_implicit = <class>.new(value, 0, :IMPLICIT)
1844
+ * prim_zero_tagged_explicit = <class>.new(value, 0, :EXPLICIT)
1845
+ */
1846
+ cASN1Primitive = rb_define_class_under(mASN1, "Primitive", cASN1Data);
1847
+ /*
1848
+ * May be used as a hint for encoding a value either implicitly or
1849
+ * explicitly by setting it either to +:IMPLICIT+ or to +:EXPLICIT+.
1850
+ * +tagging+ is not set when a ASN.1 structure is parsed using
1851
+ * OpenSSL::ASN1.decode.
1852
+ */
1853
+ rb_attr(cASN1Primitive, rb_intern("tagging"), 1, 1, Qtrue);
1854
+ rb_undef_method(cASN1Primitive, "infinite_length=");
1855
+ rb_define_method(cASN1Primitive, "initialize", ossl_asn1_initialize, -1);
1856
+ rb_define_method(cASN1Primitive, "to_der", ossl_asn1prim_to_der, 0);
1857
+
1858
+ /* Document-class: OpenSSL::ASN1::Constructive
1859
+ *
1860
+ * The parent class for all constructed encodings. The +value+ attribute
1861
+ * of a Constructive is always an +Array+. Attributes are the same as
1862
+ * for ASN1Data, with the addition of +tagging+.
1863
+ *
1864
+ * == SET and SEQUENCE
1865
+ *
1866
+ * Most constructed encodings come in the form of a SET or a SEQUENCE.
1867
+ * These encodings are represented by one of the two sub-classes of
1868
+ * Constructive:
1869
+ * * OpenSSL::ASN1::Set
1870
+ * * OpenSSL::ASN1::Sequence
1871
+ * Please note that tagged sequences and sets are still parsed as
1872
+ * instances of ASN1Data. Find further details on tagged values
1873
+ * there.
1874
+ *
1875
+ * === Example - constructing a SEQUENCE
1876
+ * int = OpenSSL::ASN1::Integer.new(1)
1877
+ * str = OpenSSL::ASN1::PrintableString.new('abc')
1878
+ * sequence = OpenSSL::ASN1::Sequence.new( [ int, str ] )
1879
+ *
1880
+ * === Example - constructing a SET
1881
+ * int = OpenSSL::ASN1::Integer.new(1)
1882
+ * str = OpenSSL::ASN1::PrintableString.new('abc')
1883
+ * set = OpenSSL::ASN1::Set.new( [ int, str ] )
1884
+ *
1885
+ * == Infinite length primitive values
1886
+ *
1887
+ * The only case where Constructive is used directly is for infinite
1888
+ * length encodings of primitive values. These encodings are always
1889
+ * constructed, with the contents of the +value+ +Array+ being either
1890
+ * UNIVERSAL non-infinite length partial encodings of the actual value
1891
+ * or again constructive encodings with infinite length (i.e. infinite
1892
+ * length primitive encodings may be constructed recursively with another
1893
+ * infinite length value within an already infinite length value). Each
1894
+ * partial encoding must be of the same UNIVERSAL type as the overall
1895
+ * encoding. The value of the overall encoding consists of the
1896
+ * concatenation of each partial encoding taken in sequence. The +value+
1897
+ * array of the outer infinite length value must end with a
1898
+ * OpenSSL::ASN1::EndOfContent instance.
1899
+ *
1900
+ * Please note that it is not possible to encode Constructive without
1901
+ * the +infinite_length+ attribute being set to +true+, use
1902
+ * OpenSSL::ASN1::Sequence or OpenSSL::ASN1::Set in these cases instead.
1903
+ *
1904
+ * === Example - Infinite length OCTET STRING
1905
+ * partial1 = OpenSSL::ASN1::OctetString.new("\x01")
1906
+ * partial2 = OpenSSL::ASN1::OctetString.new("\x02")
1907
+ * inf_octets = OpenSSL::ASN1::Constructive.new( [ partial1,
1908
+ * partial2,
1909
+ * OpenSSL::ASN1::EndOfContent.new ],
1910
+ * OpenSSL::ASN1::OCTET_STRING,
1911
+ * nil,
1912
+ * :UNIVERSAL )
1913
+ * # The real value of inf_octets is "\x01\x02", i.e. the concatenation
1914
+ * # of partial1 and partial2
1915
+ * inf_octets.infinite_length = true
1916
+ * der = inf_octets.to_der
1917
+ * asn1 = OpenSSL::ASN1.decode(der)
1918
+ * puts asn1.infinite_length # => true
1919
+ */
1920
+ cASN1Constructive = rb_define_class_under(mASN1,"Constructive", cASN1Data);
1921
+ rb_include_module(cASN1Constructive, rb_mEnumerable);
1922
+ /*
1923
+ * May be used as a hint for encoding a value either implicitly or
1924
+ * explicitly by setting it either to +:IMPLICIT+ or to +:EXPLICIT+.
1925
+ * +tagging+ is not set when a ASN.1 structure is parsed using
1926
+ * OpenSSL::ASN1.decode.
1927
+ */
1928
+ rb_attr(cASN1Constructive, rb_intern("tagging"), 1, 1, Qtrue);
1929
+ rb_define_method(cASN1Constructive, "initialize", ossl_asn1_initialize, -1);
1930
+ rb_define_method(cASN1Constructive, "to_der", ossl_asn1cons_to_der, 0);
1931
+ rb_define_method(cASN1Constructive, "each", ossl_asn1cons_each, 0);
1932
+
1933
+ #define OSSL_ASN1_DEFINE_CLASS(name, super) \
1934
+ do{\
1935
+ cASN1##name = rb_define_class_under(mASN1, #name, cASN1##super);\
1936
+ rb_define_module_function(mASN1, #name, ossl_asn1_##name, -1);\
1937
+ }while(0)
1938
+
1939
+ OSSL_ASN1_DEFINE_CLASS(Boolean, Primitive);
1940
+ OSSL_ASN1_DEFINE_CLASS(Integer, Primitive);
1941
+ OSSL_ASN1_DEFINE_CLASS(Enumerated, Primitive);
1942
+ OSSL_ASN1_DEFINE_CLASS(BitString, Primitive);
1943
+ OSSL_ASN1_DEFINE_CLASS(OctetString, Primitive);
1944
+ OSSL_ASN1_DEFINE_CLASS(UTF8String, Primitive);
1945
+ OSSL_ASN1_DEFINE_CLASS(NumericString, Primitive);
1946
+ OSSL_ASN1_DEFINE_CLASS(PrintableString, Primitive);
1947
+ OSSL_ASN1_DEFINE_CLASS(T61String, Primitive);
1948
+ OSSL_ASN1_DEFINE_CLASS(VideotexString, Primitive);
1949
+ OSSL_ASN1_DEFINE_CLASS(IA5String, Primitive);
1950
+ OSSL_ASN1_DEFINE_CLASS(GraphicString, Primitive);
1951
+ OSSL_ASN1_DEFINE_CLASS(ISO64String, Primitive);
1952
+ OSSL_ASN1_DEFINE_CLASS(GeneralString, Primitive);
1953
+ OSSL_ASN1_DEFINE_CLASS(UniversalString, Primitive);
1954
+ OSSL_ASN1_DEFINE_CLASS(BMPString, Primitive);
1955
+ OSSL_ASN1_DEFINE_CLASS(Null, Primitive);
1956
+ OSSL_ASN1_DEFINE_CLASS(ObjectId, Primitive);
1957
+ OSSL_ASN1_DEFINE_CLASS(UTCTime, Primitive);
1958
+ OSSL_ASN1_DEFINE_CLASS(GeneralizedTime, Primitive);
1959
+
1960
+ OSSL_ASN1_DEFINE_CLASS(Sequence, Constructive);
1961
+ OSSL_ASN1_DEFINE_CLASS(Set, Constructive);
1962
+
1963
+ OSSL_ASN1_DEFINE_CLASS(EndOfContent, Data);
1964
+
1965
+
1966
+ /* Document-class: OpenSSL::ASN1::ObjectId
1967
+ *
1968
+ * Represents the primitive object id for OpenSSL::ASN1
1969
+ */
1970
+ #if 0
1971
+ cASN1ObjectId = rb_define_class_under(mASN1, "ObjectId", cASN1Primitive); /* let rdoc know */
1972
+ #endif
1973
+ rb_define_singleton_method(cASN1ObjectId, "register", ossl_asn1obj_s_register, 3);
1974
+ rb_define_method(cASN1ObjectId, "sn", ossl_asn1obj_get_sn, 0);
1975
+ rb_define_method(cASN1ObjectId, "ln", ossl_asn1obj_get_ln, 0);
1976
+ rb_define_method(cASN1ObjectId, "oid", ossl_asn1obj_get_oid, 0);
1977
+ rb_define_alias(cASN1ObjectId, "short_name", "sn");
1978
+ rb_define_alias(cASN1ObjectId, "long_name", "ln");
1979
+ rb_attr(cASN1BitString, rb_intern("unused_bits"), 1, 1, 0);
1980
+
1981
+ rb_define_method(cASN1EndOfContent, "initialize", ossl_asn1eoc_initialize, 0);
1982
+
1983
+ class_tag_map = rb_hash_new();
1984
+ rb_hash_aset(class_tag_map, cASN1EndOfContent, INT2NUM(V_ASN1_EOC));
1985
+ rb_hash_aset(class_tag_map, cASN1Boolean, INT2NUM(V_ASN1_BOOLEAN));
1986
+ rb_hash_aset(class_tag_map, cASN1Integer, INT2NUM(V_ASN1_INTEGER));
1987
+ rb_hash_aset(class_tag_map, cASN1BitString, INT2NUM(V_ASN1_BIT_STRING));
1988
+ rb_hash_aset(class_tag_map, cASN1OctetString, INT2NUM(V_ASN1_OCTET_STRING));
1989
+ rb_hash_aset(class_tag_map, cASN1Null, INT2NUM(V_ASN1_NULL));
1990
+ rb_hash_aset(class_tag_map, cASN1ObjectId, INT2NUM(V_ASN1_OBJECT));
1991
+ rb_hash_aset(class_tag_map, cASN1Enumerated, INT2NUM(V_ASN1_ENUMERATED));
1992
+ rb_hash_aset(class_tag_map, cASN1UTF8String, INT2NUM(V_ASN1_UTF8STRING));
1993
+ rb_hash_aset(class_tag_map, cASN1Sequence, INT2NUM(V_ASN1_SEQUENCE));
1994
+ rb_hash_aset(class_tag_map, cASN1Set, INT2NUM(V_ASN1_SET));
1995
+ rb_hash_aset(class_tag_map, cASN1NumericString, INT2NUM(V_ASN1_NUMERICSTRING));
1996
+ rb_hash_aset(class_tag_map, cASN1PrintableString, INT2NUM(V_ASN1_PRINTABLESTRING));
1997
+ rb_hash_aset(class_tag_map, cASN1T61String, INT2NUM(V_ASN1_T61STRING));
1998
+ rb_hash_aset(class_tag_map, cASN1VideotexString, INT2NUM(V_ASN1_VIDEOTEXSTRING));
1999
+ rb_hash_aset(class_tag_map, cASN1IA5String, INT2NUM(V_ASN1_IA5STRING));
2000
+ rb_hash_aset(class_tag_map, cASN1UTCTime, INT2NUM(V_ASN1_UTCTIME));
2001
+ rb_hash_aset(class_tag_map, cASN1GeneralizedTime, INT2NUM(V_ASN1_GENERALIZEDTIME));
2002
+ rb_hash_aset(class_tag_map, cASN1GraphicString, INT2NUM(V_ASN1_GRAPHICSTRING));
2003
+ rb_hash_aset(class_tag_map, cASN1ISO64String, INT2NUM(V_ASN1_ISO64STRING));
2004
+ rb_hash_aset(class_tag_map, cASN1GeneralString, INT2NUM(V_ASN1_GENERALSTRING));
2005
+ rb_hash_aset(class_tag_map, cASN1UniversalString, INT2NUM(V_ASN1_UNIVERSALSTRING));
2006
+ rb_hash_aset(class_tag_map, cASN1BMPString, INT2NUM(V_ASN1_BMPSTRING));
2007
+ rb_global_variable(&class_tag_map);
2008
+ }