[FFmpeg-devel] Help: AES GF Multiply

Michael Niedermayer michaelni at gmx.at
Mon Jul 30 16:56:05 CEST 2012


On Mon, Jul 30, 2012 at 11:49:51PM +1000, Peter Ross wrote:
> Gents,
> 
> In my spare time I am toying with an obscure remote desktop protocol called
> PCoIP. The format encrypts its packets with Salsa20, AES-128 or 256 crypto,
> which are simple enough to decode. Alas, I am stuck implementing the checksum
> algorithm used with the AES-128/256 packets.
> 
> The checksum value is 16-byte wide, and is calculated by xor'ing each 16-byte
> block of ciphertext *and* then performing an 'AES GF multiplication' over checksum
> value. The AES instanced used to perform the multiplication is loaded with the
> same keymaterial used to decode the actual payload.
> 
> Within PCoIP the GF multiplication function is called 'gf_multi_h'. There are
> mmx and x86 variants of this within the reference .so/dll blob file.
> 
> libavutil/aes.c is performing GF multiplication, but its not obvious to
> me how to access this functionality. The math is especially foreign. Any
> pointers on how aes.c can be modified to provide such a function?

GF multiplication really behaves the same as normal multiplication in
a field. the common "laws" hold
a*1=1*a = a
a*b=b*a
a*(a^-1) = 1 | a != 0
this goes as far as log(a)+log(b) = log(a*b) | a,b!=0
the last is often used to do multiplies, that is
a*b = 0                  if a or b is 0
a*b = exp(log(a)+log(b)) else

log could be defined by a = exp(log(a)) | for all a != 0
and exp by exp(a) = e*exp(a-1) and exp(0) = 1
e is a element of the GF, choosen so above log/exp rules work
note though that in x = log(y) and exp(x) = y, that x is a integer
while y a GF element, its both int in C normally but the distinction
can be confusing if its not considered especially for the meaning of
addition and multiplication as these operations are quite different
for the 2 types.

about aes.c, if you export the log8[] alog8[] (thats exp) tables
it should be trivial to do a multiplication with them

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120730/38e00d51/attachment.asc>


More information about the ffmpeg-devel mailing list