开发者

RC2 key schedule

开发者 https://www.devze.com 2023-01-02 04:19 出处:网络
Can someone explain how the RC2 key schedule works (particularly the very beginning of it)? i know it uses little endian, but my implementation is not working for any key except \"0000 0000 0000 0000\

Can someone explain how the RC2 key schedule works (particularly the very beginning of it)? i know it uses little endian, but my implementation is not working for any key except "0000 0000 0000 0000"

Test Vector
Key = 88bc a90e 9087 5a
Plaintext = 0000 0000 0000 0000
Ciphertext = 6ccf 4308 974c 267f

im assuming that the first thing to do with the ke开发者_StackOverflowy would be to change it into

bc88 0ea9 8790 5a

and yes i know RC2 is not even used anymore, but i would still like to know


The RFC says:

The key expansion algorithm begins by placing the supplied T-byte key into bytes L[0], ..., L[T-1] of the key buffer.

So if your key is 88bc a90e 9087 5a you get L[0]=0x88, L[1]=0xbc, ... L[6]=0x5a.

No need to consider any endianess here.

If you want to treat the key-buffer as 16-bit words you get:

K[i] = L[2*i] + 256*L[2*i+1]

I.e. K[0] = 0xbc88, K[1] = 0xa90e, K[2] = 0x8790. L[7] is only assigned later in the key-expansion step, so strictly speaking K[3] is undefined at this point. Feel free to choose any value you want however, since it makes no difference to the algorithm. If you select 0, you get K[3] = 0x005a.

0

精彩评论

暂无评论...
验证码 换一张
取 消