Commits

George Notaras committed bfedc32

Improved crypto module class and method documentation

  • Participants
  • Parent commits aaf9109
  • Branches maintenance

Comments (0)

Files changed (1)

src/TinyIDS/crypto.py

         self.private_key = None
     
     def encrypt(self, data_raw):
+        """Encrypts the provided data using self.public_key.
+        
+        Use one of load_public_key() or load_external_public_key() methods
+        in order to load a public key to the PKI module.
+        
+        If a public key has not been loaded, raises PublicKeyNotLoaded.
+        
+        On any error regarding data encryption, raises DataEncryptionError.
+        
+        """
         if self.public_key is None:
             raise PublicKeyNotLoaded
         try:
             return data_enc_b64
     
     def decrypt(self, data_enc_b64):
+        """Decrypts the provided data using self.private_key.
+        
+        Use one of load_private_key() or load_external_private_key() methods
+        in order to load a private key to the PKI module.
+        
+        If a private key has not been loaded, raises PrivateKeyNotLoaded.
+        
+        On any error regarding data decryption, raises DataDecryptionError.
+        
+        """
         if self.private_key is None:
             raise PrivateKeyNotLoaded
         try:
             return data_raw
     
     def verify(self, data_signed_b64):
+        """Verifies the provided data using self.public_key.
+        
+        Use one of load_public_key() or load_external_public_key() methods
+        in order to load a public key to the PKI module.
+        
+        If a public key has not been loaded, raises PublicKeyNotLoaded.
+        
+        On any error regarding data verification, raises DataVerificationError.
+        
+        """
         if self.public_key is None:
             raise PublicKeyNotLoaded
         try:
             return data_raw
     
     def sign(self, data_raw):
+        """Signs the provided data using self.private_key.
+        
+        Use one of load_private_key() or load_external_private_key() methods
+        in order to load a private key to the PKI module.
+        
+        If a private key has not been loaded, raises PrivateKeyNotLoaded.
+        
+        On any error regarding data signing, raises DataSigningError.
+        
+        """
         if self.private_key is None:
             raise PrivateKeyNotLoaded
         try: