Did I find the right examples for you? yes no      Crawl my project      Python Jobs

# mixminion.Crypto.lioness_encrypt

All Samples(8)  |  Call(8)  |  Derive(0)  |  Import(0)
```Given four 20-byte keys, encrypts s using the LIONESS
super-pseudorandom permutation.
```

```        def lioness_encrypt(s,(key1,key2,key3,key4)):
"""Given four 20-byte keys, encrypts s using the LIONESS
super-pseudorandom permutation.
"""

assert len(key1) == len(key3) == DIGEST_LEN
assert len(key2) == len(key4) == DIGEST_LEN
assert len(s) > DIGEST_LEN

# Split the message.
left = s[:DIGEST_LEN]
right = s[DIGEST_LEN:]
del s
# Performance note: This business with sha1("".join((key,right,key)))
# may look slow, but it contributes only .7% to the total time for
# LIONESS.
right = _ml.aes_ctr128_crypt(
_ml.aes_key(_ml.sha1("".join((key1,left,key1)))[:AES_KEY_LEN]),
right, 0)
left = _ml.strxor(left,  _ml.sha1("".join((key2,right,key2))))
right = _ml.aes_ctr128_crypt(
_ml.aes_key(_ml.sha1("".join((key3,left,key3)))[:AES_KEY_LEN]),
right, 0)
left = _ml.strxor(left,  _ml.sha1("".join((key4,right,key4))))

# You could write the above as:
#   right = ctr_crypt(right, "".join((key1,left,key1))[:AES_KEY_LEN])
#   left = strxor(left, sha1("".join((key2,right,key2))))
#   right = ctr_crypt(right, "".join((key3,left,key3))[:AES_KEY_LEN])
#   left = strxor(left, sha1("".join((key4,right,key4))))
# but that would be slower by about 10%.  (Since LIONESS is in the
# critical path, we care.)

return left + right
```

src/m/i/mixminion-HEAD/lib/mixminion/BuildMessage.py   mixminion(Download)
```    # Lioness encryption.
k= Crypto.Keyset(sessionKey).getLionessKeys(Crypto.END_TO_END_ENCRYPT_MODE)
lionessPart = Crypto.lioness_encrypt(lionessPart, k)

# Now we re-divide the payload into the part that goes into the tag, and
```
```    for sec in secrets:
k = Crypto.Keyset(sec).getLionessKeys(Crypto.PAYLOAD_ENCRYPT_MODE)
payload = Crypto.lioness_encrypt(payload, k)
if check and _checkPayload(payload):
return parsePayload(payload)
```
```            ks = Crypto.Keyset(secret)
key = ks.getLionessKeys(Crypto.PAYLOAD_ENCRYPT_MODE)
payload = Crypto.lioness_encrypt(payload, key)

# Encrypt header2 with a hash of the payload.
key = Crypto.lioness_keys_from_payload(payload)
header2 = Crypto.lioness_encrypt(header2, key)
```
```    # both unrecoverable.
key = Crypto.lioness_keys_from_header(header2)
payload = Crypto.lioness_encrypt(payload, key)

# Copy secrets1 so we don't reverse the original.
```

src/m/i/mixminion-HEAD/lib/mixminion/testSupport.py   mixminion(Download)
```    print "      Example text M:",hexStr(txt)
print "   SPRP_Encrypt(K,M):",hexStr(mixminion.Crypto.lioness_encrypt(
txt,(k1,k2,k3,k4)))
print "   SPRP_Decrypt(K,M):",hexStr(mixminion.Crypto.lioness_decrypt(
txt,(k1,k2,k3,k4)))
```