# I'm trying to understand which cryptographic algorithm is this

I'm reversing a cryptographic algorithm. This is part of the encryption function translated to python (starting from assembly code):

cleartext = [ 0x24,0x11,0x33,0x63,0xbc,0x59,0x07,0x5b,0x96,0x4b,0x07,0x15,0x2d,0x23,0x4b,0x70 ]
clearlen = 16

# Init the dictionary
cdict = [ 0 ] * 256
for i in range(256):
cdict[i] = i

v1 = 0
for i in range(256):
v1 += (cleartext[ i % clearlen ] + cdict[i])
v1 = v1 & 0xFF
v2 = cdict[v1] ^ cdict[i]
cdict[i] = v2
v3 = cdict[v1] ^ v2
cdict[v1] = v3
cdict[i] ^= v3


Then this array of 256 bytes is used to extract clearlen bytes which are XORed with a key. I didn't translate it to python yet.

I was trying to understand if this was a known cryptographic algorithm, or it is completely custom. So far I was not able to identify it. Do you?

The part you quoted is the Key Setup Algorithm, which is run before you actually encrypt/decrypt anything. The part which is written in an unusual (but correct) way is the last 5 lines, which does a swap of cdict[i] and cdict[v1] - more typically, it is written with just 2 reads and 2 writes and two temp variables in the obvious fashion; for some reason they decided to use some 'clever' logic with xors (and two temp variables, 4 reads, 3 writes).