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

# mixminion.Crypto.lioness_decrypt

All Samples(7)  |  Call(7)  |  Derive(0)  |  Import(0)
```Given a 16-byte key2 and key4, and a 20-byte key1 and key3, decrypts
s using the LIONESS super-pseudorandom permutation.
```

```        def lioness_decrypt(s,(key1,key2,key3,key4)):
"""Given a 16-byte key2 and key4, and a 20-byte key1 and key3, decrypts
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

left = s[:DIGEST_LEN]
right = s[DIGEST_LEN:]
del s

# Slow, comprehensible version:
#left = strxor(left,  sha1("".join([key4,right,key4])))
#right = ctr_crypt(right, sha1("".join([key3,left,key3]))[:AES_KEY_LEN])
#left = strxor(left,  sha1("".join([key2,right,key2])))
#right = ctr_crypt(right, sha1("".join([key1,left,key1]))[:AES_KEY_LEN])

# Equivalent-but-faster version:
left = _ml.strxor(left, _ml.sha1("".join((key4,right,key4))))
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((key2,right,key2))))
right = _ml.aes_ctr128_crypt(
_ml.aes_key(_ml.sha1("".join((key1,left, key1)))[:AES_KEY_LEN]),
right, 0)

return left + right
```

```

```
```

```
```        if Packet.typeIsSwap(rt):

```

```    k = Crypto.Keyset(replyBlock.encryptionKey).getLionessKeys(

```
```    k = Crypto.Keyset(rsaPart[:SECRET_LEN]).getLionessKeys(
Crypto.END_TO_END_ENCRYPT_MODE)
rest = rsaPart[SECRET_LEN:] + Crypto.lioness_decrypt(rest, k)

# ... and then, check the checksum and continue.
```

```        txt,(k1,k2,k3,k4)))