Информационная безопасность и модели защиты информации. 1 Категории информационной безопасности


Download 0.52 Mb.
bet15/15
Sana15.06.2023
Hajmi0.52 Mb.
#1485324
1   ...   7   8   9   10   11   12   13   14   15

Приложение 1


Код криптоалгоритма на языке программирования PASCAL.


type TLong2=array[0.. 1] of longint;x2=array[0.. 1] of TLong2;Delta=$9E3779B9;key:TLong2x2;EnCryptRouting(var data);y,z,sum:longint; a:byte;:=TLong2(data)[0];z:=TLong2(data)[1];sum:=0;a:=0 to 31 do(sum,Delta);(y,((z shl 4)+key[0,0]) xor (z+sum) xor ((z shr 5)+key[0,1]));(z,((y shl 4)+key[1,0]) xor (y+sum) xor ((y shr 5)+key[1,1]));;(data)[0]:=y;TLong2(data)[1]:=z


end;


Приложение 2


Схема работы криптоалгоритма



Рис.1. Схема работы криптоалгоритма


Приложение 3


Ассиметричный алгоритм криптосистемы



Рис.1.Ассиметричный алгоритм криптосистемы


Приложение 4


Общая схема симметричной криптосистемы



Рис.1. Общая схема симметричной криптосистемы


Приложение 5


Текст программы шифратора


DES;Windows, Classes, SysUtils, Math, Dialogs;= Array of Boolean;= ^TBitString;= record:TBitString;:TBitString;;= Array[0..16]Of TSplitKeyParts;= Array[0..15]Of TBitString;= record:TBitString;:TBitString;;= Array[0..16]OF TIPKeyParts;_PC1:Array[0..55] Of Byte = (57,49,41,33,25,17,9,
,58,50,42,34,26,18,
,2,59,51,43,35,27,
,11,3,60,52,44,36,
,55,47,39,31,23,15,
,62,54,46,38,30,22,
,6,61,53,45,37,29,
,13,5,28,20,12,4);_PC2:Array[0..47] Of Byte = (14,17,11,24,1,5,
,28,15,6,21,10,
,19,12,4,26,8,
,7,27,20,13,2,
,52,31,37,47,55,
,40,51,45,33,48,
,49,39,56,34,53,
,42,50,36,29,32);_IP:Array[0..63] Of Byte = (58,50,42,34,26,18,10,2,
,52,44,36,28,20,12,4,
,54,46,38,30,22,14,6,
,56,48,40,32,24,16,8,
,49,41,33,25,17,9,1,
,51,43,35,27,19,11,3,
,53,45,37,29,21,13,5,
,55,47,39,31,23,15,7);_E:Array[0..47] Of Byte = (32,1,2,3,4,5,
,5,6,7,8,9,
,9,10,11,12,13,
,13,14,15,16,17,
,17,18,19,20,21,
,21,22,23,24,25,
,25,26,27,28,29,
,29,30,31,32,1);_BOXES:Array[0..7,0..3,0..15]Of Byte = (
((14,04,13,01,02,15,11,08,03,10,06,12,05,09,00,07),
(00,15,07,04,14,02,13,01,10,06,12,11,09,05,03,08),
(04,01,14,08,13,06,02,11,15,12,09,07,03,10,05,00),
(15,12,08,02,04,09,01,07,05,11,03,14,10,00,06,13)),
((15,01,08,14,06,11,03,04,09,07,02,13,12,00,05,10),
(03,13,04,07,15,02,08,14,12,00,01,10,06,09,11,05),
(00,14,07,11,10,04,13,01,05,08,12,06,09,03,02,15),
(13,08,10,01,03,15,04,02,11,06,07,12,00,05,14,09)),
((10,00,09,14,06,03,15,05,01,13,12,07,11,04,02,08),
(13,07,00,09,03,04,06,10,02,08,05,14,12,11,15,01),
(13,06,04,09,08,15,03,00,11,01,02,12,05,10,14,07),
(01,10,13,00,06,09,08,07,04,15,14,03,11,05,02,12)),
((07,13,14,03,00,06,09,10,01,02,08,05,11,12,04,15),
(13,08,11,05,06,15,00,03,04,07,02,12,01,10,14,09),
(10,06,09,00,12,11,07,13,15,01,03,14,05,02,08,04),
(13,15,00,06,10,01,13,08,09,04,05,11,12,07,02,14)),
((02,12,04,01,07,10,11,06,08,05,03,15,13,00,14,09),
(14,11,02,12,04,07,13,01,05,00,15,10,03,08,09,06),
(04,02,01,11,10,13,07,08,15,09,12,05,06,03,00,14),
(11,08,12,07,01,14,02,13,06,15,00,09,10,04,05,03)),
((12,01,10,15,09,02,06,08,00,13,03,04,14,07,05,11),
(10,15,04,02,07,12,09,05,06,01,13,14,00,11,03,08),
(09,14,15,05,02,08,12,03,07,00,04,10,01,13,11,06),
(04,03,02,12,09,05,15,10,11,14,01,04,06,00,08,13)),
((04,11,02,14,15,00,08,13,03,12,09,07,05,10,06,01),
(13,00,11,07,04,09,01,10,14,03,05,12,02,15,08,06),
(01,04,11,13,12,03,07,14,10,15,06,08,00,05,09,02),
(06,11,13,08,01,04,10,07,09,05,00,15,14,02,03,12)),
((13,02,08,04,06,15,11,01,10,09,03,14,05,00,12,07),
(01,15,13,08,10,03,07,04,12,05,06,11,00,14,09,02),
(07,11,04,01,09,12,14,02,00,06,10,13,15,03,05,08),
(02,01,14,07,04,10,08,13,15,12,09,00,03,05,06,11))
);_P:Array[0..31] Of Byte = (16,7,20,21,
,12,28,17,
,15,23,26,
,18,31,10,
,8,24,14,
,27,3,9,
,13,30,6,
,11,4,25);_REVERSE_IP:Array[0..63] Of Byte = (40,8,48,16,56,24,64,32,
,7,47,15,55,23,63,31,
,6,46,14,54,22,62,30,
,5,45,13,53,21,61,29,
,4,44,12,52,20,60,28,
,3,43,11,51,19,59,27,
,2,42,10,50,18,58,26,
,1,41,9,49,17,57,25);_LSH:Array[0..15] Of Byte = (1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1);BinToInt(S:TBitString):Integer;IntToBin(N:Integer;Precision:Integer=8):TBitString;BinToStr(Bits:TBitString):String;StrToBin(S:String):TBitString;AnsiStrToBin(S:String; Zeroes:Boolean=True):TBitString;BinToAnsiStr(Bits:TBitString):String;CopyBits(Var Dest:TBitString; Source:TBitString; NBits:Integer);ConcatBits(Bits:Array Of TBitString):TBitString;DESEncode(S,Key:String):TBitString;DESDecode(S,Key:String):TBitString;GetPermutedKey(Key:TBitString):TBitString;GetPermutedKey2(Key:TBitString):TBitString;GetSplitKey(Key:TBitString):TSplitKey;GetConcatKey(Key:TSplitKey):TConcatKey;GetIPKey(M:TBitString; ConcatKey:TConcatKey):TIPKey;GetF(R,K:TBitString):TBitString;GetSBox(Index:Integer; T:TBitString):TBitString;GetReverseIP(RL:TBitString):TBitString;ReverseSubKeys(Var Keys:TConcatKey);Unit1, Unit2;ConcatBits(Bits:Array Of TBitString):TBitString;,C:Integer;(Result,0);C:=0 To Length(Bits)-1 Do(Result,Length(Result)+Length(Bits[C]));I:=0 To Length(Bits[C])-1 Do[Length(Result)-Length(Bits[C])+I]:=Bits[C][I];;;CopyBits(Var Dest:TBitString; Source:TBitString; NBits:Integer);:Integer;(Dest,NBits);I:=0 To NBits-1 Do[I]:=Source[I];;BinToInt(S: TBitString): Integer;,I:Integer;:=0;:=Length(S);L=0 ThenEConvertError.Create('Specified bit string is zero length');I:=L-1 DownTo 0 Do:=Result+Ord(S[I])*Trunc(Power(2,L-I-1));;IntToBin(N:Integer; Precision:Integer):TBitString;:TList;:PBoolean;(Result,0);:=TList.Create;N>0 Do(Bit);^:=Boolean(N mod 2);.Insert(0,Bit);:=N div 2;;BitList.Count'1')And(S[I]<>'0') ThenEConvertError.Create(S+' is invalid binary string');(Result,I);[I-1]:=Boolean(StrToInt(S[I]));;;BinToAnsiStr(Bits:TBitString):String;:Integer;:TBitString;:='';(B,8);:=0;I<=Length(Bits)-8 Do(B,Ptr(Integer(Bits)+I),8);:=Result+Char(BinToInt(B));(I,8);;;GetPermutedKey(Key:TBitString):TBitString;:Integer;(Result,Length(DES_PC1));I:=0 To Length(DES_PC1)-1 Do[I]:=Key[DES_PC1[I]-1];;GetPermutedKey2(Key:TBitString):TBitString;:Integer;(Result,Length(DES_PC2));I:=0 To Length(DES_PC2)-1 Do[I]:=Key[DES_PC2[I]-1];;GetSplitKey(Key:TBitString):TSplitKey;LeftShift(Key:TBitString; N:Integer):TBitString;,J:Integer;:TBitString;(Result,28);(Temp,28);I:=0 To 27 Do[I]:=Key[I];J:=1 To N DoI:=1 To 27 Do[I-1]:=Temp[I];[27]:=Temp[0];I:=0 To 27 Do[I]:=Result[I];;;,J:Integer;J:=1 To 16 Do(Result[J].C,28);(Result[J].D,28);;(Result[0].C,Key,28);(Result[0].D,TBitString(Integer(Key)+28),28);I:=1 To 16 Do[I].C:=LeftShift(Result[I-1].C,DES_LSH[I-1]);[I].D:=LeftShift(Result[I-1].D,DES_LSH[I-1]);;;GetConcatKey(Key:TSplitKey):TConcatKey;:Integer;:TBitString;I:=0 To 15 Do(Result[I],56);:=ConcatBits([Key[I+1].C,Key[I+1].D]);[I]:=GetPermutedKey2(Temp);;;GetIPKey(M:TBitString; ConcatKey:TConcatKey):TIPKey;,J:Integer;, F:TBitString;I:=0 To 16 Do(Result[I].L,32);(Result[I].R,32);;(IP,64);I:=0 To Length(DES_IP)-1 Do[I]:=M[DES_IP[I]-1];I:=0 To 31 Do[0].L[I]:=IP[I];I:=32 To 63 Do[0].R[I-32]:=IP[I];I:=1 To 16 Do[I].L:=Result[I-1].R;:=GetF(Result[I-1].R,ConcatKey[I-1]);J:=0 To 31 Do[I].R[J]:=Result[I-1].L[J] XOR F[J];;;GetF(R,K:TBitString):TBitString;,J:Integer;,E,KE,F,T:TBitString;(E,48);I:=0 To 47 Do[I]:=R[DES_E[I]-1];(KE,48);I:=0 To 47 Do[I]:=K[I] XOR E[I];(T,6);(F,0);(S,4);:=0;I<48 DoJ:=0 To 6 Do[J]:=KE[J+I];:=GetSBox(I div 6,T);:=ConcatBits([F,S]);:=I+6;;(Result,32);I:=0 To 31 Do[I]:=F[DES_P[I]-1];;GetSBox(Index:Integer; T:TBitString):TBitString;,Row,Col:Integer;:TBitString;(Result,4);(Temp,2);[0]:=T[0];[1]:=T[5];:=BinToInt(Temp);(Temp,4);(Temp,TBitString(@T[1]),4);:=BinToInt(Temp);:=S_BOXES[Index,Row,Col];(Result,4);:=IntToBin(Val,4);;GetReverseIP(RL:TBitString):TBitString;:Integer;(Result,64);I:=0 To Length(DES_REVERSE_IP)-1 Do[I]:=RL[DES_REVERSE_IP[I]-1];;ReverseSubKeys(Var Keys:TConcatKey);,L:Integer;:TBitString;(T,48);:=Length(Keys);I:=0 To (L-1)Div 2 Do:=Keys[I];[I]:=Keys[(L-I)-1];[(L-I)-1]:=T;;;DESEncode(S,Key:String):TBitString;:Integer;:TBitString;:TBitString;:TBitString;:TBitString;:TSplitKey;:TConcatKey;:TIPKey;:=AnsiStrToBin(Key);:=GetPermutedKey(K);:=GetSplitKey(Kplus);:=GetConcatKey(SplitKey);:=AnsiStrToBin(S);:=GetIPKey(M,ConcatKey);(RL,64);I:=0 To 31 Do[I]:=IPKey[16].R[I];[I+32]:=IPKey[16].L[I];;:=GetReverseIP(RL);:=RL;;DESDecode(S,Key:String):TBitString;:Integer;:TBitString;:TBitString;:TBitString;:TBitString;:TSplitKey;:TConcatKey;:TIPKey;:=AnsiStrToBin(Key);:=GetPermutedKey(K);:=GetSplitKey(Kplus);:=GetConcatKey(SplitKey);(ConcatKey);:=AnsiStrToBin(S);:=GetIPKey(M,ConcatKey);(RL,64);I:=0 To 31 Do[I]:=IPKey[16].R[I];[I+32]:=IPKey[16].L[I];;:=GetReverseIP(RL);:=RL;
End;.

Download 0.52 Mb.

Do'stlaringiz bilan baham:
1   ...   7   8   9   10   11   12   13   14   15




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling