Skip to content

Commit 47aa00a

Browse files
committed
Use autodoc for OpenSSL.crypto
1 parent 3d231f0 commit 47aa00a

File tree

2 files changed

+42
-115
lines changed

2 files changed

+42
-115
lines changed

doc/api/crypto.rst

Lines changed: 14 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,9 @@
1616
Elliptic curves
1717
---------------
1818

19-
.. py:function:: get_elliptic_curves
20-
21-
Return a set of objects representing the elliptic curves supported in the
22-
OpenSSL build in use.
23-
24-
The curve objects have a :py:class:`unicode` ``name`` attribute by which
25-
they identify themselves.
26-
27-
The curve objects are useful as values for the argument accepted by
28-
:py:meth:`Context.set_tmp_ecdh` to specify which elliptical curve should be
29-
used for ECDHE key exchange.
30-
31-
32-
.. py:function:: get_elliptic_curve(name)
33-
34-
Return a single curve object selected by *name*.
35-
36-
See :py:func:`get_elliptic_curves` for information about curve objects.
37-
38-
If the named curve is not supported then :py:class:`ValueError` is raised.
19+
.. autofunction:: get_elliptic_curves
3920

21+
.. autofunction:: get_elliptic_curve
4022

4123
Serialization and deserialization
4224
---------------------------------
@@ -54,42 +36,23 @@ The following serialization functions take one of these constants to determine t
5436
Certificates
5537
~~~~~~~~~~~~
5638

57-
.. py:function:: dump_certificate(type, cert)
58-
59-
Dump the certificate *cert* into a buffer string encoded with the type
60-
*type*.
61-
62-
.. py:function:: load_certificate(type, buffer)
39+
.. autofunction:: dump_certificate
6340

64-
Load a certificate (X509) from the string *buffer* encoded with the
65-
type *type*.
41+
.. autofunction:: load_certificate
6642

6743
Certificate signing requests
6844
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6945

70-
.. py:function:: dump_certificate_request(type, req)
46+
.. autofunction:: dump_certificate_request
7147

72-
Dump the certificate request *req* into a buffer string encoded with the
73-
type *type*.
74-
75-
.. py:function:: load_certificate_request(type, buffer)
76-
77-
Load a certificate request (X509Req) from the string *buffer* encoded with
78-
the type *type*.
48+
.. autofunction:: load_certificate_request
7949

8050
Private keys
8151
~~~~~~~~~~~~
8252

8353
.. autofunction:: dump_privatekey
8454

85-
.. py:function:: load_privatekey(type, buffer[, passphrase])
86-
87-
Load a private key (PKey) from the string *buffer* encoded with the type
88-
*type* (must be one of :py:const:`FILETYPE_PEM` and
89-
:py:const:`FILETYPE_ASN1`).
90-
91-
*passphrase* must be either a string or a callback for providing the pass
92-
phrase.
55+
.. autofunction:: load_privatekey
9356

9457
Public keys
9558
~~~~~~~~~~~
@@ -103,53 +66,18 @@ Certificate revocation lists
10366

10467
.. autofunction:: dump_crl
10568

106-
.. py:function:: load_crl(type, buffer)
107-
108-
Load Certificate Revocation List (CRL) data from a string *buffer*.
109-
*buffer* encoded with the type *type*. The type *type* must either
110-
:py:const:`FILETYPE_PEM` or :py:const:`FILETYPE_ASN1`).
111-
112-
113-
.. py:function:: load_pkcs7_data(type, buffer)
114-
115-
Load pkcs7 data from the string *buffer* encoded with the type
116-
*type*. The type *type* must either :py:const:`FILETYPE_PEM` or
117-
:py:const:`FILETYPE_ASN1`).
118-
69+
.. autofunction:: load_crl
11970

120-
.. py:function:: load_pkcs12(buffer[, passphrase])
71+
.. autofunction:: load_pkcs7_data
12172

122-
Load pkcs12 data from the string *buffer*. If the pkcs12 structure is
123-
encrypted, a *passphrase* must be included. The MAC is always
124-
checked and thus required.
125-
126-
See also the man page for the C function :py:func:`PKCS12_parse`.
73+
.. autofunction:: load_pkcs12
12774

12875
Signing and verifying signatures
12976
--------------------------------
13077

131-
.. py:function:: sign(key, data, digest)
132-
133-
Sign a data string using the given key and message digest.
134-
135-
*key* is a :py:class:`PKey` instance. *data* is a ``str`` instance.
136-
*digest* is a ``str`` naming a supported message digest type, for example
137-
:py:const:`b"sha256"`.
138-
139-
.. versionadded:: 0.11
140-
78+
.. autofunction:: sign
14179

142-
.. py:function:: verify(certificate, signature, data, digest)
143-
144-
Verify the signature for a data string.
145-
146-
*certificate* is a :py:class:`X509` instance corresponding to the private
147-
key which generated the signature. *signature* is a *str* instance giving
148-
the signature itself. *data* is a *str* instance giving the data to which
149-
the signature applies. *digest* is a *str* instance naming the message
150-
digest type of the signature, for example :py:const:`b"sha256"`.
151-
152-
.. versionadded:: 0.11
80+
.. autofunction:: verify
15381

15482

15583
.. _openssl-x509:
@@ -243,25 +171,8 @@ PKCS7 objects
243171

244172
PKCS7 objects have the following methods:
245173

246-
.. py:method:: PKCS7.type_is_signed()
247-
248-
FIXME
249-
250-
.. py:method:: PKCS7.type_is_enveloped()
251-
252-
FIXME
253-
254-
.. py:method:: PKCS7.type_is_signedAndEnveloped()
255-
256-
FIXME
257-
258-
.. py:method:: PKCS7.type_is_data()
259-
260-
FIXME
261-
262-
.. py:method:: PKCS7.get_type_name()
263-
264-
Get the type name of the PKCS7.
174+
.. autoclass:: PKCS7
175+
:members:
265176

266177
.. _openssl-pkcs12:
267178

src/OpenSSL/crypto.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,8 @@ def verify_certificate(self):
17991799

18001800
def load_certificate(type, buffer):
18011801
"""
1802-
Load a certificate from a buffer
1802+
Load a certificate (X509) from the string *buffer* encoded with the
1803+
type *type*.
18031804
18041805
:param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1)
18051806
@@ -1828,7 +1829,8 @@ def load_certificate(type, buffer):
18281829

18291830
def dump_certificate(type, cert):
18301831
"""
1831-
Dump a certificate to a buffer
1832+
Dump the certificate *cert* into a buffer string encoded with the type
1833+
*type*.
18321834
18331835
:param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1, or
18341836
FILETYPE_TEXT)
@@ -2766,7 +2768,8 @@ def load_publickey(type, buffer):
27662768

27672769
def load_privatekey(type, buffer, passphrase=None):
27682770
"""
2769-
Load a private key from a buffer
2771+
Load a private key (PKey) from the string *buffer* encoded with the type
2772+
*type*.
27702773
27712774
:param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1)
27722775
:param buffer: The buffer the key is stored in
@@ -2801,7 +2804,8 @@ def load_privatekey(type, buffer, passphrase=None):
28012804

28022805
def dump_certificate_request(type, req):
28032806
"""
2804-
Dump a certificate request to a buffer
2807+
Dump the certificate request *req* into a buffer string encoded with the
2808+
type *type*.
28052809
28062810
:param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1)
28072811
:param req: The certificate request to dump
@@ -2828,7 +2832,8 @@ def dump_certificate_request(type, req):
28282832

28292833
def load_certificate_request(type, buffer):
28302834
"""
2831-
Load a certificate request from a buffer
2835+
Load a certificate request (X509Req) from the string *buffer* encoded with
2836+
the type *type*.
28322837
28332838
:param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1)
28342839
:param buffer: The buffer the certificate request is stored in
@@ -2855,12 +2860,14 @@ def load_certificate_request(type, buffer):
28552860

28562861
def sign(pkey, data, digest):
28572862
"""
2858-
Sign data with a digest
2863+
Sign a data string using the given key and message digest.
28592864
2860-
:param pkey: Pkey to sign with
2865+
:param pkey: PKey to sign with
28612866
:param data: data to be signed
28622867
:param digest: message digest to use
28632868
:return: signature
2869+
2870+
.. versionadded:: 0.11
28642871
"""
28652872
data = _text_to_bytes_and_warn("data", data)
28662873

@@ -2887,13 +2894,16 @@ def sign(pkey, data, digest):
28872894

28882895
def verify(cert, signature, data, digest):
28892896
"""
2890-
Verify a signature.
2897+
Verify the signature for a data string.
28912898
2892-
:param cert: signing certificate (X509 object)
2899+
:param cert: signing certificate (X509 object) corresponding to the
2900+
private key which generated the signature.
28932901
:param signature: signature returned by sign function
28942902
:param data: data to be verified
28952903
:param digest: message digest to use
28962904
:return: ``None`` if the signature is correct, raise exception otherwise.
2905+
2906+
.. versionadded:: 0.11
28972907
"""
28982908
data = _text_to_bytes_and_warn("data", data)
28992909

@@ -2948,7 +2958,8 @@ def dump_crl(type, crl):
29482958

29492959
def load_crl(type, buffer):
29502960
"""
2951-
Load a certificate revocation list from a buffer
2961+
Load Certificate Revocation List (CRL) data from a string *buffer*.
2962+
*buffer* encoded with the type *type*.
29522963
29532964
:param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1)
29542965
:param buffer: The buffer the CRL is stored in
@@ -2977,7 +2988,8 @@ def load_crl(type, buffer):
29772988

29782989
def load_pkcs7_data(type, buffer):
29792990
"""
2980-
Load pkcs7 data from a buffer
2991+
Load pkcs7 data from the string *buffer* encoded with the type
2992+
*type*.
29812993
29822994
:param type: The file type (one of FILETYPE_PEM or FILETYPE_ASN1)
29832995
:param buffer: The buffer with the pkcs7 data.
@@ -3005,7 +3017,11 @@ def load_pkcs7_data(type, buffer):
30053017

30063018
def load_pkcs12(buffer, passphrase=None):
30073019
"""
3008-
Load a PKCS12 object from a buffer
3020+
Load pkcs12 data from the string *buffer*. If the pkcs12 structure is
3021+
encrypted, a *passphrase* must be included. The MAC is always
3022+
checked and thus required.
3023+
3024+
See also the man page for the C function :py:func:`PKCS12_parse`.
30093025
30103026
:param buffer: The buffer the certificate is stored in
30113027
:param passphrase: (Optional) The password to decrypt the PKCS12 lump

0 commit comments

Comments
 (0)