Ejemplo n.º 1
0
    def generate(cls, obj, fingerprint):
        """Generate a challenge and return the hash of the challenge and 
        the challenge encrypted with GPG.
        """
        secret = os.urandom(16).encode("hex")
        hash = hashlib.sha256(secret).hexdigest()
        ciphertext = gpg.encrypt(secret, fingerprint)

        chal = Challenge(hash)
        db_session.add(chal)
        db_session.commit()
        obj.chal_id = chal.id
        db_session.commit()
        return ciphertext
Ejemplo n.º 2
0
 def test_encrypt(self):
     """Test the encrypt function"""
     ciphertext = gpg.encrypt('test', self.fp)
     self.assertIn('-----BEGIN PGP MESSAGE-----', str(ciphertext))