Example #1
0
def test_encryption_key_type_check():
    with pytest.raises(TypeError):
        encrypt_then_authenticate("", unicode(test_enc_key), test_sig_key,
                                  hashlib.sha256)
    with pytest.raises(TypeError):
        encrypt_then_authenticate("", test_enc_key, unicode(test_sig_key),
                                  hashlib.sha256)
Example #2
0
def authenced(request):
    """Encrypt and authenticate a testvalue and return a three-tuple
    (testval, ciphertext, tag)."""
    if not encryption_available():
        pytest.skip("pycrypto not available")
    testval = request.param
    ciphertext, tag = encrypt_then_authenticate(testval, test_enc_key,
                                                test_sig_key, hashlib.sha256)
    return testval, ciphertext, tag
Example #3
0
 def value_encode(self, val):
     orig_val = val
     val = self.serializer.dumps(val)
     ciphertext, sig = encrypt_then_authenticate(val, self.enc_key,
                                                 self.sig_key, self.hashalg)
     return orig_val, base64.b64encode(b"{0}{1}".format(sig, ciphertext))