des_crypt.3krb

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 3KRB 代码 · 共 301 行

3KRB
301
字号
.TH des_crypt 3krb.SH Namedes_crypt \- Data Encryption Standard (DES) encryption library routines..SH Syntax.nf.nj \fB#include <des.h>\fP.PP.ig ++ \fBint des_read_password\fP (\fIkey, prompt, verify\fP)	\fBC_Block\fP	\fI*key\fP;	\fBchar\fP		\fI*prompt;\fP	\fBint\fP		\fIverify;\fP.++.PP \fBint des_string_to_key\fP    (\fIstr, key\fP) \fBchar\fP		\fI*str\fP; \fBC_Block\fP	\fI*key\fP;.PP \fBint des_is_weak_key\fP (\fIkey\fP) \fBC_Block\fP	\fIkey\fP;.ig ++ \fBint ecb_encrypt\fP \fI(input,output,schedule,encrypt)\fP	\fBC_Block\fP	\fI*input;\fP	\fBC_Block\fP	\fI*output;\fP	\fBKey_schedule\fP	\fIschedule;\fP	\fBint\fP		\fIencrypt;\fP.PP \fBint cbc_encrypt\fP \fI(input,output,length,schedule,\fP                        \fIivec,encrypt)\fP	\fBC_Block\fP	\fI*input;\fP	\fBC_Block\fP	\fI*output;\fP	\fBlong\fP		\fIlength;\fP	\fBKey_schedule\fP	\fIschedule;\fP	\fBC_Block\fP	\fI*ivec;\fP	\fBint\fP		\fIencrypt;\fP.PP \fBint pcbc_encrypt\fP \fI(input,output,length,schedule,\fP                         \fIivec,encrypt)\fP	\fBC_Block\fP	\fI*input;\fP	\fBC_Block\fP	\fI*output;\fP	\fBlong\fP		\fIlength;\fP	\fBKey_schedule\fP	\fIschedule;\fP	\fBC_Block\fP	\fI*ivec;\fP	\fBint\fP		\fIencrypt;\fP.PP \fBunsigned long cbc_cksum\fP \fI(input,output,length,\fP                                \fIschedule,ivec)\fP	\fBC_Block\fP	\fI*input;\fP	\fBC_Block\fP	\fI*output;\fP	\fBlong\fP		\fIlength;\fP	\fBKey_schedule\fP	\fIschedule;\fP	\fBC_Block\fP	\fI*ivec;\fP.++.PP \fBunsigned long des_quad_cksum\fP  (\fIinput, output, length,                                                 iterations, seed\fP) \fBunsigned char\fP	 \fI*input\fP; \fBunsigned long\fP	\fI*output\fP; \fBlong\fP		\fIlength\fP; \fBint\fP		\fIiterations\fP; \fBC_Block\fP	\fI*seed\fP;.PP \fBint des_key_sched\fP  (\fIkey, schedule\fP) \fBC_Block\fP	\fIkey\fP; \fBKey_schedule\fP	\fIschedule\fP;.PP.fi.SH Arguments.TP 9.I keyFor .PN des_string_to_key ,\fIkey\fP is a pointer to a .PN C_Blockof 8-byte length.  For .PN des_quad_cksum ,.PN des_is_weak_key ,and.PN des_key_sched ,\fIkey\fP is a pointer to a DES key..TP.I strA string that is converted to an 8-byte DES key..TP.I inputPointer to a block of data to which a quadratic checksum algorithm is applied.  .TP.I outputPointer to a pre-allocated buffer that will contain the complete output from the quadraticchecksum algorithm.  For each iteration of the quadratic checksum applied to the input,eight bytes (two longwords) of data are generated..TP.I lengthLength of the data to which the quadratic checksum algorithm will be applied.  If inputcontains more than \fIlength\fP bytes of data, then the quadratic checksumwill only be applied to \fIlength\fP bytes of input..TP.I iterationsThe number of iterations of the.PN des_quad_cksumalgorithm to apply to \fIinput\fP.  If output is NULL, then one iteration of the algorithmwill be applied to \fIinput\fP, no matter what the value of \fIiterations\fP is.  Themaximum number of iterations is four..TP.I seedAn 8-byte quantity used as a seed to the \fIinput\fP of the.PN des_quad_cksumalgorithm..TP.I scheduleA representation of a DES key in a form more easily used with encryption algorithms.  Itis used as input to the .PN krb_sendmutualroutines. .SH Description.NXR "Kerberos routines" "des_crypt".NXR "Kerberos routines" "des_string_to_key".NXR "Kerberos routines" "des_quad_cksum".NXR "Kerberos routines" "des_key_sched"The.PN des_cryptroutines are designed to provide the cryptographic routines which are used to supportauthentication.  Specifically,.PN des_quad_cksumand.PN des_key_schedare designed to be used with the DES key which is shared between one Kerberos principaland its authenticated peer to provide an easy authentication method after the initialKerberos authentication pass..PN des_string_to_keyand.PN des_is_weak_keyare designed to enable the input and inspection of a key by a user before that key is usedwith the Kerberos authentication routines.  The.PN des_cryptroutines are not designed for general encryption..PPThe library makes extensive use of the locally defined data types\f(CWC_Block\fP and \f(CWKey_schedule\fP. The \f(CWC_Block\fP struct is an 8-byte block used by the various routines of the .PN des_cryptlibrary as the fundamental unit for DES data and keys..SH Routines.IP string_to_key Converts a null-terminated string of arbitrary lengthto an 8-byte, odd-byte-parity DES key.The \fIstr\fP argument is apointer to the character string to be converted and \fIkey\fP points to a\f(CWC_Block\fP supplied by the caller to receive the generated key.  The one-wayfunction used to convert the string to a key makes it very difficult for anyone toreconstruct the string from the key.  Nomeaningful value is returned..IP des_is_weak_key.PN des_is_weak_keychecks a new key input by a user to determine if it belongs to the well known set ofDES keys which do not provide good cryptographic behavior.  If a key passes the inspectionof.PN des_is_weak_key ,then it can be used with the.PN des_quad_cksumroutine.  The input is a DES key and the output is equal to 1 if the key is not a safe keyto use; it is equal to 0 if it is safe to use..ig ++.IP ecb_encryptEncrypts or decrypts a single 8-byte block in electronic code book(ecb) mode. This routine always transforms the input data pointed toby \fIinput\fP into the output data pointed to by \fIoutput\fP..IPThe \fIencrypt\fP flag determines if \f(CWecb_encrypt\fP encrypts ordecrypts data. If \fIencrypt\fP is non-zero, the \f(CWecb_encrypt\fProutine encrypts the cleartext data pointed to by \fIinput\fP into theciphertext data pointed to by \fIinput\fP. If \fIencrypt\fP is zero,the \f(CWecb_encrypt\fP routine decrypts the ciphertext data pointed toby \fIinput\fP into the cleartext data pointed to by \fIoutput\fP..IPInput and output may overlap. No meaningful value is returned.  Void isnot used, for compatibility with other compilers..IP cbc_encryptEncrypts/decrypts a single 8-byte block using the cipher-block-chaining(cbc) mode of DES. If the \fIencrypt\fP flag is non-zero, the routineuses the  key schedule located in the \f(CWschedule\fP structure and theinitialization vector provided by the \fIivec\fP argument to cbcencrypt the cleartext data pointed to by \fIinput\fP into theciphertext pointed to by \fIoutput\fP. .IPIf the \fIlength\fP argument is not an integral multiple of eightbytes, \f(CWcbc_encrypt\fP copies the data to a temporary area and zerofills it (highest addresses).  The output is always an integralmultiple of eight bytes..IPIf \fIencrypt\fP is zero, \f(CWcbc_encrypt\fP uses the key schedulelocated in the \f(CWschedule\fP structure and the initialization vectorprovided by the \fIivec\fP argument to cbc decrypt the (now) ciphertextdata pointed to by the input argument into the (now) cleartext pointedto by the \fIoutput\fP..IPDecryption always operates on integral multiples of 8 bytes, so thedecryption routines will round up the length provided to theappropriate multiple.  Consequently, decryption will always produce therounded-up number of bytes of output cleartext.  The application mustdetermine if the output cleartext was zero-padded due to originalcleartext lengths that were not integral multiples of 8..IPNo errors or meaningful values are returned by this routine.  Void isnot used for compatibility with other compilers..IPA characteristic of cbc mode is that changing a single bit of thecleartext, then encrypting using cbc mode, affects all the subsequentciphertext.  This makes cryptanalysis much more difficult. However,modifying a single bit of the ciphertext, then decrypting, only affectsthe resulting cleartext from the modified block and the succeedingblock.  Therefore, using the \f(CWpcbc_encrypt\fP is stronglyrecommended for applications where indefinite propagation of errors isrequired in order to detect modifications..IP pcbc_encrypt Encrypts/decrypts an 8-byte block using a modified block chaining mode.The calling sequence of \f(CWpcbc_encrypt\fP is identical to that of\f(CWcbc_encrypt\fP, however, its error propagation differs..IPBecause modifying a single bit of ciphertext affects all the subsequent(decrypted) cleartext, it is highly recommended that you use the\f(CWpcbc_encrypt\fP for most encryption purposes. Similarly, modifyinga single bit of the cleartext affects all the subsequent(encrypted) ciphertext. .IPPCBC mode on encryption, "xors" both the cleartext of block N andthe ciphertext resulting from block N with the cleartext for block N+1prior to encrypting block N+1..IP cbc_cksum produces an 8 byte cryptographic checksum by cbc encrypting thecleartext data pointed to by \fIinput\fP and using the key schedulelocated in the \fIschedule\fP structure and the initialization vectorprovided by the \fIivec\fP argument. The \f(CWcbc_cksum\fP routinediscards all of the ciphertext output except the last 8 byte ciphertextblock, which is written into the area pointed to by \fIoutput\fP..IPIf \fIlength\fP is not an integral multiple of eight bytes, the lastcleartext block is copied to a temporary location and zero filled (highestaddresses). The output is always eight bytes..IPThe \f(CWcbc_cksum\fP routine also returns an unsigned long, which isthe last (highest address) half of the 8 byte checksum computed..++.IP des_quad_cksum Produces a checksum by chaining quadratic operations on cleartextdata..PN des_quad_cksumcan be used to produce anormal quadratic checksum and, if used withthe DES key shared between two authenticatedKerberos principals, it can also providefor the integrity and authenticationprotection of data sent from one principal to another..IPInput of \fIlength\fP bytes are run through the .PN des_quad_cksumroutine \fIiterations\fP times to produce \fIoutput\fP.  If \fIoutput\fPis NULL, one iteration is performed and \fIoutput\fP is not affected.If \fIoutput\fP is not NULL, the quadratic checksum algorithm will beperformed \fIiterations\fP times on input, placing eight bytes (two longwords) of result in \fIoutput\fP for each iteration.  At all times, the low-order bitsof the last quadratic checksum algorithm pass are returnedby .PN des_quad_cksum ..IPThe quadratic checksum algorithm performs a checksumon a few bytes of data and feeds the result into the algorithmas an addition input to the checksum on the next few bytes.The seed serves as the additional input for the first checksumoperation and, therefore, the final checksum that resultsdepends upon the seed input into the algorithm.  If theDES key shared between two Kerberos principals is used asthe initial seed, then since the checksum that resultsdepends upon the seed, the ability to produce the checksumproves identity and authentication.  Also, since the message cannotbe altered without knowledge of the seed, it also provides fordata integrity..IP des_key_sched.PN des_key_schedis used to convert the key input intoa new format that can be used readily with encryptionfunctions.  The result, schedule, can be used with the .PN krb_sendmutualfunctions to enable mutualauthentication of two Kerberos principals..sp 10 is returned from .PN des_key_schedif successful..sp .5-1 is returned if the each byte of the key does nothave odd parity..sp .5-2 is returned if the key is a weak key asdefined by.PN des_is_weak_key .

⌨️ 快捷键说明

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