28 memcpy(outputKey,inputKey,32);
34 for (j=0,mask=1;j<8;j++,mask<<=1)
36 k=((
u4)outputKey[4*j])|(outputKey[4*j+1]<<8)|
37 (outputKey[4*j+2]<<16)|(outputKey[4*j+3]<<24);
47 S[0]=(
unsigned char)(s1&0xff);
48 S[1]=(
unsigned char)((s1>>8)&0xff);
49 S[2]=(
unsigned char)((s1>>16)&0xff);
50 S[3]=(
unsigned char)((s1>>24)&0xff);
51 S[4]=(
unsigned char)(s2&0xff);
52 S[5]=(
unsigned char)((s2>>8)&0xff);
53 S[6]=(
unsigned char)((s2>>16)&0xff);
54 S[7]=(
unsigned char)((s2>>24)&0xff);
71 const unsigned char *sessionKey,
unsigned char *wrappedKey)
73 unsigned char kek_ukm[32];
76 memcpy(wrappedKey,ukm,8);
77 gost_enc(ctx,sessionKey,wrappedKey+8,4);
78 gost_mac_iv(ctx,32,ukm,sessionKey,32,wrappedKey+40);
93 const unsigned char *wrappedKey,
unsigned char *sessionKey)
95 unsigned char kek_ukm[32],cek_mac[4];
100 gost_dec(ctx,wrappedKey+8,sessionKey,4);
101 gost_mac_iv(ctx,32,wrappedKey,sessionKey,32,cek_mac);
102 if (memcmp(cek_mac,wrappedKey+40,4))