📄 des算法源程序.mht
字号:
function from Kerberos v4 that is not anything =
to do=20
with<BR> DES but was=20
needed. It is a cksum that is quicker =
to=20
generate than<BR> =20
des_cbc_cksum(); I personally would =
use MD5=20
routines now.<BR>=3D=3D=3D=3D=3D<BR>Modes of =
DES<BR>Quite a bit of=20
the following information has been taken =
from<BR> =20
AS 2805.5.2<BR> =
=20
Australian Standard<BR> =
=20
Electronic funds transfer - Requirements =
for=20
interfaces,<BR> Part =
5.2:=20
Modes of operation for an n-bit block cipher=20
algorithm<BR> =
Appendix=20
A<BR><BR>There are several different modes in =
which DES=20
can be used, they are<BR>as =
follows.<BR><BR>Electronic=20
Codebook Mode (ECB) (des_ecb_encrypt())<BR>- 64 =
bits are=20
enciphered at a time.<BR>- The order of the =
blocks can=20
be rearranged without detection.<BR>- The same =
plaintext=20
block always produces the same ciphertext=20
block<BR> (for the same key) making =
it=20
vulnerable to a 'dictionary attack'.<BR>- An =
error will=20
only affect one ciphertext block.<BR><BR>Cipher =
Block=20
Chaining Mode (CBC) (des_cbc_encrypt())<BR>- a =
multiple=20
of 64 bits are enciphered at a time.<BR>- The =
CBC mode=20
produces the same ciphertext whenever the=20
same<BR> plaintext is encrypted using =
the=20
same key and starting variable.<BR>- The =
chaining=20
operation makes the ciphertext blocks dependent =
on=20
the<BR> current and all preceding =
plaintext=20
blocks and therefore blocks can =
not<BR> be=20
rearranged.<BR>- The use of different starting =
variables=20
prevents the same =
plaintext<BR> enciphering=20
to the same ciphertext.<BR>- An error will =
affect the=20
current and the following ciphertext=20
blocks.<BR><BR>Cipher Feedback Mode (CFB)=20
(des_cfb_encrypt())<BR>- a number of bits (j) =
<=3D 64=20
are enciphered at a time.<BR>- The CFB mode =
produces the=20
same ciphertext whenever the=20
same<BR> plaintext is encrypted using =
the=20
same key and starting variable.<BR>- The =
chaining=20
operation makes the ciphertext variables =
dependent on=20
the<BR> current and all preceding =
variables=20
and therefore j-bit variables =
are<BR> chained=20
together and can not be rearranged.<BR>- The use =
of=20
different starting variables prevents the same=20
plaintext<BR> enciphering to the same =
ciphertext.<BR>- The strength of the CFB mode =
depends on=20
the size of k (maximal if<BR> j =
=3D=3D=20
k). In my implementation this is =
always the=20
case.<BR>- Selection of a small value for j will =
require=20
more cycles through<BR> the =
encipherment=20
algorithm per unit of plaintext and thus=20
cause<BR> greater processing =
overheads.<BR>-=20
Only multiples of j bits can be enciphered.<BR>- =
An=20
error will affect the current and the following=20
ciphertext variables.<BR><BR>Output Feedback =
Mode (OFB)=20
(des_ofb_encrypt())<BR>- a number of bits (j) =
<=3D 64=20
are enciphered at a time.<BR>- The OFB mode =
produces the=20
same ciphertext whenever the=20
same<BR> plaintext enciphered using =
the same=20
key and starting=20
variable. More<BR> over, =
in the=20
OFB mode the same key stream is produced when =
the=20
same<BR> key and start variable are=20
used. Consequently, for security=20
reasons<BR> a specific start variable =
should=20
be used only once for a given key.<BR>- The =
absence of=20
chaining makes the OFB more vulnerable to =
specific=20
attacks.<BR>- The use of different start =
variables=20
values prevents the =
same<BR> plaintext=20
enciphering to the same ciphertext, by producing =
different<BR> key streams.<BR>- =
Selection of=20
a small value for j will require more cycles=20
through<BR> the encipherment =
algorithm per=20
unit of plaintext and thus =
cause<BR> greater=20
processing overheads.<BR>- Only multiples of j =
bits can=20
be enciphered.<BR>- OFB mode of operation does =
not=20
extend ciphertext errors in =
the<BR> resultant=20
plaintext output. Every bit error in =
the=20
ciphertext causes<BR> only one bit to =
be in=20
error in the deciphered plaintext.<BR>- OFB mode =
is not=20
self-synchronising. If the two =
operation=20
of<BR> encipherment and decipherment =
get out=20
of synchronism, the system =
needs<BR> to be=20
re-initialised.<BR>- Each re-initialisation =
should use a=20
value of the start variable<BR>different from =
the start=20
variable values used before with the=20
same<BR>key. The reason for this is =
that an=20
identical bit stream would be<BR>produced each =
time from=20
the same parameters. This would=20
be<BR>susceptible to a ' known plaintext'=20
attack.<BR><BR>Triple ECB Mode =
(des_ecb3_encrypt())<BR>-=20
Encrypt with key1, decrypt with key2 and encrypt =
with=20
key3 again.<BR>- As for ECB encryption but =
increases the=20
key length to 168 bits.<BR> There are =
theoretic attacks that can be used that make the =
effective<BR> key length 112 bits, =
but this=20
attack also requires 2^56 blocks=20
of<BR> memory, not very likely, even =
for the=20
NSA.<BR>- If both keys are the same it is =
equivalent to=20
encrypting once with<BR> just one =
key.<BR>-=20
If the first and last key are the same, the key =
length=20
is 112 bits.<BR> There are attacks =
that could=20
reduce the key space to 55 bit's but=20
it<BR> requires 2^56 blocks of =
memory.<BR>-=20
If all 3 keys are the same, this is effectively =
the same=20
as normal<BR> ecb mode.<BR><BR>Triple =
CBC=20
Mode (des_ede3_cbc_encrypt())<BR>- Encrypt with =
key1,=20
decrypt with key2 and then encrypt with =
key3.<BR>- As=20
for CBC encryption but increases the key length =
to 168=20
bits with<BR> the same restrictions =
as for=20
triple ecb =
mode.<BR><BR>=D5=E2=CA=C7=C3=E8=CA=F6=D0=D4=B5=C4=D3=EF=D1=D4=A3=AC=B2=A2=
=B2=BB=C4=DC=D6=B1=BD=D3=D4=CB=D0=D0=A3=A1<A=20
name=3Dendpid126363></A> <BR></TD></TR>
<TR align=3Dright>
<TD vAlign=3Dbottom><BR><BR><BR><BR><BR><IMG=20
=
src=3D"http://25.20.176.12/bbs/images/common/sigline.gif"><BR><IMG=20
onmouseover=3D"if(this.alt) =
this.style.cursor=3D'hand';"=20
=
onclick=3D"javascript:window.open('http://25.20.176.12/bbs/attachment.php=
?s=3D&postid=3D129100');"=20
=
src=3D"http://25.20.176.12/bbs/attachment.php?s=3D&postid=3D129100"=20
=
onload=3D"javascript:if(this.width>screen.width-333) =
{this.width=3Dscreen.width-333;this.alt=3D'=B5=E3=BB=F7=D5=E2=C0=EF=D4=DA=
=D0=C2=B4=B0=BF=DA=D4=A4=C0=C0';}"=20
border=3D0></TD></TR></TBODY></TABLE></TD></TR>
<TR bgColor=3D#e8f2ff>
<TD class=3Dsmalltxt vAlign=3Dcenter><A=20
=
href=3D"http://25.20.176.12/bbs/viewthread.php?tid=3D17748#pid126363"><IM=
G=20
alt=3D=BB=D8=B5=BD=B5=DA1=CC=F9=BF=AA=CD=B7=20
=
src=3D"http://25.20.176.12/bbs/images/default/threadforward.gif"=20
align=3DabsMiddle border=3D0></A> 2004-3-27 11:23 =
PM</A> </TD>
<TD vAlign=3Dcenter>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"100%" =
border=3D0>
<TBODY>
<TR class=3Dsmalltxt>
<TD align=3Dleft><A=20
=
href=3D"http://25.20.176.12/bbs/viewpro.php?username=3D19820522"><IMG=20
alt=3D=B2=E9=BF=B4=D7=CA=C1=CF=20
=
src=3D"http://25.20.176.12/bbs/images/default/profile.gif"=20
border=3D0></A> <A href=3D"http:///"=20
target=3D_blank><IMG =
alt=3D=B7=C3=CE=CA=D6=F7=D2=B3=20
=
src=3D"http://25.20.176.12/bbs/images/default/site.gif"=20
border=3D0></A> <A=20
=
href=3D"http://25.20.176.12/bbs/search.php?srchuname=3D19820522&srchf=
id=3Dall&srchfrom=3D0&searchsubmit=3Dyes"><IMG=20
=
alt=3D=CB=D1=CB=F7=B8=C3=D3=C3=BB=A7=B5=C4=C8=AB=B2=BF=CC=FB=D7=D3=20
=
src=3D"http://25.20.176.12/bbs/images/default/find.gif"=20
border=3D0></A> <A=20
=
href=3D"http://25.20.176.12/bbs/pm.php?action=3Dsend&username=3D19820=
522"=20
target=3D_blank><IMG =
alt=3D=B7=A2=B6=CC=CF=FB=CF=A2=20
=
src=3D"http://25.20.176.12/bbs/images/default/pm.gif"=20
border=3D0></A> </TD>
<TD align=3Dright> <A=20
=
href=3D"http://25.20.176.12/bbs/post.php?action=3Dreply&fid=3D144&=
;tid=3D17748&repquote=3D126363&page=3D1"><IMG=20
alt=3D=D2=FD=D3=C3=BB=D8=B8=B4=20
=
src=3D"http://25.20.176.12/bbs/images/default/quote.gif"=20
border=3D0></A> <A=20
=
href=3D"http://25.20.176.12/bbs/misc.php?action=3Dreport&fid=3D144&am=
p;tid=3D17748&pid=3D126363"><IMG=20
=
alt=3D=CF=F2=B0=E6=D6=F7=B7=B4=D3=A6=D5=E2=B8=F6=CC=FB=D7=D3=20
=
src=3D"http://25.20.176.12/bbs/images/default/report.gif"=20
border=3D0></A> <SELECT=20
=
onchange=3D"if(this.options[this.selectedIndex].value !=3D '') =
{ window.location=3D('misc.php?action=3Dkarma&tid=3D17748&pid=
=3D126363&username=3D19820522&score=3D'+this.options[this.selecte=
dIndex].value+'&sid=3DYGcECnhv') }"=20
align=3DabsMiddle name=3Dfid> <OPTION value=3D"" =
selected>=C6=C0=B7=D6</OPTION> <OPTION =
value=3D"">----</OPTION>=20
<OPTION value=3D-4>-4</OPTION> <OPTION=20
value=3D-3>-3</OPTION> <OPTION =
value=3D-2>-2</OPTION>=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -