⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cipher.1

📁 des算法实现源码
💻 1
字号:
.\" @(#) cipher.1 1.0  @(#)cipher.1	1.1  91/20/91  1   .TH CIPHER 1 .ds )H David A. Barrett.ds ]W Revision 1.0: Jan 1991.SH NAMEcipher, decipher \- Fast DES-compatible encryption.SH SYNOPSIS.B cipher[.B \-de] [ .B \-i.I ivec] [.B \-x.I hexkey] [.B \-k.I keystr].SH DESCRIPTION.PP.I Cipher\^is an encryption program compatible with the National Bureau ofStandards .I Data Encryption Standard,published in .I FIPS Publication 46-1 (January 22, 1988)..PP.ne 8.I Cipherreads from the standard input and writeson the standard output.The.I keystr\^is a character string whichselects a particular transformation.The output will be unintelligible to anyone who doesnot specify the same .I keystr\^to the.I decipherprogram.Output will contain the same number of characters and the input butconsists of binary characters of eight-bits each.If no keyis given (using the,.B \-kor .B \-xoption),.I cipher\^demands a key from the terminal and turnsoff printing while the key is typed in.This is recommended sinceusers running the.I ps(1)can see keys specified on the command line.To assist in preventing typographic errors during keyentry, each key must be entered twice.  This feature maybe disabled by specifying the.B \-n option..SS Options.PP.TP 11.B  \-dUsed to decipher previously ciphered text..TP.B  \-eEncipher mode.  More than one.B \-eor.B \-doption forces multiple encryption..TP.B \-ninhibits key verification.TP.BI \-k\ keystrSpecifies a character string to use as the key for encryption/decryption..TP.BI \-x\ hexkeySpecifies the key as a hexadecimal number.  One to 16 digits may bespecified.  This key is left-justified and zero-padded..TP.BI \-i\ ivecSpecifies the initialization vector for cipher-feedback mode (CFB) as a one to 16-digit hexadecimal number.  This will be right-justified and zero padded..PPThe.B \-x,.B \-i,and.B \-koptions are primarily useful for test scripts..PPUnlike the crypt command,.I cipheris not its own inverse; you must use the.B \-doption to decipher previously encrypted text or invoke the command as.I decipher..PPThe security of the Data Encryption Standard has been controversial.In particular, the number of possible keys hasbeen criticized as too small; only 56-bits are used.  To assistin minimizing this risk, multiple-encryption, and "random" key-generation from text strings is provided.The key string may be any length other than zero.This string is hashed to produce the 56-bit key used for the DES.To help thwart dictionary attacks, the key should be as long as convenient and contain a mix of upper-case, lower-case and symbolic characters (space and control characters are permitted).Short sentences or phrases consisting of nonsense words are recommended.These precautions should make it more difficult for someoneto usecomputer(s) (or DES hardware) to guess your key by trial anderror.  This is a very serious threat and should not be ignored..PPFor particularly sensitive information, doubleor triple encryption with independent keys should be used.Attempts to crack the encrypted text may be made more difficult byremoving redundancy from the input by using the.I compress(1)command prior to enciphering and subsequent to deciphering.(Even further security can be obtained by specifying the.B \-noption to .I compress so that no header is included.).ne 8.PPThe following command illustrates encryption of the file.I clearto produce the file.I cypher..PP.RScompress -n <clear | cipher \|>cypher.brInput Key:.brVerify Key:.brrm clear.br.RE.PP.PPThis command is used to examine the previously enciphered file:.PP.RScipher -d <cypher | uncompress -n | more.brInput Key:.br.RE.PPThe following command may be used to accomplish multiple-encipherment:(The key text is shown only for illustration).PP.RScipher -e -e <plain >cipherfile.brInput Key:firsty keyzy.brInput Key:seconDzy keysy.br.RE.PPA prompt for each cipher key is shown.  When multiple-encipherment isselected, care should be taken to specify the keys in the reverse orderwhen deciphering. All the following commands below are equivalent waysof deciphering the above:.PP.RScipher -d -d <cipherfile >plain.brInput Key:seconDzy keysy.brInput Key:firsty keyzy.brcipher -dk "seconDzy keysy" -dk "firsty keyzy" <cipherfile >plain.brcipher -d -k "seconDzy keysy" <cipherfile \\.br| decipher -k "firsty keyzy" >plain.RE.PPFor transmitting encrypted text though the mail system, the.I atob(1),and.I btoa(1),commands may be used.These programs are available as part of the.I compress4.0 package. (also included with the .I cipher package).PPFor example, to send a secret message, typed from the terminal:.PP.RScompress -n | cipher | btoa | mail user.RE.PPThe receiver could save the message in the file.I secretand read it using the command:.PP.RSatob <secret | decipher | uncompress -n.RE.PPNotice that you did not have to worry about stripping mailer headers from the text because the.I atobprogram does that automatically..PPSince the Data Encryption Standard is, by definition, implemented only in hardware, this algorithm should not be considered as a DESimplementation. However, it should yield the same results asDES hardware using 64-bit Cipher-Feedback Mode (CFB). (SeeFIPS Publications 81 and 74)..PPThe key used as input to the DES is generated as follows:The keystring is padded with blank characters to a positive multiple of eight.A secondary key is generated from the first eight characters of.I keystrby shifting each character left by one (discarding each high-order bit). This secondary key is used to produce a 64-bit authentication code byenciphering the rest of.I keystrusing DES in cipher-block-chaining (CBC) encryption mode withan initialization vector of zeros.This 64-bit authentication code is used as the encryption key.This is the same method used by FIPS publication 112 except the authentication code is not converted into printable form.This is also identical to FIPS publication 113 with the input padded withblanks instead of zeros.The initialization vector is generated from a string of all zeros..PP.SH WARNINGSIf output is piped to.IR nroff (1)and the encryption key is.I not\^given on the command line,.I cipher\^can leave terminal modes with echoing disabled.(see.IR stty (1))..PPIf two or more files encrypted with the same key are concatenatedand an attempt is made to decrypt the result, only thecontents of the first of the original files will be decrypted correctly..PPThis code is not compatible with Sun's des program.  Unlike Sun's this code preserves the original file size and is also suitable for use in communications protocols where one byte of output occurs as each byte is input.  As far as I know, this is the only fast implementation of DES in cipher-feedback mode which has the above two properties..SH ACKNOWLEDGEMENTSThe author has made every attempt to produce the fastest, portableDES-compatible program possible, but considerable speed improvements remain.  Comments and improvementswill be greatly appreciated and should be directed to the author:.PPDavid A. Barrett (barrett@asgard.cs.Colorado.EDU).PPCopyright 1994 by David. A. Barrett.PPThis program is not to be distributed for profit or included in suchsoftware without written permission from the author (this means you, TVAnswer).No permission is required for non-profit use..SH FILES.ta 1i/dev/tty	for typed key.DT.SH SEE ALSOcrypt(1),compress(1),btoa(1),atob(1),makekey(1), des(3),desCFB(3),crypt(3),stty(1)..\" index	\fIcrypt\fR \- encode/decode files 	 \s-2CRYPT\s+1(1)\s+1.\" index	decode/encode files 	 \s-2CIPHER\s+1(1)\s+1.\" index	encode/decode files 	 \s-2CIPHER\s+1(1)\s+1.\" index	decrypt/encrypt files 	 \s-2CIPHER\s+1(1)\s+1.\" index	encrypt/decrypt files 	 \s-2CIPHER\s+1(1)\s+1.\" index	files: encrypt/decrypt files 	 \s-2CIPHER\s+1(1)\s+1.\".\" toc	\s-2CIPHER\s+1(1)\s+1:\0\0\fIcipher\fR 	 encode/decode files

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -