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
```

```    # 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:
```
```            ks = Crypto.Keyset(secret)

```
```    # both unrecoverable.
```    print "      Example text M:",hexStr(txt)