Loading pv080_crypto/asymmetric.py +12 −12 Original line number Diff line number Diff line Loading @@ -29,11 +29,11 @@ from pv080_crypto.config import SERVER_KEY_PATH def publish_key(uco: int, key: rsa.RSAPublicKey) -> str: """ Publishes the ``key`` under the ``uco`` to https//pv080.fi.muni.cz/msg server, Publishes the ``key`` under the ``uco`` to https://pv080.fi.muni.cz/msg server, where it is readable by anyone on the internet. :param uco: Is the UČO of the owner of the key. :param key: Is the RSA public key of the owner. :param uco: The UČO of the owner of the key. :param key: The RSA public key of the owner. :returns: The status message of the result of this API call to the server. Loading Loading @@ -64,7 +64,7 @@ def fetch_key(uco: int) -> Optional[rsa.RSAPublicKey]: """ Fetches the public key associated with the ``uco`` from https://pv080.fi.muni.cz/msg. :param uco: Is the UČO of the party we want to communicate with. :param uco: The UČO of the party we want to communicate with. :returns: The ``rsa.RSAPublicKey`` corresponding to ``uco`` if found, otherwise ``None``. Loading Loading @@ -97,8 +97,8 @@ def rsa_encrypt(key: rsa.RSAPublicKey, plaintext: bytes) -> bytes: """ Uses RSA ``key`` to encrypt the ``plaintext``. :param key: Is the RSA public key to use for the encryption. :param plaintext: Is the plaintext bytes to be encrypted. :param key: The RSA public key to use for the encryption. :param plaintext: The plaintext bytes to be encrypted. :returns: The ciphertext bytes. Loading @@ -125,8 +125,8 @@ def rsa_decrypt(key: rsa.RSAPrivateKey, ciphertext: bytes) -> bytes: """ Use RSA public ``key`` to decrypt the ``ciphertext``. :param key: Is the RSA private key to use for the decryption. :param ciphertext: Is the ciphertext bytes to be decrypted. :param key: The RSA private key to use for the decryption. :param ciphertext: The ciphertext bytes to be decrypted. :returns: The plaintext bytes. Loading Loading @@ -154,8 +154,8 @@ def create_signature(private_key: rsa.RSAPrivateKey, data: bytes) -> bytes: """ Use the RSA ``private_key`` to digitally sign the ``data``. :param private_key: Is an RSA private key. :param data: Is the data to be signed. :param private_key: The RSA private key to be used for signing. :param data: The data to be signed. :returns: The bytes of the signature. Loading Loading @@ -185,8 +185,8 @@ def verify_signature( Verify that the ``signature`` of ``data`` was signed using the RSAPrivateKey corresponding to ``public_key``. :param public_key: Is the ``RSAPublicKey`` to be used for the verification. :param data: Is the data that were signed. :param public_key: The ``RSAPublicKey`` to be used for the verification. :param data: The data that were signed. :param signature: The bytes of the signature. :returns: ``True`` if the ``signature`` is a valid, ``False`` otherwise. Loading Loading
pv080_crypto/asymmetric.py +12 −12 Original line number Diff line number Diff line Loading @@ -29,11 +29,11 @@ from pv080_crypto.config import SERVER_KEY_PATH def publish_key(uco: int, key: rsa.RSAPublicKey) -> str: """ Publishes the ``key`` under the ``uco`` to https//pv080.fi.muni.cz/msg server, Publishes the ``key`` under the ``uco`` to https://pv080.fi.muni.cz/msg server, where it is readable by anyone on the internet. :param uco: Is the UČO of the owner of the key. :param key: Is the RSA public key of the owner. :param uco: The UČO of the owner of the key. :param key: The RSA public key of the owner. :returns: The status message of the result of this API call to the server. Loading Loading @@ -64,7 +64,7 @@ def fetch_key(uco: int) -> Optional[rsa.RSAPublicKey]: """ Fetches the public key associated with the ``uco`` from https://pv080.fi.muni.cz/msg. :param uco: Is the UČO of the party we want to communicate with. :param uco: The UČO of the party we want to communicate with. :returns: The ``rsa.RSAPublicKey`` corresponding to ``uco`` if found, otherwise ``None``. Loading Loading @@ -97,8 +97,8 @@ def rsa_encrypt(key: rsa.RSAPublicKey, plaintext: bytes) -> bytes: """ Uses RSA ``key`` to encrypt the ``plaintext``. :param key: Is the RSA public key to use for the encryption. :param plaintext: Is the plaintext bytes to be encrypted. :param key: The RSA public key to use for the encryption. :param plaintext: The plaintext bytes to be encrypted. :returns: The ciphertext bytes. Loading @@ -125,8 +125,8 @@ def rsa_decrypt(key: rsa.RSAPrivateKey, ciphertext: bytes) -> bytes: """ Use RSA public ``key`` to decrypt the ``ciphertext``. :param key: Is the RSA private key to use for the decryption. :param ciphertext: Is the ciphertext bytes to be decrypted. :param key: The RSA private key to use for the decryption. :param ciphertext: The ciphertext bytes to be decrypted. :returns: The plaintext bytes. Loading Loading @@ -154,8 +154,8 @@ def create_signature(private_key: rsa.RSAPrivateKey, data: bytes) -> bytes: """ Use the RSA ``private_key`` to digitally sign the ``data``. :param private_key: Is an RSA private key. :param data: Is the data to be signed. :param private_key: The RSA private key to be used for signing. :param data: The data to be signed. :returns: The bytes of the signature. Loading Loading @@ -185,8 +185,8 @@ def verify_signature( Verify that the ``signature`` of ``data`` was signed using the RSAPrivateKey corresponding to ``public_key``. :param public_key: Is the ``RSAPublicKey`` to be used for the verification. :param data: Is the data that were signed. :param public_key: The ``RSAPublicKey`` to be used for the verification. :param data: The data that were signed. :param signature: The bytes of the signature. :returns: ``True`` if the ``signature`` is a valid, ``False`` otherwise. Loading