diff options
-rw-r--r-- | rsa/key.py | 29 | ||||
-rw-r--r-- | rsa/pem.py | 12 | ||||
-rw-r--r-- | rsa/varblock.py | 10 |
3 files changed, 26 insertions, 25 deletions
@@ -135,9 +135,9 @@ class PublicKey(AbstractKey): def _load_pkcs1_der(cls, keyfile): """Loads a key in PKCS#1 DER format. - @param keyfile: contents of a DER-encoded file that contains the public + :param keyfile: contents of a DER-encoded file that contains the public key. - @return: a PublicKey object + :return: a PublicKey object First let's construct a DER encoded key: @@ -181,9 +181,9 @@ class PublicKey(AbstractKey): The contents of the file before the "-----BEGIN RSA PUBLIC KEY-----" and after the "-----END RSA PUBLIC KEY-----" lines is ignored. - @param keyfile: contents of a PEM-encoded file that contains the public + :param keyfile: contents of a PEM-encoded file that contains the public key. - @return: a PublicKey object + :return: a PublicKey object """ der = rsa.pem.load_pem(keyfile, 'RSA PUBLIC KEY') @@ -192,7 +192,7 @@ class PublicKey(AbstractKey): def _save_pkcs1_pem(self): """Saves a PKCS#1 PEM-encoded public key file. - @return: contents of a PEM-encoded file that contains the public key. + :return: contents of a PEM-encoded file that contains the public key. """ der = self._save_pkcs1_der() @@ -208,9 +208,9 @@ class PublicKey(AbstractKey): The contents of the file before the "-----BEGIN PUBLIC KEY-----" and after the "-----END PUBLIC KEY-----" lines is ignored. - @param keyfile: contents of a PEM-encoded file that contains the public + :param keyfile: contents of a PEM-encoded file that contains the public key, from OpenSSL. - @return: a PublicKey object + :return: a PublicKey object """ der = rsa.pem.load_pem(keyfile, 'PUBLIC KEY') @@ -220,9 +220,10 @@ class PublicKey(AbstractKey): def load_pkcs1_openssl_der(cls, keyfile): """Loads a PKCS#1 DER-encoded public key file from OpenSSL. - @param keyfile: contents of a DER-encoded file that contains the public + :param keyfile: contents of a DER-encoded file that contains the public key, from OpenSSL. - @return: a PublicKey object + :return: a PublicKey object + """ from rsa.asn1 import OpenSSLPubKey @@ -361,9 +362,9 @@ class PrivateKey(AbstractKey): def _load_pkcs1_der(cls, keyfile): """Loads a key in PKCS#1 DER format. - @param keyfile: contents of a DER-encoded file that contains the private + :param keyfile: contents of a DER-encoded file that contains the private key. - @return: a PrivateKey object + :return: a PrivateKey object First let's construct a DER encoded key: @@ -445,9 +446,9 @@ class PrivateKey(AbstractKey): The contents of the file before the "-----BEGIN RSA PRIVATE KEY-----" and after the "-----END RSA PRIVATE KEY-----" lines is ignored. - @param keyfile: contents of a PEM-encoded file that contains the private + :param keyfile: contents of a PEM-encoded file that contains the private key. - @return: a PrivateKey object + :return: a PrivateKey object """ der = rsa.pem.load_pem(keyfile, b('RSA PRIVATE KEY')) @@ -456,7 +457,7 @@ class PrivateKey(AbstractKey): def _save_pkcs1_pem(self): """Saves a PKCS#1 PEM-encoded private key file. - @return: contents of a PEM-encoded file that contains the private key. + :return: contents of a PEM-encoded file that contains the private key. """ der = self._save_pkcs1_der() @@ -35,12 +35,12 @@ def _markers(pem_marker): def load_pem(contents, pem_marker): """Loads a PEM file. - @param contents: the contents of the file to interpret - @param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY' + :param contents: the contents of the file to interpret + :param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY' when your file has '-----BEGIN RSA PRIVATE KEY-----' and '-----END RSA PRIVATE KEY-----' markers. - @return the base64-decoded content between the start and end markers. + :return: the base64-decoded content between the start and end markers. @raise ValueError: when the content is invalid, for example when the start marker cannot be found. @@ -97,12 +97,12 @@ def load_pem(contents, pem_marker): def save_pem(contents, pem_marker): """Saves a PEM file. - @param contents: the contents to encode in PEM format - @param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY' + :param contents: the contents to encode in PEM format + :param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY' when your file has '-----BEGIN RSA PRIVATE KEY-----' and '-----END RSA PRIVATE KEY-----' markers. - @return the base64-encoded content between the start and end markers. + :return: the base64-encoded content between the start and end markers. """ diff --git a/rsa/varblock.py b/rsa/varblock.py index 97ab762..d7d34ab 100644 --- a/rsa/varblock.py +++ b/rsa/varblock.py @@ -71,9 +71,9 @@ def read_varint(infile): EOF occurs when at least one byte has been read, an EOFError exception is raised. - @param infile: the file-like object to read from. It should have a read() + :param infile: the file-like object to read from. It should have a read() method. - @returns (varint, length), the read varint and the number of read bytes. + :returns: (varint, length), the read varint and the number of read bytes. """ varint = 0 @@ -99,9 +99,9 @@ def read_varint(infile): def write_varint(outfile, value): """Writes a varint to a file. - @param outfile: the file-like object to write to. It should have a write() + :param outfile: the file-like object to write to. It should have a write() method. - @returns the number of written bytes. + :returns: the number of written bytes. """ # there is a big difference between 'write the value 0' (this case) and @@ -128,7 +128,7 @@ def write_varint(outfile, value): def yield_varblocks(infile): """Generator, yields each block in the input file. - @param infile: file to read, is expected to have the VARBLOCK format as + :param infile: file to read, is expected to have the VARBLOCK format as described in the module's docstring. @yields the contents of each block. """ |