青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

S.l.e!ep.¢%

像打了激速一樣,以四倍的速度運轉,開心的工作
簡單、開放、平等的公司文化;尊重個性、自由與個人價值;
posts - 1098, comments - 335, trackbacks - 0, articles - 1
  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

about des_encrypt()

Posted on 2010-01-22 10:51 S.l.e!ep.¢% 閱讀(1129) 評論(0)  編輯 收藏 引用

des_encrypt() -- SSLeay 0.9.0b -- January 1999

NAME

des_encrypt, des_encrypt2, des_ecb_encrypt, des_cbc_encrypt, des_ncbc_encrypt,
des_xcbc_encrypt, des_pcbc_encrypt, des_cfb_encrypt, des_cfb64_encrypt,
des_ofb_encrypt, des_ofb64_encrypt -- DES encryption

SYNOPSIS

#include "des.h"

void des_encrypt(data,ks,enc)
unsigned long *data;
des_key_schedule ks; int enc;

void des_encrypt2(data,ks,enc)
unsigned long *data;
des_key_schedule ks; int enc;

void des_ecb_encrypt(input,output,ks,enc)
des_cblock *input, *output;
des_key_schedule ks; int enc;

void des_cbc_encrypt(input,output,length,ks,ivec,enc)
des_cblock *input, *output, *ivec;
long length;
des_key_schedule ks;
int enc;

void des_ncbc_encrypt(input,output,length,ks,ivec,enc)
des_cblock *input, *output, *ivec;
long length;
des_key_schedule ks;
int enc;

void des_xcbc_encrypt(input,output,length,ks,ivec,inw,outw,enc)
des_cblock *input, *output, *ivec, *inw, *outw;
des_cblock *output;
long length;
des_key_schedule ks;
int enc;

void des_pcbc_encrypt(input,output,length,ks,ivec,enc)
des_cblock *input, *output, *ivec;
long length;
des_key_schedule ks;
int enc;

void des_cfb_encrypt(in,out,numbits,length,ks,ivec,enc)
unsigned char *input, *output;
int numbits, enc;
long length;
des_key_schedule ks;
des_cblock *ivec;

void des_cfb64_encrypt(in,out,length,ks,ivec,num,enc)
unsigned char *in, *out;
long length;
des_key_schedule ks;
des_cblock *ivec;
int *num, enc;

void des_ofb_encrypt(in,out,numbits,length,ks,ivec)
unsigned char *in, *out;
int numbits;
long length;
des_key_schedule ks;
des_cblock *ivec;

void des_ofb64_encrypt(in,out,length,ks,ivec,num)
unsigned char *in, *out;
long length;
des_key_schedule ks;
des_cblock *ivec;
int *num;

DESCRIPTION

In any function prototype which has arguments input and output, the same variable can be passed for both arguments.

des_encrypt() is the basic building block used by all of the other DES encryption routines. It should be used only to implement a DES mode that the library doesn't already supply.

des_encrypt operates on data which is a pointer to two DES_LONGs (at least 4 characters per element, maybe more depending on how large a long is on your machine, but in that case, the extra bytes are treated as padding). In order to make this work right, each function implementing a DES mode does conversion of the input block, essentially a string of characters, to an array of DES_LONGs before invoking des_encrypt. After the encryption the function does the reverse conversion. Here's an example (from ecb_enc.c):

void des_ecb_encrypt(input, output, ks, encrypt)
des_cblock (*input);
des_cblock (*output);
des_key_schedule ks;
int encrypt;
        {
        register DES_LONG l;
        register unsigned char *in,*out;
        DES_LONG ll[2];

        in=(unsigned char *)input;
        out=(unsigned char *)output;
        c2l(in,l); ll[0]=l;
        c2l(in,l); ll[1]=l;
        des_encrypt(ll,ks,encrypt);
        l=ll[0]; l2c(l,out);
        l=ll[1]; l2c(l,out);
        l=ll[0]=ll[1]=0;
        }

ks is a previously-initialized des_key_schedule.

enc takes either the value DES_ENCRYPT, in which case encryption is performed, or DES_DECRYPT, in which case decryption is performed.

des_encrypt2() is identical to des_encrypt except that the DES initial permutation (IP) and final permutation (FP) have been left out. Again, this function should not be used except to implement new DES modes.

It is currently used to implement the various triple-DES modes.

(IP() des_encrypt2() des_encrypt2() des_encrypt2() FP()
is the same as
des_encrypt() des_encrypt() des_encrypt()
except faster :-).)

des_ecb_encrypt() is the Electronic Code Book form of DES, the most basic form of the algorithm. The des_cblock pointed to by input is encrypted into the block pointed to by output (which may be the same as input) using the key represented by ks. enc takes either the value DES_ENCRYPT, in which case encryption is performed, or DES_DECRYPT, in which case decryption is performed.

des_cbc_encrypt() implements DES in Cipher Block Chaining mode. The des_cblocks pointed to by input are encrypted (or decrypted) to the blocks pointed to by output.

Length should contain the number of des_cblocks * 8 (i.e. the total length of the input).

If length is not a multiple of 8, the results are unpredictable.

ivec is used to hold the output cipher text before calling the function again, if you are encrypting a text in several separate calls. This output is typically used in some way to modify the algorithm so that, if you use one of the chaining or feedback modes, encryption of the same block of text does not always give the same output (but encryption of the same block of text, with the same ivec in place, will typically give the same output).

See DES encryption modes overview for a discussion of the various modes.

For more details about the modes, see FIPS Pub 81: DES Modes of Operation; this is the updated version from May of 1996.

Unfortunately, this function does not automatically update ivec; the user must do it by copying in the last 8 bytes of output cipher text into ivec before the next call to this function.

ivec must be initialized to some known (but randomly generated) state before calling this function on the first chunk of data (and when you decrypt the data, the same initialization needs to be used for the first decryption call).

For example (from destest.c),

    des_cbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out,
         (long)strlen((char *)cbc_data)+1,ks,
         (C_Block *)cbc_iv,DES_ENCRYPT);
    des_cbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in,
         (long)strlen((char *)cbc_data)+1,ks,
         (C_Block *)cbc_iv,DES_DECRYPT);

where cbc_iv has been initialized previously by the user.

des_ncbc_encrypt() is identical to des_cbc_encrypt except that it does the update of ivec automatically. For tha reason it should be used in preference to des_cbc_encrypt whenever possible.

des_xcbc_encrypt() is RSA's DESX mode of DES. It uses inw and outw, supplied by the user, to 'whiten' the key. These should be nice random strings like the DES key unless the user is choosing them manually.

DESX is defined as key1 xor (des ( key2 xor input ) ), where the des encryption is done with a third key key3. Here, inw is keyn, and outw is keyn.

This substantially strengthens the algorithm against exhaustive search of the key space; see DES algorithm references for more details.

des_pcbc_encrypt() is the Propagating Cipher Block Chaining mode of DES. It is used by Kerberos v4. Its parameters are the same as des_ncbc_encrypt().

des_cfb_encrypt() is the Cipher Feedback mode of DES. This implementation 'feeds back' in numbit blocks. The input in) and the output out is in multiples of numbits bits, and numbit should be a multiple of 8 bits. length is the number of bytes in in.

If numbits is not a multiple of 8 bits, the extra bits in the bytes will be considered padding. For example, if numbits is 12, for each 2 input bytes, the 4 high bits of the second byte will be ignored. So to encode 72 bits when using numbits of 12 takes 12 bytes. To encode 72 bits when using numbits of 9 will take 16 bytes. To encode 80 bits when using numbits of 16 will take 10 bytes, and so on. This padding factor applies to both in and out.

ivec is used to keep intermediate results for subsequent calls, and as input to the function the first time it is called on a text.

It should be initialized to a known (but randomly generated) state before this function is called on the first part of a piece of data.

ks is a key schedule that has been previously set by des_set_key.

enc takes either the value DES_ENCRYPT, in which case encryption is performed, or DES_DECRYPT, in which case decryption is performed.

des_cfb64_encrypt() implements the Cipher Feedback Mode of DES, with 64 bit feedback. The arguments are the same as for des_cfb_encrypt except that there is no numbits argument, because there is no padding factor, and there is an additional num argument which is updated by the function along with ivec after each call.

The num argument is updated to show how many bytes of the ivec have been used; one step in the algorithm includes the xor of a byte of the plaintext with a byte of the (encrypted) ivec, so that all 8 bytes of the ivec are used in turn for an input block of 8 bytes. As each byte of the ivec is used, a new byte is created by the algorithm and stuffed into the ivec in place of the used byte. The following byte would be used next, and so on. num can be thought of as a pointer into the ivec to show which byte to start xor-ing with, the next time the function is called.

des_ofb_encrypt() is a implementation of the Output Feedback mode of DES. Its parameters are the same as those of des_cfb_encrypt() except that there is no < b>argument; encryption and decryption use the same arguments. in and out must be multiples of numbits long, numbits should be a multiple of 8 bits, and if it is not, the same padding factor comes into play.

Note that there is no enc parameter; this algorithm functions the same for encryption and decryption.

des_ofb64_encrypt() implements the Output Feedback Mode of DES, with 64 bit feedback. The arguments are the same as for des_cfb64_encrypt.


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲国产日韩一区| 国产精品久久久久久av福利软件 | 欧美日韩1080p| 久久久久在线| 国产精品老女人精品视频| 亚洲高清av在线| 国产综合av| 亚洲一区二区三区乱码aⅴ| 一本久久a久久精品亚洲| 麻豆国产精品va在线观看不卡 | 久久精品亚洲精品| 国产精品久久久久久久浪潮网站 | 欧美高清视频免费观看| 久久婷婷一区| 国产色爱av资源综合区| 亚洲一二三区精品| 亚洲欧美日韩在线综合| 欧美日韩中文字幕在线视频| 亚洲国产精品久久人人爱蜜臀 | 亚洲在线一区二区| 欧美日韩妖精视频| 日韩午夜av在线| 国产精品99久久久久久久久久久久| 欧美成年人网站| 亚洲日本va在线观看| 99精品福利视频| 欧美日韩日日夜夜| 99国内精品| 午夜在线不卡| 国产亚洲高清视频| 欧美自拍偷拍午夜视频| 久热精品视频在线观看一区| 精品动漫3d一区二区三区免费| 久久久欧美精品| 欧美国产日韩亚洲一区| 亚洲欧洲中文日韩久久av乱码| 欧美不卡一区| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美一区二区三区的| 久久久久99| 亚洲大胆在线| 欧美精彩视频一区二区三区| 99精品国产99久久久久久福利| 香蕉久久精品日日躁夜夜躁| 国产亚洲aⅴaaaaaa毛片| 久久久成人精品| 亚洲国产精品悠悠久久琪琪 | 在线日韩av片| 欧美激情第二页| 一区二区三区视频在线看| 欧美在线日韩精品| 亚洲人体影院| 国产精品毛片a∨一区二区三区| 午夜精品美女久久久久av福利| 裸体歌舞表演一区二区| 亚洲婷婷免费| 一区免费在线| 欧美日韩一区二区在线观看视频 | 日韩一级欧洲| 国产亚洲欧美日韩美女| 欧美精品色网| 久久精品日韩| 日韩一级黄色片| 免费在线成人av| 亚洲尤物视频在线| 亚洲高清自拍| 国产精品日日摸夜夜摸av| 久久理论片午夜琪琪电影网| av成人国产| 亚洲第一区中文99精品| 欧美一区成人| 亚洲精品国精品久久99热| 国产日韩欧美麻豆| 欧美日韩精品免费观看视一区二区| 欧美一区二区三区日韩| 日韩午夜精品| 欧美成人a∨高清免费观看| 香蕉成人久久| 亚洲色在线视频| 亚洲激情一区二区三区| 国产一区二区三区四区三区四| 欧美日韩国产在线播放| 久久嫩草精品久久久精品一| 在线综合亚洲| 亚洲精品一二区| 亚洲国产欧美一区二区三区久久| 久久久精品网| 欧美一区亚洲二区| 亚洲影视综合| 一区二区三区四区蜜桃| 亚洲精品美女在线| 伊人色综合久久天天五月婷| 国产片一区二区| 国产精品二区三区四区| 欧美日本三级| 欧美顶级少妇做爰| 久久久久久一区| 欧美有码在线视频| 午夜久久久久久久久久一区二区| 一区二区三区欧美视频| 99精品国产99久久久久久福利| 亚洲精品久久久久久一区二区| 欧美大片免费| 亚洲国产二区| 91久久精品美女| 亚洲人在线视频| 亚洲精品资源| 艳妇臀荡乳欲伦亚洲一区| 亚洲日本久久| 亚洲久久视频| 亚洲一二三区精品| 午夜精品福利一区二区三区av| 亚洲在线观看视频| 欧美在线视频二区| 久久久久9999亚洲精品| 久久噜噜噜精品国产亚洲综合| 久久深夜福利免费观看| 看片网站欧美日韩| 欧美精品在欧美一区二区少妇| 欧美日韩亚洲高清| 国产精品国产一区二区| 国产伦精品免费视频| 激情视频一区二区| 亚洲欧洲一区| 亚洲午夜一区| 欧美一区亚洲二区| 欧美成人精品一区二区| 亚洲欧洲偷拍精品| 在线亚洲免费| 欧美在线视频日韩| 欧美成在线视频| 国产精品海角社区在线观看| 国产农村妇女精品一二区| **欧美日韩vr在线| 亚洲天堂黄色| 久久久精品一品道一区| 亚洲大片在线观看| 亚洲色在线视频| 久久久国产精品一区| 欧美精品网站| 国产一区二区黄| 日韩网站在线观看| 欧美在线综合| 亚洲激情黄色| 午夜精品网站| 欧美激情91| 精品动漫3d一区二区三区免费版 | 亚洲一区二区三| 久热精品视频在线观看| 欧美精品七区| 国产最新精品精品你懂的| 亚洲精品欧洲| 久久亚洲欧洲| 一二三区精品| 欧美va亚洲va日韩∨a综合色| 国产精品久久久久久超碰| 亚洲第一福利视频| 销魂美女一区二区三区视频在线| 亚洲第一页自拍| 久久精品人人做人人综合 | 久久激五月天综合精品| 亚洲国产美国国产综合一区二区| 亚洲综合精品一区二区| 欧美精品成人91久久久久久久| 国产一级揄自揄精品视频| 在线亚洲美日韩| 欧美国产综合视频| 久久国产精品99久久久久久老狼| 欧美日韩免费| 亚洲黑丝在线| 欧美 日韩 国产一区二区在线视频 | 久久国产精品色婷婷| 欧美日韩伦理在线| 亚洲区在线播放| 免费不卡欧美自拍视频| 亚洲欧美激情一区| 国产精品免费久久久久久| 一区二区三区**美女毛片| 欧美激情网站在线观看| 久久中文欧美| 亚洲第一天堂无码专区| 久久久亚洲一区| 午夜视频在线观看一区| 国产精品一二三视频| 性欧美1819性猛交| 亚洲一级免费视频| 国产精品高潮粉嫩av| 亚洲免费网址| 亚洲伊人色欲综合网| 国产精品久久久久一区二区三区 | 欧美激情综合色| 久久天天狠狠| 亚洲国产欧美日韩另类综合| 欧美88av| 男女av一区三区二区色多| 亚洲欧洲精品一区二区三区波多野1战4 | 免费成人激情视频| 亚洲黄色成人久久久| 亚洲高清三级视频| 欧美激情欧美狂野欧美精品|