<s>
Crypto-PAn	B-Algorithm
(	O
Cryptography-based	O
Prefix-preserving	O
Anonymization	O
)	O
is	O
a	O
cryptographic	O
algorithm	O
for	O
anonymizing	O
IP	B-Protocol
addresses	I-Protocol
while	O
preserving	O
their	O
subnet	B-Protocol
structure	O
.	O
</s>
<s>
In	O
this	O
way	O
,	O
Crypto-PAn	B-Algorithm
is	O
a	O
kind	O
of	O
format-preserving	B-Algorithm
encryption	I-Algorithm
.	O
</s>
<s>
The	O
mathematical	O
outline	O
of	O
Crypto-PAn	B-Algorithm
was	O
developed	O
by	O
Jinliang	O
Fan	O
,	O
Jun	O
Xu	O
,	O
Mostafa	O
H	O
.	O
Ammar	O
(	O
all	O
of	O
Georgia	O
Tech	O
)	O
and	O
Sue	O
B	O
.	O
</s>
<s>
It	O
was	O
inspired	O
by	O
the	O
IP	B-Protocol
address	I-Protocol
anonymization	O
done	O
by	O
Greg	O
Minshall	O
's	O
TCPdpriv	O
program	O
circa	O
1996	O
.	O
</s>
<s>
Intuitively	O
,	O
Crypto-PAn	B-Algorithm
encrypts	O
a	O
bit-string	O
of	O
length	O
by	O
descending	O
a	O
binary	O
tree	O
of	O
depth	O
,	O
one	O
step	O
for	O
each	O
bit	O
in	O
the	O
string	O
.	O
</s>
<s>
The	O
first	O
128	O
bits	O
of	O
the	O
key	O
material	O
are	O
used	O
to	O
initialize	O
an	O
AES-128	B-Algorithm
cipher	O
in	O
ECB	O
mode	O
.	O
</s>
<s>
Given	O
a	O
32-bit	O
IPv4	B-Protocol
address	O
,	O
the	O
reference	O
implementation	O
performs	O
the	O
following	O
operation	O
for	O
each	O
bit	O
of	O
the	O
input	O
:	O
Compose	O
a	O
128-bit	O
input	O
block	O
.	O
</s>
<s>
Finally	O
,	O
XOR	B-Application
the	O
th	O
bit	O
of	O
that	O
output	O
block	O
with	O
the	O
th	O
bit	O
of	O
,	O
and	O
append	O
the	O
result	O
—	O
—	O
onto	O
the	O
output	O
bitstring	O
.	O
</s>
<s>
The	O
reference	O
implementation	O
does	O
not	O
implement	O
encryption	O
of	O
bitstrings	O
of	O
lengths	O
other	O
than	O
32	O
;	O
for	O
example	O
,	O
it	O
does	O
not	O
support	O
the	O
anonymization	O
of	O
128-bit	O
IPv6	B-Protocol
addresses	I-Protocol
.	O
</s>
<s>
In	O
practice	O
,	O
the	O
32-bit	O
Crypto-PAn	B-Algorithm
algorithm	O
can	O
be	O
used	O
in	O
"	O
ECB	O
mode	O
"	O
itself	O
,	O
so	O
that	O
a	O
128-bit	O
string	O
might	O
be	O
anonymized	O
as	O
.	O
</s>
<s>
This	O
approach	O
preserves	O
the	O
prefix	O
structure	O
of	O
the	O
128-bit	O
string	O
,	O
but	O
does	O
leak	O
information	O
about	O
the	O
lower-order	O
chunks	O
;	O
for	O
example	O
,	O
an	O
anonymized	O
IPv6	B-Protocol
address	I-Protocol
consisting	O
of	O
the	O
same	O
32-bit	O
ciphertext	O
repeated	O
four	O
times	O
is	O
likely	O
the	O
special	O
address	O
::	O
,	O
which	O
thus	O
reveals	O
the	O
encryption	O
of	O
the	O
32-bit	O
plaintext	O
0000:0000:0000:0000	O
.	O
</s>
<s>
Crypto-PAn	B-Algorithm
'	O
s	O
C++	B-Language
reference	O
implementation	O
was	O
written	O
in	O
2002	O
by	O
Jinliang	O
Fan	O
.	O
</s>
<s>
In	O
2005	O
,	O
David	O
Stott	O
of	O
Lucent	O
made	O
some	O
improvements	O
to	O
the	O
C++	B-Language
reference	O
implementation	O
,	O
including	O
a	O
deanonymization	O
routine	O
.	O
</s>
<s>
Stott	O
also	O
observed	O
that	O
the	O
algorithm	O
preserves	O
prefix	O
structure	O
while	O
destroying	O
suffix	O
structure	O
;	O
running	O
the	O
Crypto-PAn	B-Algorithm
algorithm	O
on	O
a	O
bit-reversed	O
string	O
will	O
preserve	O
any	O
existing	O
suffix	O
structure	O
while	O
destroying	O
prefix	O
structure	O
.	O
</s>
<s>
(	O
However	O
,	O
once	O
the	O
suffix	O
structure	O
has	O
been	O
destroyed	O
,	O
destroying	O
the	O
remaining	O
prefix	O
structure	O
can	O
be	O
accomplished	O
far	O
more	O
efficiently	O
by	O
simply	O
feeding	O
the	O
non-reversed	O
output	O
to	O
AES-128	B-Algorithm
in	O
ECB	O
mode	O
.	O
</s>
<s>
There	O
is	O
no	O
particular	O
reason	O
to	O
reuse	O
Crypto-PAn	B-Algorithm
in	O
the	O
second	O
pass	O
.	O
)	O
</s>
<s>
A	O
Perl	B-Language
implementation	O
was	O
written	O
in	O
2005	O
by	O
John	O
Kristoff	O
.	O
</s>
<s>
Python	B-Language
and	O
Ruby	B-Language
implementations	O
also	O
exist	O
.	O
</s>
<s>
Versions	O
of	O
the	O
Crypto-PAn	B-Algorithm
algorithm	O
are	O
used	O
for	O
data	O
anonymization	O
in	O
many	O
applications	O
,	O
including	O
NetSniff	O
and	O
CAIDA	O
's	O
CoralReef	O
library	O
.	O
</s>
