py2docfx 0.1.16rc2051518__py3-none-any.whl → 0.1.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (620) hide show
  1. py2docfx/docfx_yaml/miss_reference.py +1 -1
  2. py2docfx/docfx_yaml/parameter_utils.py +58 -6
  3. py2docfx/docfx_yaml/tests/roots/test-translator-typing/code_with_typing.py +14 -0
  4. py2docfx/docfx_yaml/tests/roots/test-translator-typing/conf.py +18 -0
  5. py2docfx/docfx_yaml/tests/test_translator_typing.py +39 -0
  6. py2docfx/docfx_yaml/utils.py +2 -2
  7. py2docfx/venv/basevenv/Lib/site-packages/babel/py.typed +1 -0
  8. py2docfx/venv/basevenv/Lib/site-packages/certifi/__init__.py +1 -1
  9. py2docfx/venv/basevenv/Lib/site-packages/certifi/core.py +1 -32
  10. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/cli/__main__.py +62 -2
  11. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/constant.py +17 -0
  12. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/legacy.py +1 -3
  13. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/md.py +19 -14
  14. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/utils.py +6 -0
  15. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/version.py +1 -1
  16. py2docfx/venv/basevenv/Lib/site-packages/markupsafe/_speedups.pyi +1 -0
  17. py2docfx/venv/basevenv/Lib/site-packages/markupsafe/py.typed +0 -0
  18. py2docfx/venv/basevenv/Lib/site-packages/packaging/__init__.py +1 -1
  19. py2docfx/venv/basevenv/Lib/site-packages/packaging/_elffile.py +1 -2
  20. py2docfx/venv/basevenv/Lib/site-packages/packaging/_manylinux.py +1 -2
  21. py2docfx/venv/basevenv/Lib/site-packages/packaging/_parser.py +1 -2
  22. py2docfx/venv/basevenv/Lib/site-packages/packaging/_tokenizer.py +5 -4
  23. py2docfx/venv/basevenv/Lib/site-packages/packaging/licenses/__init__.py +1 -1
  24. py2docfx/venv/basevenv/Lib/site-packages/packaging/markers.py +53 -22
  25. py2docfx/venv/basevenv/Lib/site-packages/packaging/metadata.py +1 -2
  26. py2docfx/venv/basevenv/Lib/site-packages/packaging/py.typed +0 -0
  27. py2docfx/venv/basevenv/Lib/site-packages/packaging/specifiers.py +1 -2
  28. py2docfx/venv/basevenv/Lib/site-packages/packaging/tags.py +39 -0
  29. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/cachecontrol/py.typed +0 -0
  30. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/certifi/py.typed +0 -0
  31. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/chardet/py.typed +0 -0
  32. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/distro/py.typed +0 -0
  33. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/idna/py.typed +0 -0
  34. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/packaging/py.typed +0 -0
  35. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/platformdirs/py.typed +0 -0
  36. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/pyparsing/py.typed +0 -0
  37. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/resolvelib/py.typed +0 -0
  38. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/rich/py.typed +0 -0
  39. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/tenacity/py.typed +0 -0
  40. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/tomli/py.typed +1 -0
  41. py2docfx/venv/basevenv/Lib/site-packages/pip/_vendor/truststore/py.typed +0 -0
  42. py2docfx/venv/basevenv/Lib/site-packages/pip/py.typed +4 -0
  43. py2docfx/venv/basevenv/Lib/site-packages/pkg_resources/__init__.py +6 -7
  44. py2docfx/venv/basevenv/Lib/site-packages/pkg_resources/py.typed +0 -0
  45. py2docfx/venv/basevenv/Lib/site-packages/pygments/__init__.py +1 -1
  46. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/_sql_builtins.py +106 -0
  47. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/scripting.py +5 -3
  48. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/sql.py +24 -118
  49. py2docfx/venv/basevenv/Lib/site-packages/requests/__version__.py +2 -2
  50. py2docfx/venv/basevenv/Lib/site-packages/requests/compat.py +12 -0
  51. py2docfx/venv/basevenv/Lib/site-packages/requests/models.py +3 -1
  52. py2docfx/venv/basevenv/Lib/site-packages/requests/utils.py +6 -16
  53. py2docfx/venv/basevenv/Lib/site-packages/setuptools/__init__.py +0 -38
  54. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_discovery.py +33 -0
  55. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +1 -1
  56. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/command/config.py +0 -2
  57. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_unix.py +63 -0
  58. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/compilers/C/unix.py +5 -6
  59. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_entry_points.py +4 -0
  60. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_normalization.py +0 -2
  61. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_path.py +12 -3
  62. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_reqs.py +1 -1
  63. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_scripts.py +361 -0
  64. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_shutil.py +6 -0
  65. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/importlib_metadata/py.typed +0 -0
  66. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/inflect/py.typed +0 -0
  67. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/jaraco/collections/py.typed +0 -0
  68. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/jaraco/functools/__init__.pyi +125 -0
  69. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/jaraco/functools/py.typed +0 -0
  70. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/more_itertools/__init__.pyi +2 -0
  71. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/more_itertools/more.pyi +709 -0
  72. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/more_itertools/py.typed +0 -0
  73. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/more_itertools/recipes.pyi +136 -0
  74. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/packaging/py.typed +0 -0
  75. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/platformdirs/py.typed +0 -0
  76. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/tomli/py.typed +1 -0
  77. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_vendor/typeguard/py.typed +0 -0
  78. py2docfx/venv/basevenv/Lib/site-packages/setuptools/build_meta.py +25 -37
  79. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/bdist_egg.py +9 -11
  80. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/bdist_wheel.py +1 -1
  81. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/build_ext.py +29 -28
  82. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/develop.py +39 -179
  83. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/easy_install.py +17 -2352
  84. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/editable_wheel.py +14 -31
  85. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/egg_info.py +0 -2
  86. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/install.py +3 -55
  87. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/install_scripts.py +5 -11
  88. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/sdist.py +1 -1
  89. py2docfx/venv/basevenv/Lib/site-packages/setuptools/compat/py310.py +11 -0
  90. py2docfx/venv/basevenv/Lib/site-packages/setuptools/dist.py +10 -12
  91. py2docfx/venv/basevenv/Lib/site-packages/setuptools/installer.py +34 -29
  92. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/contexts.py +0 -14
  93. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/fixtures.py +235 -0
  94. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/integration/test_pbr.py +20 -0
  95. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_build_meta.py +0 -24
  96. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_develop.py +1 -64
  97. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_dist.py +2 -2
  98. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_dist_info.py +0 -63
  99. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_editable_install.py +15 -41
  100. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_egg_info.py +3 -2
  101. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_scripts.py +12 -0
  102. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_wheel.py +12 -36
  103. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_windows_wrappers.py +3 -4
  104. py2docfx/venv/basevenv/Lib/site-packages/setuptools/wheel.py +49 -24
  105. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/__init__.py +6 -0
  106. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/arabic_stemmer.py +798 -797
  107. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/armenian_stemmer.py +212 -213
  108. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/basestemmer.py +20 -54
  109. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/basque_stemmer.py +202 -228
  110. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/catalan_stemmer.py +370 -375
  111. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/danish_stemmer.py +63 -61
  112. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/dutch_porter_stemmer.py +466 -0
  113. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/dutch_stemmer.py +1217 -343
  114. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/english_stemmer.py +295 -264
  115. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/esperanto_stemmer.py +588 -0
  116. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/estonian_stemmer.py +850 -0
  117. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/finnish_stemmer.py +144 -143
  118. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/french_stemmer.py +308 -246
  119. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/german_stemmer.py +224 -167
  120. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/greek_stemmer.py +1314 -1313
  121. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/hindi_stemmer.py +39 -38
  122. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/hungarian_stemmer.py +231 -256
  123. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/indonesian_stemmer.py +61 -64
  124. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/irish_stemmer.py +101 -106
  125. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/italian_stemmer.py +272 -272
  126. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/lithuanian_stemmer.py +233 -240
  127. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/nepali_stemmer.py +108 -134
  128. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/norwegian_stemmer.py +108 -63
  129. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/porter_stemmer.py +101 -108
  130. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/portuguese_stemmer.py +241 -250
  131. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/romanian_stemmer.py +332 -296
  132. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/russian_stemmer.py +178 -179
  133. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/serbian_stemmer.py +2331 -2332
  134. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/spanish_stemmer.py +254 -259
  135. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/swedish_stemmer.py +143 -70
  136. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/tamil_stemmer.py +638 -1491
  137. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/turkish_stemmer.py +326 -292
  138. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/yiddish_stemmer.py +245 -246
  139. py2docfx/venv/basevenv/Lib/site-packages/sphinx/py.typed +0 -0
  140. py2docfx/venv/basevenv/Lib/site-packages/sphinxcontrib/applehelp/py.typed +0 -0
  141. py2docfx/venv/basevenv/Lib/site-packages/sphinxcontrib/htmlhelp/py.typed +0 -0
  142. py2docfx/venv/basevenv/Lib/site-packages/sphinxcontrib/qthelp/py.typed +0 -0
  143. py2docfx/venv/basevenv/Lib/site-packages/sphinxcontrib/serializinghtml/py.typed +0 -0
  144. py2docfx/venv/basevenv/Lib/site-packages/urllib3/_version.py +9 -4
  145. py2docfx/venv/basevenv/Lib/site-packages/urllib3/connection.py +87 -38
  146. py2docfx/venv/basevenv/Lib/site-packages/urllib3/contrib/emscripten/fetch.py +20 -0
  147. py2docfx/venv/basevenv/Lib/site-packages/urllib3/contrib/emscripten/response.py +8 -16
  148. py2docfx/venv/basevenv/Lib/site-packages/urllib3/contrib/pyopenssl.py +10 -0
  149. py2docfx/venv/basevenv/Lib/site-packages/urllib3/exceptions.py +12 -4
  150. py2docfx/venv/basevenv/Lib/site-packages/urllib3/http2/connection.py +1 -1
  151. py2docfx/venv/basevenv/Lib/site-packages/urllib3/poolmanager.py +17 -1
  152. py2docfx/venv/basevenv/Lib/site-packages/urllib3/py.typed +2 -0
  153. py2docfx/venv/basevenv/Lib/site-packages/urllib3/response.py +53 -24
  154. py2docfx/venv/basevenv/Lib/site-packages/urllib3/util/request.py +12 -4
  155. py2docfx/venv/basevenv/Lib/site-packages/urllib3/util/ssl_.py +22 -2
  156. py2docfx/venv/basevenv/Lib/site-packages/urllib3/util/ssl_match_hostname.py +1 -1
  157. py2docfx/venv/basevenv/Lib/site-packages/wheel/__init__.py +1 -1
  158. py2docfx/venv/basevenv/Lib/site-packages/wheel/__main__.py +7 -5
  159. py2docfx/venv/{venv1/Lib/site-packages/wheel/cli → basevenv/Lib/site-packages/wheel/_commands}/__init__.py +3 -5
  160. py2docfx/venv/{venv1/Lib/site-packages/wheel/cli → basevenv/Lib/site-packages/wheel/_commands}/convert.py +14 -9
  161. py2docfx/venv/{venv1/Lib/site-packages/wheel/cli → basevenv/Lib/site-packages/wheel/_commands}/pack.py +1 -2
  162. py2docfx/venv/basevenv/Lib/site-packages/wheel/{cli → _commands}/tags.py +4 -3
  163. py2docfx/venv/basevenv/Lib/site-packages/wheel/_metadata.py +184 -0
  164. py2docfx/venv/basevenv/Lib/site-packages/wheel/bdist_wheel.py +12 -23
  165. py2docfx/venv/basevenv/Lib/site-packages/wheel/macosx_libfile.py +4 -0
  166. py2docfx/venv/basevenv/Lib/site-packages/wheel/metadata.py +17 -183
  167. py2docfx/venv/basevenv/Lib/site-packages/wheel/wheelfile.py +30 -16
  168. py2docfx/venv/venv1/Lib/site-packages/azure/core/_version.py +1 -1
  169. py2docfx/venv/venv1/Lib/site-packages/azure/core/credentials.py +5 -4
  170. py2docfx/venv/venv1/Lib/site-packages/azure/core/instrumentation.py +67 -0
  171. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/_base.py +3 -1
  172. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/_base_async.py +1 -1
  173. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/_tools.py +1 -1
  174. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_authentication.py +4 -4
  175. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_authentication_async.py +1 -2
  176. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_distributed_tracing.py +152 -29
  177. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_redirect.py +3 -2
  178. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_redirect_async.py +2 -2
  179. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_retry.py +3 -10
  180. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_retry_async.py +3 -8
  181. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_universal.py +2 -0
  182. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_aiohttp.py +1 -2
  183. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_base_async.py +2 -1
  184. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_requests_asyncio.py +1 -1
  185. py2docfx/venv/venv1/Lib/site-packages/azure/core/polling/base_polling.py +3 -3
  186. py2docfx/venv/venv1/Lib/site-packages/azure/core/py.typed +0 -0
  187. py2docfx/venv/venv1/Lib/site-packages/azure/core/rest/_aiohttp.py +2 -2
  188. py2docfx/venv/venv1/Lib/site-packages/azure/core/rest/_http_response_impl_async.py +3 -0
  189. py2docfx/venv/venv1/Lib/site-packages/azure/core/rest/_requests_asyncio.py +1 -1
  190. py2docfx/venv/venv1/Lib/site-packages/azure/core/rest/_rest_py3.py +2 -2
  191. py2docfx/venv/venv1/Lib/site-packages/azure/core/settings.py +27 -21
  192. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/__init__.py +3 -7
  193. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/_abstract_span.py +2 -35
  194. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/_models.py +71 -0
  195. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/common.py +12 -4
  196. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/decorator.py +66 -13
  197. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/decorator_async.py +62 -23
  198. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/ext/opencensus_span/py.typed +0 -0
  199. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/opentelemetry.py +256 -0
  200. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_connection_string_parser.py +1 -2
  201. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_messaging_shared.py +1 -1
  202. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_pipeline_transport_rest_shared.py +1 -1
  203. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_pipeline_transport_rest_shared_async.py +2 -1
  204. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_utils.py +2 -2
  205. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_constants.py +1 -0
  206. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/default.py +23 -2
  207. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/environment.py +12 -16
  208. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/service_fabric.py +22 -1
  209. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/user_password.py +10 -6
  210. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/vscode.py +13 -4
  211. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/auth_code_redirect_handler.py +3 -5
  212. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/msal_client.py +2 -1
  213. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_persistent_cache.py +3 -2
  214. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_version.py +1 -1
  215. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azd_cli.py +1 -1
  216. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_cli.py +1 -1
  217. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_powershell.py +1 -1
  218. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/chained.py +1 -1
  219. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/default.py +22 -2
  220. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/environment.py +2 -2
  221. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/service_fabric.py +17 -1
  222. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/vscode.py +4 -4
  223. py2docfx/venv/venv1/Lib/site-packages/azure/identity/py.typed +0 -0
  224. py2docfx/venv/venv1/Lib/site-packages/certifi/__init__.py +1 -1
  225. py2docfx/venv/venv1/Lib/site-packages/certifi/core.py +1 -32
  226. py2docfx/venv/venv1/Lib/site-packages/certifi/py.typed +0 -0
  227. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/cli/__main__.py +62 -2
  228. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/constant.py +17 -0
  229. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/legacy.py +1 -3
  230. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/md.py +19 -14
  231. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/py.typed +0 -0
  232. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/utils.py +6 -0
  233. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/version.py +1 -1
  234. py2docfx/venv/venv1/Lib/site-packages/cryptography/__about__.py +2 -2
  235. py2docfx/venv/venv1/Lib/site-packages/cryptography/__init__.py +2 -2
  236. py2docfx/venv/venv1/Lib/site-packages/cryptography/fernet.py +2 -1
  237. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/_oid.py +35 -2
  238. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/backends/openssl/backend.py +33 -10
  239. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +37 -0
  240. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/_openssl.pyi +8 -0
  241. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/asn1.pyi +7 -0
  242. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/exceptions.pyi +17 -0
  243. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +117 -0
  244. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +75 -0
  245. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/aead.pyi +107 -0
  246. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +38 -0
  247. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/cmac.pyi +18 -0
  248. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/dh.pyi +51 -0
  249. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/dsa.pyi +41 -0
  250. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ec.pyi +52 -0
  251. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed25519.pyi +13 -0
  252. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed448.pyi +13 -0
  253. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +28 -0
  254. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/hmac.pyi +22 -0
  255. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +49 -0
  256. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +34 -0
  257. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/poly1305.pyi +15 -0
  258. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/rsa.pyi +55 -0
  259. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +13 -0
  260. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +13 -0
  261. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +52 -0
  262. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +50 -0
  263. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +23 -0
  264. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +313 -0
  265. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +9 -1
  266. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/binding.py +2 -1
  267. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +5 -0
  268. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/_cipheralgorithm.py +4 -2
  269. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/_serialization.py +1 -2
  270. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py +12 -0
  271. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/dsa.py +16 -3
  272. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py +47 -3
  273. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py +16 -3
  274. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ed448.py +16 -3
  275. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +14 -0
  276. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py +14 -1
  277. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/x448.py +14 -1
  278. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +6 -6
  279. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/base.py +5 -4
  280. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +18 -18
  281. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/hashes.py +5 -1
  282. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py +5 -4
  283. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +4 -4
  284. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +7 -4
  285. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py +1 -1
  286. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/x963kdf.py +1 -1
  287. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/padding.py +7 -121
  288. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/__init__.py +2 -0
  289. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py +21 -1
  290. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/pkcs7.py +48 -6
  291. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +68 -18
  292. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/twofactor/hotp.py +3 -2
  293. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/twofactor/totp.py +2 -1
  294. py2docfx/venv/venv1/Lib/site-packages/cryptography/py.typed +0 -0
  295. py2docfx/venv/venv1/Lib/site-packages/cryptography/utils.py +15 -3
  296. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/__init__.py +3 -0
  297. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/base.py +39 -6
  298. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/extensions.py +100 -49
  299. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/name.py +27 -15
  300. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/ocsp.py +60 -25
  301. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/oid.py +2 -0
  302. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/verification.py +6 -0
  303. py2docfx/venv/venv1/Lib/site-packages/google/api/annotations_pb2.pyi +24 -0
  304. py2docfx/venv/venv1/Lib/site-packages/google/api/auth_pb2.pyi +120 -0
  305. py2docfx/venv/venv1/Lib/site-packages/google/api/backend_pb2.pyi +102 -0
  306. py2docfx/venv/venv1/Lib/site-packages/google/api/billing_pb2.pyi +50 -0
  307. py2docfx/venv/venv1/Lib/site-packages/google/api/client_pb2.pyi +405 -0
  308. py2docfx/venv/venv1/Lib/site-packages/google/api/config_change_pb2.pyi +65 -0
  309. py2docfx/venv/venv1/Lib/site-packages/google/api/consumer_pb2.pyi +62 -0
  310. py2docfx/venv/venv1/Lib/site-packages/google/api/context_pb2.pyi +60 -0
  311. py2docfx/venv/venv1/Lib/site-packages/google/api/control_pb2.pyi +43 -0
  312. py2docfx/venv/venv1/Lib/site-packages/google/api/distribution_pb2.pyi +144 -0
  313. py2docfx/venv/venv1/Lib/site-packages/google/api/documentation_pb2.pyi +86 -0
  314. py2docfx/venv/venv1/Lib/site-packages/google/api/endpoint_pb2.pyi +41 -0
  315. py2docfx/venv/venv1/Lib/site-packages/google/api/error_reason_pb2.pyi +90 -0
  316. py2docfx/venv/venv1/Lib/site-packages/google/api/field_behavior_pb2.pyi +45 -0
  317. py2docfx/venv/venv1/Lib/site-packages/google/api/field_info_pb2.pyi +60 -0
  318. py2docfx/venv/venv1/Lib/site-packages/google/api/http_pb2.pyi +94 -0
  319. py2docfx/venv/venv1/Lib/site-packages/google/api/httpbody_pb2.pyi +41 -0
  320. py2docfx/venv/venv1/Lib/site-packages/google/api/label_pb2.pyi +47 -0
  321. py2docfx/venv/venv1/Lib/site-packages/google/api/launch_stage_pb2.pyi +40 -0
  322. py2docfx/venv/venv1/Lib/site-packages/google/api/log_pb2.pyi +47 -0
  323. py2docfx/venv/venv1/Lib/site-packages/google/api/logging_pb2.pyi +57 -0
  324. py2docfx/venv/venv1/Lib/site-packages/google/api/metric_pb2.pyi +186 -0
  325. py2docfx/venv/venv1/Lib/site-packages/google/api/monitored_resource_pb2.pyi +104 -0
  326. py2docfx/venv/venv1/Lib/site-packages/google/api/monitoring_pb2.pyi +57 -0
  327. py2docfx/venv/venv1/Lib/site-packages/google/api/policy_pb2.pyi +57 -0
  328. py2docfx/venv/venv1/Lib/site-packages/google/api/quota_pb2.pyi +116 -0
  329. py2docfx/venv/venv1/Lib/site-packages/google/api/resource_pb2.pyi +93 -0
  330. py2docfx/venv/venv1/Lib/site-packages/google/api/routing_pb2.pyi +49 -0
  331. py2docfx/venv/venv1/Lib/site-packages/google/api/service_pb2.pyi +170 -0
  332. py2docfx/venv/venv1/Lib/site-packages/google/api/source_info_pb2.pyi +34 -0
  333. py2docfx/venv/venv1/Lib/site-packages/google/api/system_parameter_pb2.pyi +60 -0
  334. py2docfx/venv/venv1/Lib/site-packages/google/api/usage_pb2.pyi +55 -0
  335. py2docfx/venv/venv1/Lib/site-packages/google/api/visibility_pb2.pyi +56 -0
  336. py2docfx/venv/venv1/Lib/site-packages/google/api_core/bidi.py +17 -4
  337. py2docfx/venv/venv1/Lib/site-packages/google/api_core/client_info.py +6 -0
  338. py2docfx/venv/venv1/Lib/site-packages/google/api_core/gapic_v1/client_info.py +1 -0
  339. py2docfx/venv/venv1/Lib/site-packages/google/api_core/py.typed +2 -0
  340. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_base.py +13 -4
  341. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_streaming.py +7 -6
  342. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_streaming_async.py +8 -5
  343. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_unary.py +7 -6
  344. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_unary_async.py +7 -6
  345. py2docfx/venv/venv1/Lib/site-packages/google/api_core/version.py +1 -1
  346. py2docfx/venv/venv1/Lib/site-packages/google/auth/_default.py +2 -36
  347. py2docfx/venv/venv1/Lib/site-packages/google/auth/_helpers.py +240 -0
  348. py2docfx/venv/venv1/Lib/site-packages/google/auth/aio/_helpers.py +62 -0
  349. py2docfx/venv/venv1/Lib/site-packages/google/auth/aio/transport/aiohttp.py +6 -0
  350. py2docfx/venv/venv1/Lib/site-packages/google/auth/compute_engine/_metadata.py +5 -1
  351. py2docfx/venv/venv1/Lib/site-packages/google/auth/compute_engine/credentials.py +2 -1
  352. py2docfx/venv/venv1/Lib/site-packages/google/auth/identity_pool.py +91 -2
  353. py2docfx/venv/venv1/Lib/site-packages/google/auth/impersonated_credentials.py +75 -0
  354. py2docfx/venv/venv1/Lib/site-packages/google/auth/py.typed +2 -0
  355. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/__init__.py +1 -0
  356. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/_aiohttp_requests.py +8 -1
  357. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/_http_client.py +3 -1
  358. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/requests.py +4 -1
  359. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/urllib3.py +15 -5
  360. py2docfx/venv/venv1/Lib/site-packages/google/auth/version.py +1 -1
  361. py2docfx/venv/venv1/Lib/site-packages/google/cloud/extended_operations_pb2.pyi +45 -0
  362. py2docfx/venv/venv1/Lib/site-packages/google/cloud/location/locations_pb2.pyi +96 -0
  363. py2docfx/venv/venv1/Lib/site-packages/google/gapic/metadata/gapic_metadata_pb2.pyi +118 -0
  364. py2docfx/venv/venv1/Lib/site-packages/google/logging/type/http_request_pb2.pyi +91 -0
  365. py2docfx/venv/venv1/Lib/site-packages/google/logging/type/log_severity_pb2.pyi +42 -0
  366. py2docfx/venv/venv1/Lib/site-packages/google/longrunning/operations_proto_pb2.pyi +126 -0
  367. py2docfx/venv/venv1/Lib/site-packages/google/oauth2/id_token.py +12 -0
  368. py2docfx/venv/venv1/Lib/site-packages/google/oauth2/py.typed +2 -0
  369. py2docfx/venv/venv1/Lib/site-packages/google/oauth2/webauthn_types.py +1 -1
  370. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/__init__.py +1 -1
  371. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/any.py +15 -1
  372. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/any_pb2.py +3 -3
  373. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/api_pb2.py +3 -3
  374. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/compiler/plugin_pb2.py +3 -3
  375. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor.py +15 -2
  376. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pb2.py +258 -113
  377. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pool.py +22 -8
  378. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/duration_pb2.py +3 -3
  379. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/empty_pb2.py +3 -3
  380. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/field_mask_pb2.py +3 -3
  381. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/decoder.py +106 -23
  382. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/field_mask.py +3 -1
  383. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_edition_defaults.py +1 -1
  384. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_message.py +21 -18
  385. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/testing_refleaks.py +8 -2
  386. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/well_known_types.py +60 -43
  387. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/json_format.py +4 -5
  388. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/message_factory.py +16 -0
  389. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/runtime_version.py +2 -2
  390. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/source_context_pb2.py +3 -3
  391. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/struct_pb2.py +3 -3
  392. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/text_format.py +11 -7
  393. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/timestamp_pb2.py +3 -3
  394. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/type_pb2.py +3 -3
  395. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/wrappers_pb2.py +3 -3
  396. py2docfx/venv/venv1/Lib/site-packages/google/rpc/code_pb2.pyi +58 -0
  397. py2docfx/venv/venv1/Lib/site-packages/google/rpc/context/attribute_context_pb2.pyi +309 -0
  398. py2docfx/venv/venv1/Lib/site-packages/google/rpc/context/audit_context_pb2.pyi +51 -0
  399. py2docfx/venv/venv1/Lib/site-packages/google/rpc/error_details_pb2.py +29 -23
  400. py2docfx/venv/venv1/Lib/site-packages/google/rpc/error_details_pb2.pyi +246 -0
  401. py2docfx/venv/venv1/Lib/site-packages/google/rpc/http_pb2.pyi +71 -0
  402. py2docfx/venv/venv1/Lib/site-packages/google/rpc/status_pb2.pyi +41 -0
  403. py2docfx/venv/venv1/Lib/site-packages/google/type/calendar_period_pb2.pyi +40 -0
  404. py2docfx/venv/venv1/Lib/site-packages/google/type/color_pb2.pyi +42 -0
  405. py2docfx/venv/venv1/Lib/site-packages/google/type/date_pb2.pyi +36 -0
  406. py2docfx/venv/venv1/Lib/site-packages/google/type/datetime_pb2.pyi +77 -0
  407. py2docfx/venv/venv1/Lib/site-packages/google/type/dayofweek_pb2.pyi +40 -0
  408. py2docfx/venv/venv1/Lib/site-packages/google/type/decimal_pb2.pyi +27 -0
  409. py2docfx/venv/venv1/Lib/site-packages/google/type/expr_pb2.pyi +39 -0
  410. py2docfx/venv/venv1/Lib/site-packages/google/type/fraction_pb2.pyi +31 -0
  411. py2docfx/venv/venv1/Lib/site-packages/google/type/interval_pb2.pyi +36 -0
  412. py2docfx/venv/venv1/Lib/site-packages/google/type/latlng_pb2.pyi +31 -0
  413. py2docfx/venv/venv1/Lib/site-packages/google/type/localized_text_pb2.pyi +31 -0
  414. py2docfx/venv/venv1/Lib/site-packages/google/type/money_pb2.pyi +36 -0
  415. py2docfx/venv/venv1/Lib/site-packages/google/type/month_pb2.pyi +50 -0
  416. py2docfx/venv/venv1/Lib/site-packages/google/type/phone_number_pb2.pyi +48 -0
  417. py2docfx/venv/venv1/Lib/site-packages/google/type/postal_address_pb2.pyi +74 -0
  418. py2docfx/venv/venv1/Lib/site-packages/google/type/quaternion_pb2.pyi +39 -0
  419. py2docfx/venv/venv1/Lib/site-packages/google/type/timeofday_pb2.pyi +39 -0
  420. py2docfx/venv/venv1/Lib/site-packages/idna/py.typed +0 -0
  421. py2docfx/venv/venv1/Lib/site-packages/jwt/py.typed +0 -0
  422. py2docfx/venv/venv1/Lib/site-packages/msal/application.py +1 -0
  423. py2docfx/venv/venv1/Lib/site-packages/msal/individual_cache.py +9 -5
  424. py2docfx/venv/venv1/Lib/site-packages/msal/managed_identity.py +4 -5
  425. py2docfx/venv/venv1/Lib/site-packages/msal/sku.py +1 -1
  426. py2docfx/venv/venv1/Lib/site-packages/msal/throttled_http_client.py +58 -30
  427. py2docfx/venv/venv1/Lib/site-packages/opencensus/__init__.py +1 -1
  428. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/__init__.py +1 -1
  429. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/__init__.py +1 -1
  430. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/__init__.py +138 -138
  431. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/exporter.py +93 -93
  432. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/processor.py +63 -63
  433. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/protocol.py +206 -206
  434. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/storage.py +205 -205
  435. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/transport.py +355 -355
  436. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/utils.py +79 -79
  437. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/version.py +15 -15
  438. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/log_exporter/__init__.py +314 -314
  439. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/__init__.py +190 -190
  440. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/__init__.py +62 -62
  441. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/cpu.py +50 -50
  442. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/http_requests.py +176 -176
  443. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/memory.py +42 -42
  444. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/process.py +87 -87
  445. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/__init__.py +1 -1
  446. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/state.py +50 -50
  447. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/statsbeat.py +100 -100
  448. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/statsbeat_metrics.py +480 -480
  449. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/trace_exporter/__init__.py +236 -236
  450. py2docfx/venv/venv1/Lib/site-packages/packaging/__init__.py +15 -0
  451. py2docfx/venv/{basevenv/Lib/site-packages/wheel/vendored → venv1/Lib/site-packages}/packaging/_elffile.py +10 -9
  452. py2docfx/venv/venv1/Lib/site-packages/{wheel/vendored/packaging → packaging}/_manylinux.py +13 -11
  453. py2docfx/venv/{basevenv/Lib/site-packages/wheel/vendored → venv1/Lib/site-packages}/packaging/_musllinux.py +5 -3
  454. py2docfx/venv/venv1/Lib/site-packages/{wheel/vendored/packaging → packaging}/_parser.py +12 -15
  455. py2docfx/venv/venv1/Lib/site-packages/{wheel/vendored/packaging → packaging}/_tokenizer.py +15 -12
  456. py2docfx/venv/venv1/Lib/site-packages/packaging/licenses/__init__.py +145 -0
  457. py2docfx/venv/venv1/Lib/site-packages/packaging/licenses/_spdx.py +759 -0
  458. py2docfx/venv/venv1/Lib/site-packages/{wheel/vendored/packaging → packaging}/markers.py +148 -39
  459. py2docfx/venv/venv1/Lib/site-packages/packaging/metadata.py +862 -0
  460. py2docfx/venv/venv1/Lib/site-packages/packaging/py.typed +0 -0
  461. py2docfx/venv/venv1/Lib/site-packages/{wheel/vendored/packaging → packaging}/requirements.py +5 -4
  462. py2docfx/venv/venv1/Lib/site-packages/{wheel/vendored/packaging → packaging}/specifiers.py +41 -33
  463. py2docfx/venv/{basevenv/Lib/site-packages/wheel/vendored → venv1/Lib/site-packages}/packaging/tags.py +135 -50
  464. py2docfx/venv/venv1/Lib/site-packages/{wheel/vendored/packaging → packaging}/utils.py +39 -48
  465. py2docfx/venv/{basevenv/Lib/site-packages/wheel/vendored → venv1/Lib/site-packages}/packaging/version.py +53 -32
  466. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/cachecontrol/py.typed +0 -0
  467. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/certifi/py.typed +0 -0
  468. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/chardet/py.typed +0 -0
  469. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/distro/py.typed +0 -0
  470. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/idna/py.typed +0 -0
  471. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/packaging/py.typed +0 -0
  472. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/platformdirs/py.typed +0 -0
  473. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/pyparsing/py.typed +0 -0
  474. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/resolvelib/py.typed +0 -0
  475. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/rich/py.typed +0 -0
  476. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/tenacity/py.typed +0 -0
  477. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/tomli/py.typed +1 -0
  478. py2docfx/venv/venv1/Lib/site-packages/pip/_vendor/truststore/py.typed +0 -0
  479. py2docfx/venv/venv1/Lib/site-packages/pip/py.typed +4 -0
  480. py2docfx/venv/venv1/Lib/site-packages/pkg_resources/__init__.py +6 -7
  481. py2docfx/venv/venv1/Lib/site-packages/pkg_resources/py.typed +0 -0
  482. py2docfx/venv/venv1/Lib/site-packages/requests/__version__.py +2 -2
  483. py2docfx/venv/venv1/Lib/site-packages/requests/compat.py +12 -0
  484. py2docfx/venv/venv1/Lib/site-packages/requests/models.py +3 -1
  485. py2docfx/venv/venv1/Lib/site-packages/requests/utils.py +6 -16
  486. py2docfx/venv/venv1/Lib/site-packages/rsa/__init__.py +2 -2
  487. py2docfx/venv/venv1/Lib/site-packages/rsa/asn1.py +52 -52
  488. py2docfx/venv/venv1/Lib/site-packages/rsa/cli.py +321 -321
  489. py2docfx/venv/venv1/Lib/site-packages/rsa/common.py +184 -184
  490. py2docfx/venv/venv1/Lib/site-packages/rsa/core.py +53 -53
  491. py2docfx/venv/venv1/Lib/site-packages/rsa/key.py +858 -858
  492. py2docfx/venv/venv1/Lib/site-packages/rsa/parallel.py +96 -96
  493. py2docfx/venv/venv1/Lib/site-packages/rsa/pem.py +134 -134
  494. py2docfx/venv/venv1/Lib/site-packages/rsa/pkcs1.py +485 -485
  495. py2docfx/venv/venv1/Lib/site-packages/rsa/pkcs1_v2.py +100 -100
  496. py2docfx/venv/venv1/Lib/site-packages/rsa/prime.py +198 -198
  497. py2docfx/venv/venv1/Lib/site-packages/rsa/py.typed +1 -0
  498. py2docfx/venv/venv1/Lib/site-packages/rsa/randnum.py +95 -95
  499. py2docfx/venv/venv1/Lib/site-packages/rsa/transform.py +72 -72
  500. py2docfx/venv/venv1/Lib/site-packages/rsa/util.py +97 -97
  501. py2docfx/venv/venv1/Lib/site-packages/setuptools/__init__.py +0 -38
  502. py2docfx/venv/venv1/Lib/site-packages/setuptools/_discovery.py +33 -0
  503. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +1 -1
  504. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/command/config.py +0 -2
  505. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_unix.py +63 -0
  506. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/compilers/C/unix.py +5 -6
  507. py2docfx/venv/venv1/Lib/site-packages/setuptools/_entry_points.py +4 -0
  508. py2docfx/venv/venv1/Lib/site-packages/setuptools/_normalization.py +0 -2
  509. py2docfx/venv/venv1/Lib/site-packages/setuptools/_path.py +12 -3
  510. py2docfx/venv/venv1/Lib/site-packages/setuptools/_reqs.py +1 -1
  511. py2docfx/venv/venv1/Lib/site-packages/setuptools/_scripts.py +361 -0
  512. py2docfx/venv/venv1/Lib/site-packages/setuptools/_shutil.py +6 -0
  513. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/importlib_metadata/py.typed +0 -0
  514. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/inflect/py.typed +0 -0
  515. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/jaraco/collections/py.typed +0 -0
  516. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/jaraco/functools/__init__.pyi +125 -0
  517. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/jaraco/functools/py.typed +0 -0
  518. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/more_itertools/__init__.pyi +2 -0
  519. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/more_itertools/more.pyi +709 -0
  520. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/more_itertools/py.typed +0 -0
  521. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/more_itertools/recipes.pyi +136 -0
  522. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/packaging/py.typed +0 -0
  523. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/platformdirs/py.typed +0 -0
  524. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/tomli/py.typed +1 -0
  525. py2docfx/venv/venv1/Lib/site-packages/setuptools/_vendor/typeguard/py.typed +0 -0
  526. py2docfx/venv/venv1/Lib/site-packages/setuptools/build_meta.py +25 -37
  527. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/bdist_egg.py +9 -11
  528. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/bdist_wheel.py +1 -1
  529. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/build_ext.py +29 -28
  530. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/develop.py +39 -179
  531. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/easy_install.py +17 -2352
  532. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/editable_wheel.py +14 -31
  533. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/egg_info.py +0 -2
  534. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/install.py +3 -55
  535. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/install_scripts.py +5 -11
  536. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/sdist.py +1 -1
  537. py2docfx/venv/venv1/Lib/site-packages/setuptools/compat/py310.py +11 -0
  538. py2docfx/venv/venv1/Lib/site-packages/setuptools/dist.py +10 -12
  539. py2docfx/venv/venv1/Lib/site-packages/setuptools/installer.py +34 -29
  540. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/contexts.py +0 -14
  541. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/fixtures.py +235 -0
  542. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/integration/test_pbr.py +20 -0
  543. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_build_meta.py +0 -24
  544. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_develop.py +1 -64
  545. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_dist.py +2 -2
  546. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_dist_info.py +0 -63
  547. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_editable_install.py +15 -41
  548. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_egg_info.py +3 -2
  549. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_scripts.py +12 -0
  550. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_wheel.py +12 -36
  551. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_windows_wrappers.py +3 -4
  552. py2docfx/venv/venv1/Lib/site-packages/setuptools/wheel.py +49 -24
  553. py2docfx/venv/venv1/Lib/site-packages/typing_extensions.py +380 -708
  554. py2docfx/venv/venv1/Lib/site-packages/urllib3/_version.py +9 -4
  555. py2docfx/venv/venv1/Lib/site-packages/urllib3/connection.py +87 -38
  556. py2docfx/venv/venv1/Lib/site-packages/urllib3/contrib/emscripten/fetch.py +20 -0
  557. py2docfx/venv/venv1/Lib/site-packages/urllib3/contrib/emscripten/response.py +8 -16
  558. py2docfx/venv/venv1/Lib/site-packages/urllib3/contrib/pyopenssl.py +10 -0
  559. py2docfx/venv/venv1/Lib/site-packages/urllib3/exceptions.py +12 -4
  560. py2docfx/venv/venv1/Lib/site-packages/urllib3/http2/connection.py +1 -1
  561. py2docfx/venv/venv1/Lib/site-packages/urllib3/poolmanager.py +17 -1
  562. py2docfx/venv/venv1/Lib/site-packages/urllib3/py.typed +2 -0
  563. py2docfx/venv/venv1/Lib/site-packages/urllib3/response.py +53 -24
  564. py2docfx/venv/venv1/Lib/site-packages/urllib3/util/request.py +12 -4
  565. py2docfx/venv/venv1/Lib/site-packages/urllib3/util/ssl_.py +22 -2
  566. py2docfx/venv/venv1/Lib/site-packages/urllib3/util/ssl_match_hostname.py +1 -1
  567. py2docfx/venv/venv1/Lib/site-packages/wheel/__init__.py +1 -1
  568. py2docfx/venv/venv1/Lib/site-packages/wheel/__main__.py +7 -5
  569. py2docfx/venv/{basevenv/Lib/site-packages/wheel/cli → venv1/Lib/site-packages/wheel/_commands}/__init__.py +3 -5
  570. py2docfx/venv/{basevenv/Lib/site-packages/wheel/cli → venv1/Lib/site-packages/wheel/_commands}/convert.py +14 -9
  571. py2docfx/venv/{basevenv/Lib/site-packages/wheel/cli → venv1/Lib/site-packages/wheel/_commands}/pack.py +1 -2
  572. py2docfx/venv/venv1/Lib/site-packages/wheel/{cli → _commands}/tags.py +4 -3
  573. py2docfx/venv/venv1/Lib/site-packages/wheel/_metadata.py +184 -0
  574. py2docfx/venv/venv1/Lib/site-packages/wheel/bdist_wheel.py +12 -23
  575. py2docfx/venv/venv1/Lib/site-packages/wheel/macosx_libfile.py +4 -0
  576. py2docfx/venv/venv1/Lib/site-packages/wheel/metadata.py +17 -183
  577. py2docfx/venv/venv1/Lib/site-packages/wheel/wheelfile.py +30 -16
  578. {py2docfx-0.1.16rc2051518.dist-info → py2docfx-0.1.17.dist-info}/METADATA +2 -3
  579. {py2docfx-0.1.16rc2051518.dist-info → py2docfx-0.1.17.dist-info}/RECORD +588 -427
  580. {py2docfx-0.1.16rc2051518.dist-info → py2docfx-0.1.17.dist-info}/WHEEL +1 -1
  581. py2docfx/venv/basevenv/Lib/site-packages/setuptools/package_index.py +0 -1137
  582. py2docfx/venv/basevenv/Lib/site-packages/setuptools/sandbox.py +0 -536
  583. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/server.py +0 -86
  584. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_easy_install.py +0 -1476
  585. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_packageindex.py +0 -267
  586. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_sandbox.py +0 -134
  587. py2docfx/venv/basevenv/Lib/site-packages/wheel/_bdist_wheel.py +0 -613
  588. py2docfx/venv/basevenv/Lib/site-packages/wheel/_setuptools_logging.py +0 -26
  589. py2docfx/venv/basevenv/Lib/site-packages/wheel/util.py +0 -17
  590. py2docfx/venv/basevenv/Lib/site-packages/wheel/vendored/packaging/_manylinux.py +0 -260
  591. py2docfx/venv/basevenv/Lib/site-packages/wheel/vendored/packaging/_parser.py +0 -356
  592. py2docfx/venv/basevenv/Lib/site-packages/wheel/vendored/packaging/_tokenizer.py +0 -192
  593. py2docfx/venv/basevenv/Lib/site-packages/wheel/vendored/packaging/markers.py +0 -253
  594. py2docfx/venv/basevenv/Lib/site-packages/wheel/vendored/packaging/requirements.py +0 -90
  595. py2docfx/venv/basevenv/Lib/site-packages/wheel/vendored/packaging/specifiers.py +0 -1011
  596. py2docfx/venv/basevenv/Lib/site-packages/wheel/vendored/packaging/utils.py +0 -172
  597. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/application.py +0 -119
  598. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/application.py +0 -121
  599. py2docfx/venv/venv1/Lib/site-packages/setuptools/package_index.py +0 -1137
  600. py2docfx/venv/venv1/Lib/site-packages/setuptools/sandbox.py +0 -536
  601. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/server.py +0 -86
  602. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_easy_install.py +0 -1476
  603. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_packageindex.py +0 -267
  604. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_sandbox.py +0 -134
  605. py2docfx/venv/venv1/Lib/site-packages/wheel/_bdist_wheel.py +0 -613
  606. py2docfx/venv/venv1/Lib/site-packages/wheel/_setuptools_logging.py +0 -26
  607. py2docfx/venv/venv1/Lib/site-packages/wheel/util.py +0 -17
  608. py2docfx/venv/venv1/Lib/site-packages/wheel/vendored/packaging/_elffile.py +0 -108
  609. py2docfx/venv/venv1/Lib/site-packages/wheel/vendored/packaging/_musllinux.py +0 -83
  610. py2docfx/venv/venv1/Lib/site-packages/wheel/vendored/packaging/_structures.py +0 -61
  611. py2docfx/venv/venv1/Lib/site-packages/wheel/vendored/packaging/tags.py +0 -571
  612. py2docfx/venv/venv1/Lib/site-packages/wheel/vendored/packaging/version.py +0 -561
  613. /py2docfx/venv/basevenv/Lib/site-packages/{wheel/vendored/__init__.py → certifi/py.typed} +0 -0
  614. /py2docfx/venv/basevenv/Lib/site-packages/{wheel/vendored/packaging/__init__.py → charset_normalizer/py.typed} +0 -0
  615. /py2docfx/venv/{venv1/Lib/site-packages/wheel/vendored/__init__.py → basevenv/Lib/site-packages/idna/py.typed} +0 -0
  616. /py2docfx/venv/{venv1/Lib/site-packages/wheel/vendored/packaging/__init__.py → basevenv/Lib/site-packages/jinja2/py.typed} +0 -0
  617. /py2docfx/venv/basevenv/Lib/site-packages/wheel/{cli → _commands}/unpack.py +0 -0
  618. /py2docfx/venv/{basevenv/Lib/site-packages/wheel/vendored → venv1/Lib/site-packages}/packaging/_structures.py +0 -0
  619. /py2docfx/venv/venv1/Lib/site-packages/wheel/{cli → _commands}/unpack.py +0 -0
  620. {py2docfx-0.1.16rc2051518.dist-info → py2docfx-0.1.17.dist-info}/top_level.txt +0 -0
@@ -1,858 +1,858 @@
1
- # Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """RSA key generation code.
16
-
17
- Create new keys with the newkeys() function. It will give you a PublicKey and a
18
- PrivateKey object.
19
-
20
- Loading and saving keys requires the pyasn1 module. This module is imported as
21
- late as possible, such that other functionality will remain working in absence
22
- of pyasn1.
23
-
24
- .. note::
25
-
26
- Storing public and private keys via the `pickle` module is possible.
27
- However, it is insecure to load a key from an untrusted source.
28
- The pickle module is not secure against erroneous or maliciously
29
- constructed data. Never unpickle data received from an untrusted
30
- or unauthenticated source.
31
-
32
- """
33
-
34
- import threading
35
- import typing
36
- import warnings
37
-
38
- import rsa.prime
39
- import rsa.pem
40
- import rsa.common
41
- import rsa.randnum
42
- import rsa.core
43
-
44
-
45
- DEFAULT_EXPONENT = 65537
46
-
47
-
48
- T = typing.TypeVar("T", bound="AbstractKey")
49
-
50
-
51
- class AbstractKey:
52
- """Abstract superclass for private and public keys."""
53
-
54
- __slots__ = ("n", "e", "blindfac", "blindfac_inverse", "mutex")
55
-
56
- def __init__(self, n: int, e: int) -> None:
57
- self.n = n
58
- self.e = e
59
-
60
- # These will be computed properly on the first call to blind().
61
- self.blindfac = self.blindfac_inverse = -1
62
-
63
- # Used to protect updates to the blinding factor in multi-threaded
64
- # environments.
65
- self.mutex = threading.Lock()
66
-
67
- @classmethod
68
- def _load_pkcs1_pem(cls: typing.Type[T], keyfile: bytes) -> T:
69
- """Loads a key in PKCS#1 PEM format, implement in a subclass.
70
-
71
- :param keyfile: contents of a PEM-encoded file that contains
72
- the public key.
73
- :type keyfile: bytes
74
-
75
- :return: the loaded key
76
- :rtype: AbstractKey
77
- """
78
-
79
- @classmethod
80
- def _load_pkcs1_der(cls: typing.Type[T], keyfile: bytes) -> T:
81
- """Loads a key in PKCS#1 PEM format, implement in a subclass.
82
-
83
- :param keyfile: contents of a DER-encoded file that contains
84
- the public key.
85
- :type keyfile: bytes
86
-
87
- :return: the loaded key
88
- :rtype: AbstractKey
89
- """
90
-
91
- def _save_pkcs1_pem(self) -> bytes:
92
- """Saves the key in PKCS#1 PEM format, implement in a subclass.
93
-
94
- :returns: the PEM-encoded key.
95
- :rtype: bytes
96
- """
97
-
98
- def _save_pkcs1_der(self) -> bytes:
99
- """Saves the key in PKCS#1 DER format, implement in a subclass.
100
-
101
- :returns: the DER-encoded key.
102
- :rtype: bytes
103
- """
104
-
105
- @classmethod
106
- def load_pkcs1(cls: typing.Type[T], keyfile: bytes, format: str = "PEM") -> T:
107
- """Loads a key in PKCS#1 DER or PEM format.
108
-
109
- :param keyfile: contents of a DER- or PEM-encoded file that contains
110
- the key.
111
- :type keyfile: bytes
112
- :param format: the format of the file to load; 'PEM' or 'DER'
113
- :type format: str
114
-
115
- :return: the loaded key
116
- :rtype: AbstractKey
117
- """
118
-
119
- methods = {
120
- "PEM": cls._load_pkcs1_pem,
121
- "DER": cls._load_pkcs1_der,
122
- }
123
-
124
- method = cls._assert_format_exists(format, methods)
125
- return method(keyfile)
126
-
127
- @staticmethod
128
- def _assert_format_exists(
129
- file_format: str, methods: typing.Mapping[str, typing.Callable]
130
- ) -> typing.Callable:
131
- """Checks whether the given file format exists in 'methods'."""
132
-
133
- try:
134
- return methods[file_format]
135
- except KeyError as ex:
136
- formats = ", ".join(sorted(methods.keys()))
137
- raise ValueError(
138
- "Unsupported format: %r, try one of %s" % (file_format, formats)
139
- ) from ex
140
-
141
- def save_pkcs1(self, format: str = "PEM") -> bytes:
142
- """Saves the key in PKCS#1 DER or PEM format.
143
-
144
- :param format: the format to save; 'PEM' or 'DER'
145
- :type format: str
146
- :returns: the DER- or PEM-encoded key.
147
- :rtype: bytes
148
- """
149
-
150
- methods = {
151
- "PEM": self._save_pkcs1_pem,
152
- "DER": self._save_pkcs1_der,
153
- }
154
-
155
- method = self._assert_format_exists(format, methods)
156
- return method()
157
-
158
- def blind(self, message: int) -> typing.Tuple[int, int]:
159
- """Performs blinding on the message.
160
-
161
- :param message: the message, as integer, to blind.
162
- :param r: the random number to blind with.
163
- :return: tuple (the blinded message, the inverse of the used blinding factor)
164
-
165
- The blinding is such that message = unblind(decrypt(blind(encrypt(message))).
166
-
167
- See https://en.wikipedia.org/wiki/Blinding_%28cryptography%29
168
- """
169
- blindfac, blindfac_inverse = self._update_blinding_factor()
170
- blinded = (message * pow(blindfac, self.e, self.n)) % self.n
171
- return blinded, blindfac_inverse
172
-
173
- def unblind(self, blinded: int, blindfac_inverse: int) -> int:
174
- """Performs blinding on the message using random number 'blindfac_inverse'.
175
-
176
- :param blinded: the blinded message, as integer, to unblind.
177
- :param blindfac: the factor to unblind with.
178
- :return: the original message.
179
-
180
- The blinding is such that message = unblind(decrypt(blind(encrypt(message))).
181
-
182
- See https://en.wikipedia.org/wiki/Blinding_%28cryptography%29
183
- """
184
- return (blindfac_inverse * blinded) % self.n
185
-
186
- def _initial_blinding_factor(self) -> int:
187
- for _ in range(1000):
188
- blind_r = rsa.randnum.randint(self.n - 1)
189
- if rsa.prime.are_relatively_prime(self.n, blind_r):
190
- return blind_r
191
- raise RuntimeError("unable to find blinding factor")
192
-
193
- def _update_blinding_factor(self) -> typing.Tuple[int, int]:
194
- """Update blinding factors.
195
-
196
- Computing a blinding factor is expensive, so instead this function
197
- does this once, then updates the blinding factor as per section 9
198
- of 'A Timing Attack against RSA with the Chinese Remainder Theorem'
199
- by Werner Schindler.
200
- See https://tls.mbed.org/public/WSchindler-RSA_Timing_Attack.pdf
201
-
202
- :return: the new blinding factor and its inverse.
203
- """
204
-
205
- with self.mutex:
206
- if self.blindfac < 0:
207
- # Compute initial blinding factor, which is rather slow to do.
208
- self.blindfac = self._initial_blinding_factor()
209
- self.blindfac_inverse = rsa.common.inverse(self.blindfac, self.n)
210
- else:
211
- # Reuse previous blinding factor.
212
- self.blindfac = pow(self.blindfac, 2, self.n)
213
- self.blindfac_inverse = pow(self.blindfac_inverse, 2, self.n)
214
-
215
- return self.blindfac, self.blindfac_inverse
216
-
217
-
218
- class PublicKey(AbstractKey):
219
- """Represents a public RSA key.
220
-
221
- This key is also known as the 'encryption key'. It contains the 'n' and 'e'
222
- values.
223
-
224
- Supports attributes as well as dictionary-like access. Attribute access is
225
- faster, though.
226
-
227
- >>> PublicKey(5, 3)
228
- PublicKey(5, 3)
229
-
230
- >>> key = PublicKey(5, 3)
231
- >>> key.n
232
- 5
233
- >>> key['n']
234
- 5
235
- >>> key.e
236
- 3
237
- >>> key['e']
238
- 3
239
-
240
- """
241
-
242
- __slots__ = ()
243
-
244
- def __getitem__(self, key: str) -> int:
245
- return getattr(self, key)
246
-
247
- def __repr__(self) -> str:
248
- return "PublicKey(%i, %i)" % (self.n, self.e)
249
-
250
- def __getstate__(self) -> typing.Tuple[int, int]:
251
- """Returns the key as tuple for pickling."""
252
- return self.n, self.e
253
-
254
- def __setstate__(self, state: typing.Tuple[int, int]) -> None:
255
- """Sets the key from tuple."""
256
- self.n, self.e = state
257
- AbstractKey.__init__(self, self.n, self.e)
258
-
259
- def __eq__(self, other: typing.Any) -> bool:
260
- if other is None:
261
- return False
262
-
263
- if not isinstance(other, PublicKey):
264
- return False
265
-
266
- return self.n == other.n and self.e == other.e
267
-
268
- def __ne__(self, other: typing.Any) -> bool:
269
- return not (self == other)
270
-
271
- def __hash__(self) -> int:
272
- return hash((self.n, self.e))
273
-
274
- @classmethod
275
- def _load_pkcs1_der(cls, keyfile: bytes) -> "PublicKey":
276
- """Loads a key in PKCS#1 DER format.
277
-
278
- :param keyfile: contents of a DER-encoded file that contains the public
279
- key.
280
- :return: a PublicKey object
281
-
282
- First let's construct a DER encoded key:
283
-
284
- >>> import base64
285
- >>> b64der = 'MAwCBQCNGmYtAgMBAAE='
286
- >>> der = base64.standard_b64decode(b64der)
287
-
288
- This loads the file:
289
-
290
- >>> PublicKey._load_pkcs1_der(der)
291
- PublicKey(2367317549, 65537)
292
-
293
- """
294
-
295
- from pyasn1.codec.der import decoder
296
- from rsa.asn1 import AsnPubKey
297
-
298
- (priv, _) = decoder.decode(keyfile, asn1Spec=AsnPubKey())
299
- return cls(n=int(priv["modulus"]), e=int(priv["publicExponent"]))
300
-
301
- def _save_pkcs1_der(self) -> bytes:
302
- """Saves the public key in PKCS#1 DER format.
303
-
304
- :returns: the DER-encoded public key.
305
- :rtype: bytes
306
- """
307
-
308
- from pyasn1.codec.der import encoder
309
- from rsa.asn1 import AsnPubKey
310
-
311
- # Create the ASN object
312
- asn_key = AsnPubKey()
313
- asn_key.setComponentByName("modulus", self.n)
314
- asn_key.setComponentByName("publicExponent", self.e)
315
-
316
- return encoder.encode(asn_key)
317
-
318
- @classmethod
319
- def _load_pkcs1_pem(cls, keyfile: bytes) -> "PublicKey":
320
- """Loads a PKCS#1 PEM-encoded public key file.
321
-
322
- The contents of the file before the "-----BEGIN RSA PUBLIC KEY-----" and
323
- after the "-----END RSA PUBLIC KEY-----" lines is ignored.
324
-
325
- :param keyfile: contents of a PEM-encoded file that contains the public
326
- key.
327
- :return: a PublicKey object
328
- """
329
-
330
- der = rsa.pem.load_pem(keyfile, "RSA PUBLIC KEY")
331
- return cls._load_pkcs1_der(der)
332
-
333
- def _save_pkcs1_pem(self) -> bytes:
334
- """Saves a PKCS#1 PEM-encoded public key file.
335
-
336
- :return: contents of a PEM-encoded file that contains the public key.
337
- :rtype: bytes
338
- """
339
-
340
- der = self._save_pkcs1_der()
341
- return rsa.pem.save_pem(der, "RSA PUBLIC KEY")
342
-
343
- @classmethod
344
- def load_pkcs1_openssl_pem(cls, keyfile: bytes) -> "PublicKey":
345
- """Loads a PKCS#1.5 PEM-encoded public key file from OpenSSL.
346
-
347
- These files can be recognised in that they start with BEGIN PUBLIC KEY
348
- rather than BEGIN RSA PUBLIC KEY.
349
-
350
- The contents of the file before the "-----BEGIN PUBLIC KEY-----" and
351
- after the "-----END PUBLIC KEY-----" lines is ignored.
352
-
353
- :param keyfile: contents of a PEM-encoded file that contains the public
354
- key, from OpenSSL.
355
- :type keyfile: bytes
356
- :return: a PublicKey object
357
- """
358
-
359
- der = rsa.pem.load_pem(keyfile, "PUBLIC KEY")
360
- return cls.load_pkcs1_openssl_der(der)
361
-
362
- @classmethod
363
- def load_pkcs1_openssl_der(cls, keyfile: bytes) -> "PublicKey":
364
- """Loads a PKCS#1 DER-encoded public key file from OpenSSL.
365
-
366
- :param keyfile: contents of a DER-encoded file that contains the public
367
- key, from OpenSSL.
368
- :return: a PublicKey object
369
- """
370
-
371
- from rsa.asn1 import OpenSSLPubKey
372
- from pyasn1.codec.der import decoder
373
- from pyasn1.type import univ
374
-
375
- (keyinfo, _) = decoder.decode(keyfile, asn1Spec=OpenSSLPubKey())
376
-
377
- if keyinfo["header"]["oid"] != univ.ObjectIdentifier("1.2.840.113549.1.1.1"):
378
- raise TypeError("This is not a DER-encoded OpenSSL-compatible public key")
379
-
380
- return cls._load_pkcs1_der(keyinfo["key"][1:])
381
-
382
-
383
- class PrivateKey(AbstractKey):
384
- """Represents a private RSA key.
385
-
386
- This key is also known as the 'decryption key'. It contains the 'n', 'e',
387
- 'd', 'p', 'q' and other values.
388
-
389
- Supports attributes as well as dictionary-like access. Attribute access is
390
- faster, though.
391
-
392
- >>> PrivateKey(3247, 65537, 833, 191, 17)
393
- PrivateKey(3247, 65537, 833, 191, 17)
394
-
395
- exp1, exp2 and coef will be calculated:
396
-
397
- >>> pk = PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
398
- >>> pk.exp1
399
- 55063
400
- >>> pk.exp2
401
- 10095
402
- >>> pk.coef
403
- 50797
404
-
405
- """
406
-
407
- __slots__ = ("d", "p", "q", "exp1", "exp2", "coef")
408
-
409
- def __init__(self, n: int, e: int, d: int, p: int, q: int) -> None:
410
- AbstractKey.__init__(self, n, e)
411
- self.d = d
412
- self.p = p
413
- self.q = q
414
-
415
- # Calculate exponents and coefficient.
416
- self.exp1 = int(d % (p - 1))
417
- self.exp2 = int(d % (q - 1))
418
- self.coef = rsa.common.inverse(q, p)
419
-
420
- def __getitem__(self, key: str) -> int:
421
- return getattr(self, key)
422
-
423
- def __repr__(self) -> str:
424
- return "PrivateKey(%i, %i, %i, %i, %i)" % (
425
- self.n,
426
- self.e,
427
- self.d,
428
- self.p,
429
- self.q,
430
- )
431
-
432
- def __getstate__(self) -> typing.Tuple[int, int, int, int, int, int, int, int]:
433
- """Returns the key as tuple for pickling."""
434
- return self.n, self.e, self.d, self.p, self.q, self.exp1, self.exp2, self.coef
435
-
436
- def __setstate__(self, state: typing.Tuple[int, int, int, int, int, int, int, int]) -> None:
437
- """Sets the key from tuple."""
438
- self.n, self.e, self.d, self.p, self.q, self.exp1, self.exp2, self.coef = state
439
- AbstractKey.__init__(self, self.n, self.e)
440
-
441
- def __eq__(self, other: typing.Any) -> bool:
442
- if other is None:
443
- return False
444
-
445
- if not isinstance(other, PrivateKey):
446
- return False
447
-
448
- return (
449
- self.n == other.n
450
- and self.e == other.e
451
- and self.d == other.d
452
- and self.p == other.p
453
- and self.q == other.q
454
- and self.exp1 == other.exp1
455
- and self.exp2 == other.exp2
456
- and self.coef == other.coef
457
- )
458
-
459
- def __ne__(self, other: typing.Any) -> bool:
460
- return not (self == other)
461
-
462
- def __hash__(self) -> int:
463
- return hash((self.n, self.e, self.d, self.p, self.q, self.exp1, self.exp2, self.coef))
464
-
465
- def blinded_decrypt(self, encrypted: int) -> int:
466
- """Decrypts the message using blinding to prevent side-channel attacks.
467
-
468
- :param encrypted: the encrypted message
469
- :type encrypted: int
470
-
471
- :returns: the decrypted message
472
- :rtype: int
473
- """
474
-
475
- # Blinding and un-blinding should be using the same factor
476
- blinded, blindfac_inverse = self.blind(encrypted)
477
-
478
- # Instead of using the core functionality, use the Chinese Remainder
479
- # Theorem and be 2-4x faster. This the same as:
480
- #
481
- # decrypted = rsa.core.decrypt_int(blinded, self.d, self.n)
482
- s1 = pow(blinded, self.exp1, self.p)
483
- s2 = pow(blinded, self.exp2, self.q)
484
- h = ((s1 - s2) * self.coef) % self.p
485
- decrypted = s2 + self.q * h
486
-
487
- return self.unblind(decrypted, blindfac_inverse)
488
-
489
- def blinded_encrypt(self, message: int) -> int:
490
- """Encrypts the message using blinding to prevent side-channel attacks.
491
-
492
- :param message: the message to encrypt
493
- :type message: int
494
-
495
- :returns: the encrypted message
496
- :rtype: int
497
- """
498
-
499
- blinded, blindfac_inverse = self.blind(message)
500
- encrypted = rsa.core.encrypt_int(blinded, self.d, self.n)
501
- return self.unblind(encrypted, blindfac_inverse)
502
-
503
- @classmethod
504
- def _load_pkcs1_der(cls, keyfile: bytes) -> "PrivateKey":
505
- """Loads a key in PKCS#1 DER format.
506
-
507
- :param keyfile: contents of a DER-encoded file that contains the private
508
- key.
509
- :type keyfile: bytes
510
- :return: a PrivateKey object
511
-
512
- First let's construct a DER encoded key:
513
-
514
- >>> import base64
515
- >>> b64der = 'MC4CAQACBQDeKYlRAgMBAAECBQDHn4npAgMA/icCAwDfxwIDANcXAgInbwIDAMZt'
516
- >>> der = base64.standard_b64decode(b64der)
517
-
518
- This loads the file:
519
-
520
- >>> PrivateKey._load_pkcs1_der(der)
521
- PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
522
-
523
- """
524
-
525
- from pyasn1.codec.der import decoder
526
-
527
- (priv, _) = decoder.decode(keyfile)
528
-
529
- # ASN.1 contents of DER encoded private key:
530
- #
531
- # RSAPrivateKey ::= SEQUENCE {
532
- # version Version,
533
- # modulus INTEGER, -- n
534
- # publicExponent INTEGER, -- e
535
- # privateExponent INTEGER, -- d
536
- # prime1 INTEGER, -- p
537
- # prime2 INTEGER, -- q
538
- # exponent1 INTEGER, -- d mod (p-1)
539
- # exponent2 INTEGER, -- d mod (q-1)
540
- # coefficient INTEGER, -- (inverse of q) mod p
541
- # otherPrimeInfos OtherPrimeInfos OPTIONAL
542
- # }
543
-
544
- if priv[0] != 0:
545
- raise ValueError("Unable to read this file, version %s != 0" % priv[0])
546
-
547
- as_ints = map(int, priv[1:6])
548
- key = cls(*as_ints)
549
-
550
- exp1, exp2, coef = map(int, priv[6:9])
551
-
552
- if (key.exp1, key.exp2, key.coef) != (exp1, exp2, coef):
553
- warnings.warn(
554
- "You have provided a malformed keyfile. Either the exponents "
555
- "or the coefficient are incorrect. Using the correct values "
556
- "instead.",
557
- UserWarning,
558
- )
559
-
560
- return key
561
-
562
- def _save_pkcs1_der(self) -> bytes:
563
- """Saves the private key in PKCS#1 DER format.
564
-
565
- :returns: the DER-encoded private key.
566
- :rtype: bytes
567
- """
568
-
569
- from pyasn1.type import univ, namedtype
570
- from pyasn1.codec.der import encoder
571
-
572
- class AsnPrivKey(univ.Sequence):
573
- componentType = namedtype.NamedTypes(
574
- namedtype.NamedType("version", univ.Integer()),
575
- namedtype.NamedType("modulus", univ.Integer()),
576
- namedtype.NamedType("publicExponent", univ.Integer()),
577
- namedtype.NamedType("privateExponent", univ.Integer()),
578
- namedtype.NamedType("prime1", univ.Integer()),
579
- namedtype.NamedType("prime2", univ.Integer()),
580
- namedtype.NamedType("exponent1", univ.Integer()),
581
- namedtype.NamedType("exponent2", univ.Integer()),
582
- namedtype.NamedType("coefficient", univ.Integer()),
583
- )
584
-
585
- # Create the ASN object
586
- asn_key = AsnPrivKey()
587
- asn_key.setComponentByName("version", 0)
588
- asn_key.setComponentByName("modulus", self.n)
589
- asn_key.setComponentByName("publicExponent", self.e)
590
- asn_key.setComponentByName("privateExponent", self.d)
591
- asn_key.setComponentByName("prime1", self.p)
592
- asn_key.setComponentByName("prime2", self.q)
593
- asn_key.setComponentByName("exponent1", self.exp1)
594
- asn_key.setComponentByName("exponent2", self.exp2)
595
- asn_key.setComponentByName("coefficient", self.coef)
596
-
597
- return encoder.encode(asn_key)
598
-
599
- @classmethod
600
- def _load_pkcs1_pem(cls, keyfile: bytes) -> "PrivateKey":
601
- """Loads a PKCS#1 PEM-encoded private key file.
602
-
603
- The contents of the file before the "-----BEGIN RSA PRIVATE KEY-----" and
604
- after the "-----END RSA PRIVATE KEY-----" lines is ignored.
605
-
606
- :param keyfile: contents of a PEM-encoded file that contains the private
607
- key.
608
- :type keyfile: bytes
609
- :return: a PrivateKey object
610
- """
611
-
612
- der = rsa.pem.load_pem(keyfile, b"RSA PRIVATE KEY")
613
- return cls._load_pkcs1_der(der)
614
-
615
- def _save_pkcs1_pem(self) -> bytes:
616
- """Saves a PKCS#1 PEM-encoded private key file.
617
-
618
- :return: contents of a PEM-encoded file that contains the private key.
619
- :rtype: bytes
620
- """
621
-
622
- der = self._save_pkcs1_der()
623
- return rsa.pem.save_pem(der, b"RSA PRIVATE KEY")
624
-
625
-
626
- def find_p_q(
627
- nbits: int,
628
- getprime_func: typing.Callable[[int], int] = rsa.prime.getprime,
629
- accurate: bool = True,
630
- ) -> typing.Tuple[int, int]:
631
- """Returns a tuple of two different primes of nbits bits each.
632
-
633
- The resulting p * q has exactly 2 * nbits bits, and the returned p and q
634
- will not be equal.
635
-
636
- :param nbits: the number of bits in each of p and q.
637
- :param getprime_func: the getprime function, defaults to
638
- :py:func:`rsa.prime.getprime`.
639
-
640
- *Introduced in Python-RSA 3.1*
641
-
642
- :param accurate: whether to enable accurate mode or not.
643
- :returns: (p, q), where p > q
644
-
645
- >>> (p, q) = find_p_q(128)
646
- >>> from rsa import common
647
- >>> common.bit_size(p * q)
648
- 256
649
-
650
- When not in accurate mode, the number of bits can be slightly less
651
-
652
- >>> (p, q) = find_p_q(128, accurate=False)
653
- >>> from rsa import common
654
- >>> common.bit_size(p * q) <= 256
655
- True
656
- >>> common.bit_size(p * q) > 240
657
- True
658
-
659
- """
660
-
661
- total_bits = nbits * 2
662
-
663
- # Make sure that p and q aren't too close or the factoring programs can
664
- # factor n.
665
- shift = nbits // 16
666
- pbits = nbits + shift
667
- qbits = nbits - shift
668
-
669
- # Choose the two initial primes
670
- p = getprime_func(pbits)
671
- q = getprime_func(qbits)
672
-
673
- def is_acceptable(p: int, q: int) -> bool:
674
- """Returns True iff p and q are acceptable:
675
-
676
- - p and q differ
677
- - (p * q) has the right nr of bits (when accurate=True)
678
- """
679
-
680
- if p == q:
681
- return False
682
-
683
- if not accurate:
684
- return True
685
-
686
- # Make sure we have just the right amount of bits
687
- found_size = rsa.common.bit_size(p * q)
688
- return total_bits == found_size
689
-
690
- # Keep choosing other primes until they match our requirements.
691
- change_p = False
692
- while not is_acceptable(p, q):
693
- # Change p on one iteration and q on the other
694
- if change_p:
695
- p = getprime_func(pbits)
696
- else:
697
- q = getprime_func(qbits)
698
-
699
- change_p = not change_p
700
-
701
- # We want p > q as described on
702
- # http://www.di-mgt.com.au/rsa_alg.html#crt
703
- return max(p, q), min(p, q)
704
-
705
-
706
- def calculate_keys_custom_exponent(p: int, q: int, exponent: int) -> typing.Tuple[int, int]:
707
- """Calculates an encryption and a decryption key given p, q and an exponent,
708
- and returns them as a tuple (e, d)
709
-
710
- :param p: the first large prime
711
- :param q: the second large prime
712
- :param exponent: the exponent for the key; only change this if you know
713
- what you're doing, as the exponent influences how difficult your
714
- private key can be cracked. A very common choice for e is 65537.
715
- :type exponent: int
716
-
717
- """
718
-
719
- phi_n = (p - 1) * (q - 1)
720
-
721
- try:
722
- d = rsa.common.inverse(exponent, phi_n)
723
- except rsa.common.NotRelativePrimeError as ex:
724
- raise rsa.common.NotRelativePrimeError(
725
- exponent,
726
- phi_n,
727
- ex.d,
728
- msg="e (%d) and phi_n (%d) are not relatively prime (divider=%i)"
729
- % (exponent, phi_n, ex.d),
730
- ) from ex
731
-
732
- if (exponent * d) % phi_n != 1:
733
- raise ValueError(
734
- "e (%d) and d (%d) are not mult. inv. modulo " "phi_n (%d)" % (exponent, d, phi_n)
735
- )
736
-
737
- return exponent, d
738
-
739
-
740
- def calculate_keys(p: int, q: int) -> typing.Tuple[int, int]:
741
- """Calculates an encryption and a decryption key given p and q, and
742
- returns them as a tuple (e, d)
743
-
744
- :param p: the first large prime
745
- :param q: the second large prime
746
-
747
- :return: tuple (e, d) with the encryption and decryption exponents.
748
- """
749
-
750
- return calculate_keys_custom_exponent(p, q, DEFAULT_EXPONENT)
751
-
752
-
753
- def gen_keys(
754
- nbits: int,
755
- getprime_func: typing.Callable[[int], int],
756
- accurate: bool = True,
757
- exponent: int = DEFAULT_EXPONENT,
758
- ) -> typing.Tuple[int, int, int, int]:
759
- """Generate RSA keys of nbits bits. Returns (p, q, e, d).
760
-
761
- Note: this can take a long time, depending on the key size.
762
-
763
- :param nbits: the total number of bits in ``p`` and ``q``. Both ``p`` and
764
- ``q`` will use ``nbits/2`` bits.
765
- :param getprime_func: either :py:func:`rsa.prime.getprime` or a function
766
- with similar signature.
767
- :param exponent: the exponent for the key; only change this if you know
768
- what you're doing, as the exponent influences how difficult your
769
- private key can be cracked. A very common choice for e is 65537.
770
- :type exponent: int
771
- """
772
-
773
- # Regenerate p and q values, until calculate_keys doesn't raise a
774
- # ValueError.
775
- while True:
776
- (p, q) = find_p_q(nbits // 2, getprime_func, accurate)
777
- try:
778
- (e, d) = calculate_keys_custom_exponent(p, q, exponent=exponent)
779
- break
780
- except ValueError:
781
- pass
782
-
783
- return p, q, e, d
784
-
785
-
786
- def newkeys(
787
- nbits: int,
788
- accurate: bool = True,
789
- poolsize: int = 1,
790
- exponent: int = DEFAULT_EXPONENT,
791
- ) -> typing.Tuple[PublicKey, PrivateKey]:
792
- """Generates public and private keys, and returns them as (pub, priv).
793
-
794
- The public key is also known as the 'encryption key', and is a
795
- :py:class:`rsa.PublicKey` object. The private key is also known as the
796
- 'decryption key' and is a :py:class:`rsa.PrivateKey` object.
797
-
798
- :param nbits: the number of bits required to store ``n = p*q``.
799
- :param accurate: when True, ``n`` will have exactly the number of bits you
800
- asked for. However, this makes key generation much slower. When False,
801
- `n`` may have slightly less bits.
802
- :param poolsize: the number of processes to use to generate the prime
803
- numbers. If set to a number > 1, a parallel algorithm will be used.
804
- This requires Python 2.6 or newer.
805
- :param exponent: the exponent for the key; only change this if you know
806
- what you're doing, as the exponent influences how difficult your
807
- private key can be cracked. A very common choice for e is 65537.
808
- :type exponent: int
809
-
810
- :returns: a tuple (:py:class:`rsa.PublicKey`, :py:class:`rsa.PrivateKey`)
811
-
812
- The ``poolsize`` parameter was added in *Python-RSA 3.1* and requires
813
- Python 2.6 or newer.
814
-
815
- """
816
-
817
- if nbits < 16:
818
- raise ValueError("Key too small")
819
-
820
- if poolsize < 1:
821
- raise ValueError("Pool size (%i) should be >= 1" % poolsize)
822
-
823
- # Determine which getprime function to use
824
- if poolsize > 1:
825
- from rsa import parallel
826
-
827
- def getprime_func(nbits: int) -> int:
828
- return parallel.getprime(nbits, poolsize=poolsize)
829
-
830
- else:
831
- getprime_func = rsa.prime.getprime
832
-
833
- # Generate the key components
834
- (p, q, e, d) = gen_keys(nbits, getprime_func, accurate=accurate, exponent=exponent)
835
-
836
- # Create the key objects
837
- n = p * q
838
-
839
- return (PublicKey(n, e), PrivateKey(n, e, d, p, q))
840
-
841
-
842
- __all__ = ["PublicKey", "PrivateKey", "newkeys"]
843
-
844
- if __name__ == "__main__":
845
- import doctest
846
-
847
- try:
848
- for count in range(100):
849
- (failures, tests) = doctest.testmod()
850
- if failures:
851
- break
852
-
853
- if (count % 10 == 0 and count) or count == 1:
854
- print("%i times" % count)
855
- except KeyboardInterrupt:
856
- print("Aborted")
857
- else:
858
- print("Doctests done")
1
+ # Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """RSA key generation code.
16
+
17
+ Create new keys with the newkeys() function. It will give you a PublicKey and a
18
+ PrivateKey object.
19
+
20
+ Loading and saving keys requires the pyasn1 module. This module is imported as
21
+ late as possible, such that other functionality will remain working in absence
22
+ of pyasn1.
23
+
24
+ .. note::
25
+
26
+ Storing public and private keys via the `pickle` module is possible.
27
+ However, it is insecure to load a key from an untrusted source.
28
+ The pickle module is not secure against erroneous or maliciously
29
+ constructed data. Never unpickle data received from an untrusted
30
+ or unauthenticated source.
31
+
32
+ """
33
+
34
+ import threading
35
+ import typing
36
+ import warnings
37
+
38
+ import rsa.prime
39
+ import rsa.pem
40
+ import rsa.common
41
+ import rsa.randnum
42
+ import rsa.core
43
+
44
+
45
+ DEFAULT_EXPONENT = 65537
46
+
47
+
48
+ T = typing.TypeVar("T", bound="AbstractKey")
49
+
50
+
51
+ class AbstractKey:
52
+ """Abstract superclass for private and public keys."""
53
+
54
+ __slots__ = ("n", "e", "blindfac", "blindfac_inverse", "mutex")
55
+
56
+ def __init__(self, n: int, e: int) -> None:
57
+ self.n = n
58
+ self.e = e
59
+
60
+ # These will be computed properly on the first call to blind().
61
+ self.blindfac = self.blindfac_inverse = -1
62
+
63
+ # Used to protect updates to the blinding factor in multi-threaded
64
+ # environments.
65
+ self.mutex = threading.Lock()
66
+
67
+ @classmethod
68
+ def _load_pkcs1_pem(cls: typing.Type[T], keyfile: bytes) -> T:
69
+ """Loads a key in PKCS#1 PEM format, implement in a subclass.
70
+
71
+ :param keyfile: contents of a PEM-encoded file that contains
72
+ the public key.
73
+ :type keyfile: bytes
74
+
75
+ :return: the loaded key
76
+ :rtype: AbstractKey
77
+ """
78
+
79
+ @classmethod
80
+ def _load_pkcs1_der(cls: typing.Type[T], keyfile: bytes) -> T:
81
+ """Loads a key in PKCS#1 PEM format, implement in a subclass.
82
+
83
+ :param keyfile: contents of a DER-encoded file that contains
84
+ the public key.
85
+ :type keyfile: bytes
86
+
87
+ :return: the loaded key
88
+ :rtype: AbstractKey
89
+ """
90
+
91
+ def _save_pkcs1_pem(self) -> bytes:
92
+ """Saves the key in PKCS#1 PEM format, implement in a subclass.
93
+
94
+ :returns: the PEM-encoded key.
95
+ :rtype: bytes
96
+ """
97
+
98
+ def _save_pkcs1_der(self) -> bytes:
99
+ """Saves the key in PKCS#1 DER format, implement in a subclass.
100
+
101
+ :returns: the DER-encoded key.
102
+ :rtype: bytes
103
+ """
104
+
105
+ @classmethod
106
+ def load_pkcs1(cls: typing.Type[T], keyfile: bytes, format: str = "PEM") -> T:
107
+ """Loads a key in PKCS#1 DER or PEM format.
108
+
109
+ :param keyfile: contents of a DER- or PEM-encoded file that contains
110
+ the key.
111
+ :type keyfile: bytes
112
+ :param format: the format of the file to load; 'PEM' or 'DER'
113
+ :type format: str
114
+
115
+ :return: the loaded key
116
+ :rtype: AbstractKey
117
+ """
118
+
119
+ methods = {
120
+ "PEM": cls._load_pkcs1_pem,
121
+ "DER": cls._load_pkcs1_der,
122
+ }
123
+
124
+ method = cls._assert_format_exists(format, methods)
125
+ return method(keyfile)
126
+
127
+ @staticmethod
128
+ def _assert_format_exists(
129
+ file_format: str, methods: typing.Mapping[str, typing.Callable]
130
+ ) -> typing.Callable:
131
+ """Checks whether the given file format exists in 'methods'."""
132
+
133
+ try:
134
+ return methods[file_format]
135
+ except KeyError as ex:
136
+ formats = ", ".join(sorted(methods.keys()))
137
+ raise ValueError(
138
+ "Unsupported format: %r, try one of %s" % (file_format, formats)
139
+ ) from ex
140
+
141
+ def save_pkcs1(self, format: str = "PEM") -> bytes:
142
+ """Saves the key in PKCS#1 DER or PEM format.
143
+
144
+ :param format: the format to save; 'PEM' or 'DER'
145
+ :type format: str
146
+ :returns: the DER- or PEM-encoded key.
147
+ :rtype: bytes
148
+ """
149
+
150
+ methods = {
151
+ "PEM": self._save_pkcs1_pem,
152
+ "DER": self._save_pkcs1_der,
153
+ }
154
+
155
+ method = self._assert_format_exists(format, methods)
156
+ return method()
157
+
158
+ def blind(self, message: int) -> typing.Tuple[int, int]:
159
+ """Performs blinding on the message.
160
+
161
+ :param message: the message, as integer, to blind.
162
+ :param r: the random number to blind with.
163
+ :return: tuple (the blinded message, the inverse of the used blinding factor)
164
+
165
+ The blinding is such that message = unblind(decrypt(blind(encrypt(message))).
166
+
167
+ See https://en.wikipedia.org/wiki/Blinding_%28cryptography%29
168
+ """
169
+ blindfac, blindfac_inverse = self._update_blinding_factor()
170
+ blinded = (message * pow(blindfac, self.e, self.n)) % self.n
171
+ return blinded, blindfac_inverse
172
+
173
+ def unblind(self, blinded: int, blindfac_inverse: int) -> int:
174
+ """Performs blinding on the message using random number 'blindfac_inverse'.
175
+
176
+ :param blinded: the blinded message, as integer, to unblind.
177
+ :param blindfac: the factor to unblind with.
178
+ :return: the original message.
179
+
180
+ The blinding is such that message = unblind(decrypt(blind(encrypt(message))).
181
+
182
+ See https://en.wikipedia.org/wiki/Blinding_%28cryptography%29
183
+ """
184
+ return (blindfac_inverse * blinded) % self.n
185
+
186
+ def _initial_blinding_factor(self) -> int:
187
+ for _ in range(1000):
188
+ blind_r = rsa.randnum.randint(self.n - 1)
189
+ if rsa.prime.are_relatively_prime(self.n, blind_r):
190
+ return blind_r
191
+ raise RuntimeError("unable to find blinding factor")
192
+
193
+ def _update_blinding_factor(self) -> typing.Tuple[int, int]:
194
+ """Update blinding factors.
195
+
196
+ Computing a blinding factor is expensive, so instead this function
197
+ does this once, then updates the blinding factor as per section 9
198
+ of 'A Timing Attack against RSA with the Chinese Remainder Theorem'
199
+ by Werner Schindler.
200
+ See https://tls.mbed.org/public/WSchindler-RSA_Timing_Attack.pdf
201
+
202
+ :return: the new blinding factor and its inverse.
203
+ """
204
+
205
+ with self.mutex:
206
+ if self.blindfac < 0:
207
+ # Compute initial blinding factor, which is rather slow to do.
208
+ self.blindfac = self._initial_blinding_factor()
209
+ self.blindfac_inverse = rsa.common.inverse(self.blindfac, self.n)
210
+ else:
211
+ # Reuse previous blinding factor.
212
+ self.blindfac = pow(self.blindfac, 2, self.n)
213
+ self.blindfac_inverse = pow(self.blindfac_inverse, 2, self.n)
214
+
215
+ return self.blindfac, self.blindfac_inverse
216
+
217
+
218
+ class PublicKey(AbstractKey):
219
+ """Represents a public RSA key.
220
+
221
+ This key is also known as the 'encryption key'. It contains the 'n' and 'e'
222
+ values.
223
+
224
+ Supports attributes as well as dictionary-like access. Attribute access is
225
+ faster, though.
226
+
227
+ >>> PublicKey(5, 3)
228
+ PublicKey(5, 3)
229
+
230
+ >>> key = PublicKey(5, 3)
231
+ >>> key.n
232
+ 5
233
+ >>> key['n']
234
+ 5
235
+ >>> key.e
236
+ 3
237
+ >>> key['e']
238
+ 3
239
+
240
+ """
241
+
242
+ __slots__ = ()
243
+
244
+ def __getitem__(self, key: str) -> int:
245
+ return getattr(self, key)
246
+
247
+ def __repr__(self) -> str:
248
+ return "PublicKey(%i, %i)" % (self.n, self.e)
249
+
250
+ def __getstate__(self) -> typing.Tuple[int, int]:
251
+ """Returns the key as tuple for pickling."""
252
+ return self.n, self.e
253
+
254
+ def __setstate__(self, state: typing.Tuple[int, int]) -> None:
255
+ """Sets the key from tuple."""
256
+ self.n, self.e = state
257
+ AbstractKey.__init__(self, self.n, self.e)
258
+
259
+ def __eq__(self, other: typing.Any) -> bool:
260
+ if other is None:
261
+ return False
262
+
263
+ if not isinstance(other, PublicKey):
264
+ return False
265
+
266
+ return self.n == other.n and self.e == other.e
267
+
268
+ def __ne__(self, other: typing.Any) -> bool:
269
+ return not (self == other)
270
+
271
+ def __hash__(self) -> int:
272
+ return hash((self.n, self.e))
273
+
274
+ @classmethod
275
+ def _load_pkcs1_der(cls, keyfile: bytes) -> "PublicKey":
276
+ """Loads a key in PKCS#1 DER format.
277
+
278
+ :param keyfile: contents of a DER-encoded file that contains the public
279
+ key.
280
+ :return: a PublicKey object
281
+
282
+ First let's construct a DER encoded key:
283
+
284
+ >>> import base64
285
+ >>> b64der = 'MAwCBQCNGmYtAgMBAAE='
286
+ >>> der = base64.standard_b64decode(b64der)
287
+
288
+ This loads the file:
289
+
290
+ >>> PublicKey._load_pkcs1_der(der)
291
+ PublicKey(2367317549, 65537)
292
+
293
+ """
294
+
295
+ from pyasn1.codec.der import decoder
296
+ from rsa.asn1 import AsnPubKey
297
+
298
+ (priv, _) = decoder.decode(keyfile, asn1Spec=AsnPubKey())
299
+ return cls(n=int(priv["modulus"]), e=int(priv["publicExponent"]))
300
+
301
+ def _save_pkcs1_der(self) -> bytes:
302
+ """Saves the public key in PKCS#1 DER format.
303
+
304
+ :returns: the DER-encoded public key.
305
+ :rtype: bytes
306
+ """
307
+
308
+ from pyasn1.codec.der import encoder
309
+ from rsa.asn1 import AsnPubKey
310
+
311
+ # Create the ASN object
312
+ asn_key = AsnPubKey()
313
+ asn_key.setComponentByName("modulus", self.n)
314
+ asn_key.setComponentByName("publicExponent", self.e)
315
+
316
+ return encoder.encode(asn_key)
317
+
318
+ @classmethod
319
+ def _load_pkcs1_pem(cls, keyfile: bytes) -> "PublicKey":
320
+ """Loads a PKCS#1 PEM-encoded public key file.
321
+
322
+ The contents of the file before the "-----BEGIN RSA PUBLIC KEY-----" and
323
+ after the "-----END RSA PUBLIC KEY-----" lines is ignored.
324
+
325
+ :param keyfile: contents of a PEM-encoded file that contains the public
326
+ key.
327
+ :return: a PublicKey object
328
+ """
329
+
330
+ der = rsa.pem.load_pem(keyfile, "RSA PUBLIC KEY")
331
+ return cls._load_pkcs1_der(der)
332
+
333
+ def _save_pkcs1_pem(self) -> bytes:
334
+ """Saves a PKCS#1 PEM-encoded public key file.
335
+
336
+ :return: contents of a PEM-encoded file that contains the public key.
337
+ :rtype: bytes
338
+ """
339
+
340
+ der = self._save_pkcs1_der()
341
+ return rsa.pem.save_pem(der, "RSA PUBLIC KEY")
342
+
343
+ @classmethod
344
+ def load_pkcs1_openssl_pem(cls, keyfile: bytes) -> "PublicKey":
345
+ """Loads a PKCS#1.5 PEM-encoded public key file from OpenSSL.
346
+
347
+ These files can be recognised in that they start with BEGIN PUBLIC KEY
348
+ rather than BEGIN RSA PUBLIC KEY.
349
+
350
+ The contents of the file before the "-----BEGIN PUBLIC KEY-----" and
351
+ after the "-----END PUBLIC KEY-----" lines is ignored.
352
+
353
+ :param keyfile: contents of a PEM-encoded file that contains the public
354
+ key, from OpenSSL.
355
+ :type keyfile: bytes
356
+ :return: a PublicKey object
357
+ """
358
+
359
+ der = rsa.pem.load_pem(keyfile, "PUBLIC KEY")
360
+ return cls.load_pkcs1_openssl_der(der)
361
+
362
+ @classmethod
363
+ def load_pkcs1_openssl_der(cls, keyfile: bytes) -> "PublicKey":
364
+ """Loads a PKCS#1 DER-encoded public key file from OpenSSL.
365
+
366
+ :param keyfile: contents of a DER-encoded file that contains the public
367
+ key, from OpenSSL.
368
+ :return: a PublicKey object
369
+ """
370
+
371
+ from rsa.asn1 import OpenSSLPubKey
372
+ from pyasn1.codec.der import decoder
373
+ from pyasn1.type import univ
374
+
375
+ (keyinfo, _) = decoder.decode(keyfile, asn1Spec=OpenSSLPubKey())
376
+
377
+ if keyinfo["header"]["oid"] != univ.ObjectIdentifier("1.2.840.113549.1.1.1"):
378
+ raise TypeError("This is not a DER-encoded OpenSSL-compatible public key")
379
+
380
+ return cls._load_pkcs1_der(keyinfo["key"][1:])
381
+
382
+
383
+ class PrivateKey(AbstractKey):
384
+ """Represents a private RSA key.
385
+
386
+ This key is also known as the 'decryption key'. It contains the 'n', 'e',
387
+ 'd', 'p', 'q' and other values.
388
+
389
+ Supports attributes as well as dictionary-like access. Attribute access is
390
+ faster, though.
391
+
392
+ >>> PrivateKey(3247, 65537, 833, 191, 17)
393
+ PrivateKey(3247, 65537, 833, 191, 17)
394
+
395
+ exp1, exp2 and coef will be calculated:
396
+
397
+ >>> pk = PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
398
+ >>> pk.exp1
399
+ 55063
400
+ >>> pk.exp2
401
+ 10095
402
+ >>> pk.coef
403
+ 50797
404
+
405
+ """
406
+
407
+ __slots__ = ("d", "p", "q", "exp1", "exp2", "coef")
408
+
409
+ def __init__(self, n: int, e: int, d: int, p: int, q: int) -> None:
410
+ AbstractKey.__init__(self, n, e)
411
+ self.d = d
412
+ self.p = p
413
+ self.q = q
414
+
415
+ # Calculate exponents and coefficient.
416
+ self.exp1 = int(d % (p - 1))
417
+ self.exp2 = int(d % (q - 1))
418
+ self.coef = rsa.common.inverse(q, p)
419
+
420
+ def __getitem__(self, key: str) -> int:
421
+ return getattr(self, key)
422
+
423
+ def __repr__(self) -> str:
424
+ return "PrivateKey(%i, %i, %i, %i, %i)" % (
425
+ self.n,
426
+ self.e,
427
+ self.d,
428
+ self.p,
429
+ self.q,
430
+ )
431
+
432
+ def __getstate__(self) -> typing.Tuple[int, int, int, int, int, int, int, int]:
433
+ """Returns the key as tuple for pickling."""
434
+ return self.n, self.e, self.d, self.p, self.q, self.exp1, self.exp2, self.coef
435
+
436
+ def __setstate__(self, state: typing.Tuple[int, int, int, int, int, int, int, int]) -> None:
437
+ """Sets the key from tuple."""
438
+ self.n, self.e, self.d, self.p, self.q, self.exp1, self.exp2, self.coef = state
439
+ AbstractKey.__init__(self, self.n, self.e)
440
+
441
+ def __eq__(self, other: typing.Any) -> bool:
442
+ if other is None:
443
+ return False
444
+
445
+ if not isinstance(other, PrivateKey):
446
+ return False
447
+
448
+ return (
449
+ self.n == other.n
450
+ and self.e == other.e
451
+ and self.d == other.d
452
+ and self.p == other.p
453
+ and self.q == other.q
454
+ and self.exp1 == other.exp1
455
+ and self.exp2 == other.exp2
456
+ and self.coef == other.coef
457
+ )
458
+
459
+ def __ne__(self, other: typing.Any) -> bool:
460
+ return not (self == other)
461
+
462
+ def __hash__(self) -> int:
463
+ return hash((self.n, self.e, self.d, self.p, self.q, self.exp1, self.exp2, self.coef))
464
+
465
+ def blinded_decrypt(self, encrypted: int) -> int:
466
+ """Decrypts the message using blinding to prevent side-channel attacks.
467
+
468
+ :param encrypted: the encrypted message
469
+ :type encrypted: int
470
+
471
+ :returns: the decrypted message
472
+ :rtype: int
473
+ """
474
+
475
+ # Blinding and un-blinding should be using the same factor
476
+ blinded, blindfac_inverse = self.blind(encrypted)
477
+
478
+ # Instead of using the core functionality, use the Chinese Remainder
479
+ # Theorem and be 2-4x faster. This the same as:
480
+ #
481
+ # decrypted = rsa.core.decrypt_int(blinded, self.d, self.n)
482
+ s1 = pow(blinded, self.exp1, self.p)
483
+ s2 = pow(blinded, self.exp2, self.q)
484
+ h = ((s1 - s2) * self.coef) % self.p
485
+ decrypted = s2 + self.q * h
486
+
487
+ return self.unblind(decrypted, blindfac_inverse)
488
+
489
+ def blinded_encrypt(self, message: int) -> int:
490
+ """Encrypts the message using blinding to prevent side-channel attacks.
491
+
492
+ :param message: the message to encrypt
493
+ :type message: int
494
+
495
+ :returns: the encrypted message
496
+ :rtype: int
497
+ """
498
+
499
+ blinded, blindfac_inverse = self.blind(message)
500
+ encrypted = rsa.core.encrypt_int(blinded, self.d, self.n)
501
+ return self.unblind(encrypted, blindfac_inverse)
502
+
503
+ @classmethod
504
+ def _load_pkcs1_der(cls, keyfile: bytes) -> "PrivateKey":
505
+ """Loads a key in PKCS#1 DER format.
506
+
507
+ :param keyfile: contents of a DER-encoded file that contains the private
508
+ key.
509
+ :type keyfile: bytes
510
+ :return: a PrivateKey object
511
+
512
+ First let's construct a DER encoded key:
513
+
514
+ >>> import base64
515
+ >>> b64der = 'MC4CAQACBQDeKYlRAgMBAAECBQDHn4npAgMA/icCAwDfxwIDANcXAgInbwIDAMZt'
516
+ >>> der = base64.standard_b64decode(b64der)
517
+
518
+ This loads the file:
519
+
520
+ >>> PrivateKey._load_pkcs1_der(der)
521
+ PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
522
+
523
+ """
524
+
525
+ from pyasn1.codec.der import decoder
526
+
527
+ (priv, _) = decoder.decode(keyfile)
528
+
529
+ # ASN.1 contents of DER encoded private key:
530
+ #
531
+ # RSAPrivateKey ::= SEQUENCE {
532
+ # version Version,
533
+ # modulus INTEGER, -- n
534
+ # publicExponent INTEGER, -- e
535
+ # privateExponent INTEGER, -- d
536
+ # prime1 INTEGER, -- p
537
+ # prime2 INTEGER, -- q
538
+ # exponent1 INTEGER, -- d mod (p-1)
539
+ # exponent2 INTEGER, -- d mod (q-1)
540
+ # coefficient INTEGER, -- (inverse of q) mod p
541
+ # otherPrimeInfos OtherPrimeInfos OPTIONAL
542
+ # }
543
+
544
+ if priv[0] != 0:
545
+ raise ValueError("Unable to read this file, version %s != 0" % priv[0])
546
+
547
+ as_ints = map(int, priv[1:6])
548
+ key = cls(*as_ints)
549
+
550
+ exp1, exp2, coef = map(int, priv[6:9])
551
+
552
+ if (key.exp1, key.exp2, key.coef) != (exp1, exp2, coef):
553
+ warnings.warn(
554
+ "You have provided a malformed keyfile. Either the exponents "
555
+ "or the coefficient are incorrect. Using the correct values "
556
+ "instead.",
557
+ UserWarning,
558
+ )
559
+
560
+ return key
561
+
562
+ def _save_pkcs1_der(self) -> bytes:
563
+ """Saves the private key in PKCS#1 DER format.
564
+
565
+ :returns: the DER-encoded private key.
566
+ :rtype: bytes
567
+ """
568
+
569
+ from pyasn1.type import univ, namedtype
570
+ from pyasn1.codec.der import encoder
571
+
572
+ class AsnPrivKey(univ.Sequence):
573
+ componentType = namedtype.NamedTypes(
574
+ namedtype.NamedType("version", univ.Integer()),
575
+ namedtype.NamedType("modulus", univ.Integer()),
576
+ namedtype.NamedType("publicExponent", univ.Integer()),
577
+ namedtype.NamedType("privateExponent", univ.Integer()),
578
+ namedtype.NamedType("prime1", univ.Integer()),
579
+ namedtype.NamedType("prime2", univ.Integer()),
580
+ namedtype.NamedType("exponent1", univ.Integer()),
581
+ namedtype.NamedType("exponent2", univ.Integer()),
582
+ namedtype.NamedType("coefficient", univ.Integer()),
583
+ )
584
+
585
+ # Create the ASN object
586
+ asn_key = AsnPrivKey()
587
+ asn_key.setComponentByName("version", 0)
588
+ asn_key.setComponentByName("modulus", self.n)
589
+ asn_key.setComponentByName("publicExponent", self.e)
590
+ asn_key.setComponentByName("privateExponent", self.d)
591
+ asn_key.setComponentByName("prime1", self.p)
592
+ asn_key.setComponentByName("prime2", self.q)
593
+ asn_key.setComponentByName("exponent1", self.exp1)
594
+ asn_key.setComponentByName("exponent2", self.exp2)
595
+ asn_key.setComponentByName("coefficient", self.coef)
596
+
597
+ return encoder.encode(asn_key)
598
+
599
+ @classmethod
600
+ def _load_pkcs1_pem(cls, keyfile: bytes) -> "PrivateKey":
601
+ """Loads a PKCS#1 PEM-encoded private key file.
602
+
603
+ The contents of the file before the "-----BEGIN RSA PRIVATE KEY-----" and
604
+ after the "-----END RSA PRIVATE KEY-----" lines is ignored.
605
+
606
+ :param keyfile: contents of a PEM-encoded file that contains the private
607
+ key.
608
+ :type keyfile: bytes
609
+ :return: a PrivateKey object
610
+ """
611
+
612
+ der = rsa.pem.load_pem(keyfile, b"RSA PRIVATE KEY")
613
+ return cls._load_pkcs1_der(der)
614
+
615
+ def _save_pkcs1_pem(self) -> bytes:
616
+ """Saves a PKCS#1 PEM-encoded private key file.
617
+
618
+ :return: contents of a PEM-encoded file that contains the private key.
619
+ :rtype: bytes
620
+ """
621
+
622
+ der = self._save_pkcs1_der()
623
+ return rsa.pem.save_pem(der, b"RSA PRIVATE KEY")
624
+
625
+
626
+ def find_p_q(
627
+ nbits: int,
628
+ getprime_func: typing.Callable[[int], int] = rsa.prime.getprime,
629
+ accurate: bool = True,
630
+ ) -> typing.Tuple[int, int]:
631
+ """Returns a tuple of two different primes of nbits bits each.
632
+
633
+ The resulting p * q has exactly 2 * nbits bits, and the returned p and q
634
+ will not be equal.
635
+
636
+ :param nbits: the number of bits in each of p and q.
637
+ :param getprime_func: the getprime function, defaults to
638
+ :py:func:`rsa.prime.getprime`.
639
+
640
+ *Introduced in Python-RSA 3.1*
641
+
642
+ :param accurate: whether to enable accurate mode or not.
643
+ :returns: (p, q), where p > q
644
+
645
+ >>> (p, q) = find_p_q(128)
646
+ >>> from rsa import common
647
+ >>> common.bit_size(p * q)
648
+ 256
649
+
650
+ When not in accurate mode, the number of bits can be slightly less
651
+
652
+ >>> (p, q) = find_p_q(128, accurate=False)
653
+ >>> from rsa import common
654
+ >>> common.bit_size(p * q) <= 256
655
+ True
656
+ >>> common.bit_size(p * q) > 240
657
+ True
658
+
659
+ """
660
+
661
+ total_bits = nbits * 2
662
+
663
+ # Make sure that p and q aren't too close or the factoring programs can
664
+ # factor n.
665
+ shift = nbits // 16
666
+ pbits = nbits + shift
667
+ qbits = nbits - shift
668
+
669
+ # Choose the two initial primes
670
+ p = getprime_func(pbits)
671
+ q = getprime_func(qbits)
672
+
673
+ def is_acceptable(p: int, q: int) -> bool:
674
+ """Returns True iff p and q are acceptable:
675
+
676
+ - p and q differ
677
+ - (p * q) has the right nr of bits (when accurate=True)
678
+ """
679
+
680
+ if p == q:
681
+ return False
682
+
683
+ if not accurate:
684
+ return True
685
+
686
+ # Make sure we have just the right amount of bits
687
+ found_size = rsa.common.bit_size(p * q)
688
+ return total_bits == found_size
689
+
690
+ # Keep choosing other primes until they match our requirements.
691
+ change_p = False
692
+ while not is_acceptable(p, q):
693
+ # Change p on one iteration and q on the other
694
+ if change_p:
695
+ p = getprime_func(pbits)
696
+ else:
697
+ q = getprime_func(qbits)
698
+
699
+ change_p = not change_p
700
+
701
+ # We want p > q as described on
702
+ # http://www.di-mgt.com.au/rsa_alg.html#crt
703
+ return max(p, q), min(p, q)
704
+
705
+
706
+ def calculate_keys_custom_exponent(p: int, q: int, exponent: int) -> typing.Tuple[int, int]:
707
+ """Calculates an encryption and a decryption key given p, q and an exponent,
708
+ and returns them as a tuple (e, d)
709
+
710
+ :param p: the first large prime
711
+ :param q: the second large prime
712
+ :param exponent: the exponent for the key; only change this if you know
713
+ what you're doing, as the exponent influences how difficult your
714
+ private key can be cracked. A very common choice for e is 65537.
715
+ :type exponent: int
716
+
717
+ """
718
+
719
+ phi_n = (p - 1) * (q - 1)
720
+
721
+ try:
722
+ d = rsa.common.inverse(exponent, phi_n)
723
+ except rsa.common.NotRelativePrimeError as ex:
724
+ raise rsa.common.NotRelativePrimeError(
725
+ exponent,
726
+ phi_n,
727
+ ex.d,
728
+ msg="e (%d) and phi_n (%d) are not relatively prime (divider=%i)"
729
+ % (exponent, phi_n, ex.d),
730
+ ) from ex
731
+
732
+ if (exponent * d) % phi_n != 1:
733
+ raise ValueError(
734
+ "e (%d) and d (%d) are not mult. inv. modulo " "phi_n (%d)" % (exponent, d, phi_n)
735
+ )
736
+
737
+ return exponent, d
738
+
739
+
740
+ def calculate_keys(p: int, q: int) -> typing.Tuple[int, int]:
741
+ """Calculates an encryption and a decryption key given p and q, and
742
+ returns them as a tuple (e, d)
743
+
744
+ :param p: the first large prime
745
+ :param q: the second large prime
746
+
747
+ :return: tuple (e, d) with the encryption and decryption exponents.
748
+ """
749
+
750
+ return calculate_keys_custom_exponent(p, q, DEFAULT_EXPONENT)
751
+
752
+
753
+ def gen_keys(
754
+ nbits: int,
755
+ getprime_func: typing.Callable[[int], int],
756
+ accurate: bool = True,
757
+ exponent: int = DEFAULT_EXPONENT,
758
+ ) -> typing.Tuple[int, int, int, int]:
759
+ """Generate RSA keys of nbits bits. Returns (p, q, e, d).
760
+
761
+ Note: this can take a long time, depending on the key size.
762
+
763
+ :param nbits: the total number of bits in ``p`` and ``q``. Both ``p`` and
764
+ ``q`` will use ``nbits/2`` bits.
765
+ :param getprime_func: either :py:func:`rsa.prime.getprime` or a function
766
+ with similar signature.
767
+ :param exponent: the exponent for the key; only change this if you know
768
+ what you're doing, as the exponent influences how difficult your
769
+ private key can be cracked. A very common choice for e is 65537.
770
+ :type exponent: int
771
+ """
772
+
773
+ # Regenerate p and q values, until calculate_keys doesn't raise a
774
+ # ValueError.
775
+ while True:
776
+ (p, q) = find_p_q(nbits // 2, getprime_func, accurate)
777
+ try:
778
+ (e, d) = calculate_keys_custom_exponent(p, q, exponent=exponent)
779
+ break
780
+ except ValueError:
781
+ pass
782
+
783
+ return p, q, e, d
784
+
785
+
786
+ def newkeys(
787
+ nbits: int,
788
+ accurate: bool = True,
789
+ poolsize: int = 1,
790
+ exponent: int = DEFAULT_EXPONENT,
791
+ ) -> typing.Tuple[PublicKey, PrivateKey]:
792
+ """Generates public and private keys, and returns them as (pub, priv).
793
+
794
+ The public key is also known as the 'encryption key', and is a
795
+ :py:class:`rsa.PublicKey` object. The private key is also known as the
796
+ 'decryption key' and is a :py:class:`rsa.PrivateKey` object.
797
+
798
+ :param nbits: the number of bits required to store ``n = p*q``.
799
+ :param accurate: when True, ``n`` will have exactly the number of bits you
800
+ asked for. However, this makes key generation much slower. When False,
801
+ `n`` may have slightly less bits.
802
+ :param poolsize: the number of processes to use to generate the prime
803
+ numbers. If set to a number > 1, a parallel algorithm will be used.
804
+ This requires Python 2.6 or newer.
805
+ :param exponent: the exponent for the key; only change this if you know
806
+ what you're doing, as the exponent influences how difficult your
807
+ private key can be cracked. A very common choice for e is 65537.
808
+ :type exponent: int
809
+
810
+ :returns: a tuple (:py:class:`rsa.PublicKey`, :py:class:`rsa.PrivateKey`)
811
+
812
+ The ``poolsize`` parameter was added in *Python-RSA 3.1* and requires
813
+ Python 2.6 or newer.
814
+
815
+ """
816
+
817
+ if nbits < 16:
818
+ raise ValueError("Key too small")
819
+
820
+ if poolsize < 1:
821
+ raise ValueError("Pool size (%i) should be >= 1" % poolsize)
822
+
823
+ # Determine which getprime function to use
824
+ if poolsize > 1:
825
+ from rsa import parallel
826
+
827
+ def getprime_func(nbits: int) -> int:
828
+ return parallel.getprime(nbits, poolsize=poolsize)
829
+
830
+ else:
831
+ getprime_func = rsa.prime.getprime
832
+
833
+ # Generate the key components
834
+ (p, q, e, d) = gen_keys(nbits, getprime_func, accurate=accurate, exponent=exponent)
835
+
836
+ # Create the key objects
837
+ n = p * q
838
+
839
+ return (PublicKey(n, e), PrivateKey(n, e, d, p, q))
840
+
841
+
842
+ __all__ = ["PublicKey", "PrivateKey", "newkeys"]
843
+
844
+ if __name__ == "__main__":
845
+ import doctest
846
+
847
+ try:
848
+ for count in range(100):
849
+ (failures, tests) = doctest.testmod()
850
+ if failures:
851
+ break
852
+
853
+ if (count % 10 == 0 and count) or count == 1:
854
+ print("%i times" % count)
855
+ except KeyboardInterrupt:
856
+ print("Aborted")
857
+ else:
858
+ print("Doctests done")