Skip to content

Commit 0373718

Browse files
authored
Paint it Black by the Rolling Stones (#920)
1 parent 4ca4fb9 commit 0373718

23 files changed

+1466
-1023
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
- python: "2.7"
8484
env: TOXENV=pypi-readme
8585

86-
- python: "2.7"
86+
- python: "3.8"
8787
env: TOXENV=flake8
8888

8989
- python: "2.7"

doc/conf.py

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def read_file(*parts):
3232

3333
def find_version(*file_paths):
3434
version_file = read_file(*file_paths)
35-
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
36-
version_file, re.M)
35+
version_match = re.search(
36+
r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M
37+
)
3738
if version_match:
3839
return version_match.group(1)
3940
raise RuntimeError("Unable to find version string.")
@@ -45,34 +46,34 @@ def find_version(*file_paths):
4546
# If extensions (or modules to document with autodoc) are in another directory,
4647
# add these directories to sys.path here. If the directory is relative to the
4748
# documentation root, use os.path.abspath to make it absolute, like shown here.
48-
#sys.path.insert(0, os.path.abspath('.'))
49+
# sys.path.insert(0, os.path.abspath('.'))
4950

5051
# -- General configuration -----------------------------------------------------
5152

5253
# If your documentation needs a minimal Sphinx version, state it here.
53-
needs_sphinx = '1.0'
54+
needs_sphinx = "1.0"
5455

5556
# Add any Sphinx extension module names here, as strings. They can be
5657
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
5758
extensions = [
5859
"sphinx.ext.autodoc",
59-
'sphinx.ext.intersphinx',
60+
"sphinx.ext.intersphinx",
6061
]
6162

6263
# Add any paths that contain templates here, relative to this directory.
63-
templates_path = ['_templates']
64+
templates_path = ["_templates"]
6465

6566
# The suffix of source filenames.
66-
source_suffix = '.rst'
67+
source_suffix = ".rst"
6768

6869
# The encoding of source files.
69-
#source_encoding = 'utf-8-sig'
70+
# source_encoding = 'utf-8-sig'
7071

7172
# The master toctree document.
72-
master_doc = 'index'
73+
master_doc = "index"
7374

7475
# General information about the project.
75-
project = u'pyOpenSSL'
76+
project = u"pyOpenSSL"
7677
authors = u"The pyOpenSSL developers"
7778
copyright = u"2001 " + authors
7879

@@ -87,73 +88,74 @@ def find_version(*file_paths):
8788

8889
# The language for content autogenerated by Sphinx. Refer to documentation
8990
# for a list of supported languages.
90-
#language = None
91+
# language = None
9192

9293
# There are two options for replacing |today|: either, you set today to some
9394
# non-false value, then it is used:
94-
#today = ''
95+
# today = ''
9596
# Else, today_fmt is used as the format for a strftime call.
96-
#today_fmt = '%B %d, %Y'
97+
# today_fmt = '%B %d, %Y'
9798

9899
# List of patterns, relative to source directory, that match files and
99100
# directories to ignore when looking for source files.
100-
exclude_patterns = ['_build']
101+
exclude_patterns = ["_build"]
101102

102103
# The reST default role (used for this markup: `text`) to use for all documents.
103-
#default_role = None
104+
# default_role = None
104105

105106
# If true, '()' will be appended to :func: etc. cross-reference text.
106-
#add_function_parentheses = True
107+
# add_function_parentheses = True
107108

108109
# If true, the current module name will be prepended to all description
109110
# unit titles (such as .. function::).
110-
#add_module_names = True
111+
# add_module_names = True
111112

112113
# If true, sectionauthor and moduleauthor directives will be shown in the
113114
# output. They are ignored by default.
114-
#show_authors = False
115+
# show_authors = False
115116

116117
# The name of the Pygments (syntax highlighting) style to use.
117-
pygments_style = 'sphinx'
118+
pygments_style = "sphinx"
118119

119120
# A list of ignored prefixes for module index sorting.
120-
#modindex_common_prefix = []
121+
# modindex_common_prefix = []
121122

122123

123124
# -- Options for HTML output ---------------------------------------------------
124125

125126
# The theme to use for HTML and HTML Help pages. See the documentation for
126127
# a list of builtin themes.
127-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
128+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
128129

129130
if not on_rtd: # only import and set the theme if we're building docs locally
130131
import sphinx_rtd_theme
131-
html_theme = 'sphinx_rtd_theme'
132+
133+
html_theme = "sphinx_rtd_theme"
132134
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
133135

134136
# Theme options are theme-specific and customize the look and feel of a theme
135137
# further. For a list of options available for each theme, see the
136138
# documentation.
137-
#html_theme_options = {}
139+
# html_theme_options = {}
138140

139141
# Add any paths that contain custom themes here, relative to this directory.
140-
#html_theme_path = []
142+
# html_theme_path = []
141143

142144
# The name for this set of Sphinx documents. If None, it defaults to
143145
# "<project> v<release> documentation".
144-
#html_title = None
146+
# html_title = None
145147

146148
# A shorter title for the navigation bar. Default is the same as html_title.
147-
#html_short_title = None
149+
# html_short_title = None
148150

149151
# The name of an image file (relative to this directory) to place at the top
150152
# of the sidebar.
151-
#html_logo = None
153+
# html_logo = None
152154

153155
# The name of an image file (within the static path) to use as favicon of the
154156
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
155157
# pixels large.
156-
#html_favicon = None
158+
# html_favicon = None
157159

158160
# Add any paths that contain custom static files (such as style sheets) here,
159161
# relative to this directory. They are copied after the builtin static files,
@@ -162,96 +164,92 @@ def find_version(*file_paths):
162164

163165
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
164166
# using the given strftime format.
165-
#html_last_updated_fmt = '%b %d, %Y'
167+
# html_last_updated_fmt = '%b %d, %Y'
166168

167169
# If true, SmartyPants will be used to convert quotes and dashes to
168170
# typographically correct entities.
169-
#html_use_smartypants = True
171+
# html_use_smartypants = True
170172

171173
# Custom sidebar templates, maps document names to template names.
172-
#html_sidebars = {}
174+
# html_sidebars = {}
173175

174176
# Additional templates that should be rendered to pages, maps page names to
175177
# template names.
176-
#html_additional_pages = {}
178+
# html_additional_pages = {}
177179

178180
# If false, no module index is generated.
179-
#html_domain_indices = True
181+
# html_domain_indices = True
180182

181183
# If false, no index is generated.
182-
#html_use_index = True
184+
# html_use_index = True
183185

184186
# If true, the index is split into individual pages for each letter.
185-
#html_split_index = False
187+
# html_split_index = False
186188

187189
# If true, links to the reST sources are added to the pages.
188-
#html_show_sourcelink = True
190+
# html_show_sourcelink = True
189191

190192
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
191-
#html_show_sphinx = True
193+
# html_show_sphinx = True
192194

193195
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
194-
#html_show_copyright = True
196+
# html_show_copyright = True
195197

196198
# If true, an OpenSearch description file will be output, and all pages will
197199
# contain a <link> tag referring to it. The value of this option must be the
198200
# base URL from which the finished HTML is served.
199-
#html_use_opensearch = ''
201+
# html_use_opensearch = ''
200202

201203
# This is the file name suffix for HTML files (e.g. ".xhtml").
202-
#html_file_suffix = None
204+
# html_file_suffix = None
203205

204206
# Output file base name for HTML help builder.
205-
htmlhelp_basename = 'pyOpenSSLdoc'
207+
htmlhelp_basename = "pyOpenSSLdoc"
206208

207209

208210
# -- Options for LaTeX output --------------------------------------------------
209211

210212
# The paper size ('letter' or 'a4').
211-
#latex_paper_size = 'letter'
213+
# latex_paper_size = 'letter'
212214

213215
# The font size ('10pt', '11pt' or '12pt').
214-
#latex_font_size = '10pt'
216+
# latex_font_size = '10pt'
215217

216218
# Grouping the document tree into LaTeX files. List of tuples
217219
# (source start file, target name, title, author, documentclass [howto/manual]).
218220
latex_documents = [
219-
('index', 'pyOpenSSL.tex', u'pyOpenSSL Documentation',
220-
authors, 'manual'),
221+
("index", "pyOpenSSL.tex", u"pyOpenSSL Documentation", authors, "manual"),
221222
]
222223

223224
# The name of an image file (relative to this directory) to place at the top of
224225
# the title page.
225-
#latex_logo = None
226+
# latex_logo = None
226227

227228
# For "manual" documents, if this is true, then toplevel headings are parts,
228229
# not chapters.
229-
#latex_use_parts = False
230+
# latex_use_parts = False
230231

231232
# If true, show page references after internal links.
232-
#latex_show_pagerefs = False
233+
# latex_show_pagerefs = False
233234

234235
# If true, show URL addresses after external links.
235-
#latex_show_urls = False
236+
# latex_show_urls = False
236237

237238
# Additional stuff for the LaTeX preamble.
238-
#latex_preamble = ''
239+
# latex_preamble = ''
239240

240241
# Documents to append as an appendix to all manuals.
241-
#latex_appendices = []
242+
# latex_appendices = []
242243

243244
# If false, no module index is generated.
244-
#latex_domain_indices = True
245+
# latex_domain_indices = True
245246

246247

247248
# -- Options for manual page output --------------------------------------------
248249

249250
# One entry per manual page. List of tuples
250251
# (source start file, name, description, authors, manual section).
251-
man_pages = [
252-
('index', 'pyopenssl', u'pyOpenSSL Documentation',
253-
[authors], 1)
254-
]
252+
man_pages = [("index", "pyopenssl", u"pyOpenSSL Documentation", [authors], 1)]
255253

256254
intersphinx_mapping = {
257255
"https://docs.python.org/3": None,

leakcheck/context-info-callback.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"0QwrX8nxFeTytr8pFGezj4a4KVCdb2B3CL+p3f70K7RIo9d/7b6frJI6ZL/LHQf2\n"
3030
"UP4pKRDkgKsVDx7MELECQGm072/Z7vmb03h/uE95IYJOgY4nfmYs0QKA9Is18wUz\n"
3131
"DpjfE33p0Ha6GO1VZRIQoqE24F8o5oimy3BEjryFuw4=\n"
32-
"-----END RSA PRIVATE KEY-----\n")
32+
"-----END RSA PRIVATE KEY-----\n"
33+
)
3334

3435

3536
cleartextCertificatePEM = (
@@ -48,24 +49,31 @@
4849
"q55LJdOnJbCCXIgxLdoVmvYAz1ZJq1eGKgKWI5QLgxiSzJLEU7KK//aVfiZzoCd5\n"
4950
"RipBiEEMEV4eAY317bHPwPP+4Bj9t0l8AsDLseC5vLRHgxrLEu3bn08DYx6imB5Q\n"
5051
"UBj849/xpszEM7BhwKE0GiQ=\n"
51-
"-----END CERTIFICATE-----\n")
52+
"-----END CERTIFICATE-----\n"
53+
)
5254

5355
count = count()
56+
57+
5458
def go():
5559
port = socket()
56-
port.bind(('', 0))
60+
port.bind(("", 0))
5761
port.listen(1)
5862

5963
called = []
64+
6065
def info(conn, where, ret):
6166
print count.next()
6267
called.append(None)
68+
6369
context = Context(TLSv1_METHOD)
6470
context.set_info_callback(info)
6571
context.use_certificate(
66-
load_certificate(FILETYPE_PEM, cleartextCertificatePEM))
72+
load_certificate(FILETYPE_PEM, cleartextCertificatePEM)
73+
)
6774
context.use_privatekey(
68-
load_privatekey(FILETYPE_PEM, cleartextPrivateKeyPEM))
75+
load_privatekey(FILETYPE_PEM, cleartextPrivateKeyPEM)
76+
)
6977

7078
while 1:
7179
client = socket()

leakcheck/context-passphrase-callback.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,23 @@
1515

1616
k = PKey()
1717
k.generate_key(TYPE_RSA, 128)
18-
file('pkey.pem', 'w').write(dump_privatekey(FILETYPE_PEM, k, "blowfish", "foobar"))
18+
file("pkey.pem", "w").write(
19+
dump_privatekey(FILETYPE_PEM, k, "blowfish", "foobar")
20+
)
1921

2022
count = count()
23+
24+
2125
def go():
2226
def cb(a, b, c):
2327
print count.next()
2428
return "foobar"
29+
2530
c = Context(TLSv1_METHOD)
2631
c.set_passwd_cb(cb)
2732
while 1:
28-
c.use_privatekey_file('pkey.pem')
33+
c.use_privatekey_file("pkey.pem")
34+
2935

3036
threads = [Thread(target=go, args=()) for i in xrange(2)]
3137
for th in threads:

0 commit comments

Comments
 (0)