📄 des_crypt.3
字号:
.\" $Source: /usr/src/kerberosIV/man/RCS/des_crypt.3,v $.\" $Author: kfall $.\" $Header: /usr/src/kerberosIV/man/RCS/des_crypt.3,v 4.4 90/06/25 21:11:49 kfall Exp $.\" Copyright 1989 by the Massachusetts Institute of Technology..\".\" For copying and distribution information,.\" please see the file <mit-copyright.h>..\".TH DES_CRYPT 3 "Kerberos Version 4.0" "MIT Project Athena".SH NAMEdes_read_password, des_string_to_key, des_random_key, des_set_key,des_ecb_encrypt, des_cbc_encrypt, des_pcbc_encrypt, des_cbc_cksum,des_quad_cksum, \- (new) DES encryption.SH SYNOPSIS.nf.nj.ft B#include <kerberosIV/des.h>.PP.ft B.B int des_read_password(key,prompt,verify)des_cblock *key;char *prompt;int verify;.PP.ft Bint des_string_to_key(str,key)char *str;des_cblock key;.PP.ft Bint des_random_key(key)des_cblock *key;.PP.ft Bint des_set_key(key,schedule)des_cblock *key;des_key_schedule schedule;.PP.ft Bint des_ecb_encrypt(input,output,schedule,encrypt)des_cblock *input;des_cblock *output;des_key_schedule schedule;int encrypt;.PP.ft Bint des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)des_cblock *input;des_cblock *output;long length;des_key_schedule schedule;des_cblock *ivec;int encrypt;.PP.ft Bint des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt)des_cblock *input;des_cblock *output;long length;des_key_schedule schedule;des_cblock *ivec;int encrypt;.PP.ft Bunsigned long des_cbc_cksum(input,output,length,schedule,ivec)des_cblock *input;des_cblock *output;long length;des_key_schedule schedule;des_cblock *ivec;.PP.ft Bunsigned long quad_cksum(input,output,length,out_count,seed)des_cblock *input;des_cblock *output;long length;int out_count;des_cblock *seed;.PP.fi.SH DESCRIPTIONThis library supports various DES encryption related operations. It differsfrom the.I crypt, setkey, and encryptlibrary routines in that it providesa true DES encryption, without modifying the algorithm,and executes much faster..PPFor each key that may be simultaneously active, create a.B des_key_schedulestruct,defined in "des.h". Next, create key schedules (from the 8-byte keys) asneeded, via.I des_set_key,prior to using the encryption or checksum routines. Thensetup the input and output areas. Make sure to note the restrictionson lengths being multiples of eight bytes. Finally, invoke theencryption/decryption routines,.I des_ecb_encryptor.I des_cbc_encryptor.I des_pcbc_encrypt,or, to generate a cryptographic checksum, use.I quad_cksum(fast) or.I des_cbc_cksum(slow)..PPA.I des_cblockstruct is an 8 byte block used as the fundamental unit for DES data andkeys, and is defined as:.PP.B typedef unsigned char des_cblock[8];.PPand a.I des_key_schedule,is defined as:.PP.B typedef struct des_ks_struct {des_cblock _;} des_key_schedule[16];.PP.I des_read_passwordwrites the string specified by.I promptto the standardoutput, turns off echo (if possible)and reads an input string from standard input until terminated with a newline.If.I verifyis non-zero, it prompts and reads input again, for usein applications such as changing a password; bothversions are compared, and the input is requested repeatedly until theymatch. Then.I des_read_passwordconverts the input string into a valid DES key, internallyusing the.I des_string_to_keyroutine. The newly created key is copied to thearea pointed to by the.I keyargument..I des_read_passwordreturns a zero if no errors occurred, or a -1indicating that an erroroccurred trying to manipulate the terminal echo..PP.PP.I des_string_to_keyconverts an arbitrary length null-terminated stringto an 8 byte DES key, with odd byte parity, per FIPS specification.A one-way function is used to convert the string to a key, making itvery difficult to reconstruct the string from the key.The.I strargument is a pointer to the string, and.I keyshouldpoint to a.I des_cblocksupplied by the caller to receive the generated key.No meaningful value is returned. Void is not used for compatibility withother compilers..PP.PP.I des_random_keygenerates a random DES encryption key (eight bytes), set to odd parity perFIPSspecifications.This routine uses the current time, process id, and a counteras a seed for the random number generator.The caller must supply space for the output key, pointed toby argument.I key,then after calling.I des_random_keyshouldcall the.I des_set_keyroutine when needed.No meaningful value is returned. Void is not used for compatibilitywith other compilers..PP.PP.I des_set_keycalculates a key schedule from all eight bytes of the input key, pointedto by the.I keyargument, and outputs the schedule into the.I des_key_scheduleindicated by the.I scheduleargument. Make sure to pass a valid eight bytekey; no padding is done. The key schedule may then be used in subsequentencryption/decryption/checksum operations. Many key schedules may becached for later use. The user is responsible to clear keys and schedulesas soon as no longer needed, to prevent their disclosure.The routine also checks the keyparity, and returns a zero if the key parity is correct (odd), a -1indicating a key parity error, or a -2 indicating use of an illegalweak key. If an error is returned, the key schedule was not created..PP.PP.I des_ecb_encryptis the basic DES encryption routine that encrypts or decrypts a single 8-byteblock in.B electronic code bookmode. It always transforms the input data, pointed to by.I input,into the output data, pointed to by the.I outputargument..PPIf the.I encryptargument is non-zero, the.I input(cleartext) is encrypted into the.I output(ciphertext) using the key_schedule specified by the.I scheduleargument, previously set via.I des_set_key.PPIf encrypt is zero, the.I input(now ciphertext) is decrypted into the.I output(now cleartext)..PPInput and output may overlap..PPNo meaningful value is returned. Void is not used for compatibilitywith other compilers..PP.PP.I des_cbc_encryptencrypts/decrypts using the.B cipher-block-chaining mode of DES.If the.I encryptargument is non-zero, the routine cipher-block-chain encryptsthe cleartext data pointed to by the.I inputargument into the ciphertext pointed to by the.I outputargument, using the key schedule provided by the.I scheduleargument, and initialization vector provided by the.I ivecargument.If the.I lengthargument is not an integralmultiple of eight bytes, the last block is copied to a temp and zerofilled (highest addresses). The output is ALWAYS an integral multipleof eight bytes..PPIf.I encryptis zero, the routine cipher-block chain decrypts the (now) ciphertextdata pointed to by the.I inputargument into (now) cleartext pointed to by the.I outputargument using the key schedule provided by the.I scheduleargument, and initialization vector provided by the.I ivecargument. Decryption ALWAYS operates on integralmultiples of 8 bytes, so it will round the.I lengthprovided up to theappropriate multiple. Consequently, it will always produce the rounded-upnumber of bytes of output cleartext. The application must determine ifthe output cleartext was zero-padded due to original cleartext lengths thatwere not integral multiples of 8..PPNo errors or meaningful values are returned. Void is not used forcompatibility with other compilers..PPA characteristic of cbc mode is that changing a single bit of thecleartext, then encrypting using cbc mode,affects ALL the subsequent ciphertext. This makes cryptanalysismuch more difficult. However, modifying a single bit of the ciphertext,then decrypting, only affects the resulting cleartext fromthe modified block and the succeeding block. Therefore,.I des_pcbc_encryptis STRONGLY recommended for applications whereindefinite propagation of errors is required in order to detect modifications..PP.PP.I des_pcbc_encryptencrypts/decrypts using a modified block chaining mode. Its callingsequence is identical to.I des_cbc_encrypt.It differs in its error propagation characteristics..PP.I des_pcbc_encryptis highly recommended for most encryption purposes, in thatmodification of a single bit of the ciphertext will affect ALL thesubsequent (decrypted) cleartext. Similarly, modifying a single bit ofthe cleartext will affect ALL the subsequent (encrypted) ciphertext."PCBC" mode, on encryption, "xors" both thecleartext of block N and the ciphertext resulting from block N with thecleartext for block N+1 prior to encrypting block N+1..PP.I des_cbc_cksumproduces an 8 byte cryptographic checksum by cipher-block-chainencrypting the cleartext data pointed to by the.I inputargument. All of the ciphertext output is discarded, except thelast 8-byte ciphertext block, which is written into the area pointed to bythe.I outputargument.It uses the key schedule,provided by the.I scheduleargument and initialization vector provided by the.I ivecargument.If the.I lengthargument is not an integralmultiple of eight bytes, the last cleartext block is copied to a temp and zerofilled (highest addresses). The output is ALWAYS eight bytes..PPThe routine also returns an unsigned long, which is the last (highest address)half of the 8 byte checksum computed..PP.PP.I quad_cksumproduces a checksum by chaining quadratic operations on the cleartext datapointed to by the.I inputargument. The.I lengthargument specifies the length of theinput -- only exactly that many bytes are included for the checksum,without any padding..PPThe algorithm may be iterated over the same input data, if the.I out_countargument is 2, 3 or 4, and the optional.I outputargument is a non-null pointer .The default is one iteration, and it will not runmore than 4 times. Multiple iterations run slower, but providea longer checksum if desired. The.I seedargument provides an 8-byte seed for the first iteration. If multiple iterations arerequested, the results of one iteration are automatically used asthe seed for the next iteration..PPIt returns both an unsigned long checksum value, andif the.I outputargument is not a null pointer, up to 16 bytes ofthe computed checksum are written into the output..PP.PP.SH FILES/usr/include/kerberosIV/des.h.br/usr/lib/libdes.a.SH "SEE ALSO".SH DIAGNOSTICS.SH BUGSThis software has not yet been compiled or tested on machines other than theVAX and the IBM PC..SH AUTHORSSteve Miller, MIT Project Athena/Digital Equipment Corporation.SH RESTRICTIONSCOPYRIGHT 1985,1986 Massachusetts Institute of Technology.PPThis software may not be exported outside of the US without a speciallicense from the US Dept of Commerce. It may be replaced by any secretkey block cipher with block length and key length of 8 bytes, as longas the interface is the same as described here.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -