procedure makeKey(inKey: array of Byte; var outKey: array of TKeyByte);
const
bitDisplace: array[0..15] of Byte =
( 1,1,2,2, 2,2,2,2, 1,2,2,2, 2,2,2,1 );
var
outData56: array[0..7] of Byte;
i,i2,j1,ii,k,temp,temp1: Integer;
ebp_5,ebp_9,ebp_10,ebp_8,ebp_7,ebp_6,ebp_14,ebp_15,ebp_1C,ebp_1D,ebp_28,ebp_C,ebp_B,ebp_A,ebp_24:Byte;
begin
ebp_14:=0;
ebp_C:=0;
ebp_B:=0;
ebp_A:=0;
ebp_9:=0;
ebp_8:=0;
ebp_7:=0;
ebp_6:=0;
ebp_5:=0;
ebp_10:=0;
ebp_1C:=0;
ebp_14:=1;
ebp_15:=0;
ebp_1D:=0;
permutationChoose1(inKey, outData56);
for i := 0 to 15 do
begin
i2:=i;
if bitDisplace[i]=1 then
begin
ebp_15:=outData56[0] and $80;
outData56[0]:= outData56[0] and $7F;
end
else
begin
ebp_15:=outData56[0] and $C0;
outData56[0]:= outData56[0] and $3F;
end;
ebp_24:=7;
//整体左移 bitDisplace[i]的过程
for j1:=7 downto 0 do
begin
ebp_24:=j1;
if bitDisplace[i]=1 then
begin
ebp_1D:=outData56[j1] and $80;
outData56[j1]:= outData56[j1] and $7F;
end
else
begin
ebp_1D:=outData56[j1] and $C0;
outData56[j1]:= outData56[j1] and $3F;
end;
outData56[j1]:=outData56[j1] shl bitDisplace[i]; //左移
if bitDisplace[i]=1 then
begin
outData56[j1]:=outData56[j1] and $FD;
end
else
begin
outData56[j1]:=outData56[j1] and $FC;
end;
outData56[j1]:=outData56[j1] or (ebp_15 shr (7-bitDisplace[i]));
ebp_15:=ebp_1D;
end;
if bitDisplace[i]=1 then
begin
ebp_15:=outData56[3] and 3;
ebp_1D:=outData56[7] and 3;
outData56[3]:=outData56[3] and $FC;
outData56[7]:=outData56[7] and $FC;
outData56[3]:=outData56[3] or ebp_1D;
outData56[7]:=outData56[7] or ebp_15;
end
else
begin
ebp_15:=outData56[3] and 7;
ebp_1D:=outData56[7] and 7;
outData56[3]:=outData56[3] and $F8;
outData56[7]:=outData56[7] and $F8;
outData56[3]:=outData56[3] or ebp_1D;
outData56[7]:=outData56[7] or ebp_15;
end;
ebp_28:=ebp_14-ebp_1C-1;
ebp_24:=ebp_28;
for ii:=0 to 47 do
begin
k:=BitPMC2[ii] div 7;
ebp_15:=outData56[k];
temp:=BitPMC2[ii] div 6;
temp:=temp*6;
temp:=BitPMC2[ii]+1-temp;
temp:=8-temp;
ebp_15:=(ebp_15 shr temp) and 1;
temp1:=ii div 6;
temp1:=temp1*6;
temp1:=ii+1-temp1;
temp1:=8-temp1;
ebp_15:=ebp_15 shl temp1;
outkey[i][ii div 6]:=outkey[i][ii div 6] or ebp_15;
ebp_24:=ebp_24+1;
end;
end;
end;