亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? des.c

?? smartcard的des程序 加密方面的內容
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
   This is a 'C' implementation of the National Bureau of Statistics
   Data Encryption Standard.

   All attempts have been made to use standard C facilities to maintain
   transportability.

   The DES procedure accepts 64-bits of data, 64-bits of key, an
   indication of whether the required function is an ENCRYPT or DECRYPT,
   and a 52 word work area.

   The output from the DES procedure is the data (which is now
   ENCRYPTed or DECRYPTed according to the input parameters).

   The work area is used for efficiency reasons, and may be used to avoid
   recalculating the subkeys if a single key is used repeatedly (as is the
   case in MAC processing).


   C Language Function Definition :

          DES( data, key, encode, work )

          unsigned int   data[4],
                         key[4],
                         encrypt,
                         work[52];

   where the following rules apply :

   in:     data        64 bits of data to be encrypted or decrypted. The most
                       significant byte is data[0]; the least significant byte
                       is data[3].
           key         64 bits of encryption key. This routine does not check
                       the parity of the key before using it; It is the
                       responsibility of the calling routine to ensure that the
                       key is in good working order.
           encrypt     FALSE (zero)     - selects a DECRYPT operation
                       TRUE  (non-zero) - selects an ENCRYPT operation
           work        This area is used to store the sub-keys for the supplied
                       key. If the same key is being used repeatedly, savings
                       can be made by eliminating the recalculation of the
                       sub-keys for each operation by passing the same work
                       area back to this function, without modifying any of the
                       work area between calls.

   out:    data        The output of the encryption or decryption process.
                       The original data is destroyed.
           key         Unchanged.
           encrypt     Unchanged.
           work        Contains the key and the subkeys from the operation
                       just performed.
                       NOTE: The work area should be zeroed if there is no need
                       to use the same key in the next operation (for security
                       reasons)
*/
/**/
/*
    Calling this routine from a C environment :

         A sample program is listed below :

*/
#include <stdio.h>

#define TRUE  -1
#define FALSE 0

#if 1
unsigned int key[] = { 0x0000, 0x0000, 0x0000, 0x0000 },
	     data[]= { 0x3131, 0x3131, 0x3131, 0x3131 },
	     work[52];

#endif
#if 0
unsigned int key[] = { 0x3131, 0x3131, 0x3131, 0x3131 },
	     data[]= { 0x3131, 0x3131, 0x3131, 0x3131 },
	     work[52];

#endif
#if 0
unsigned int key[] = { 0x0123, 0x4567, 0x89ab, 0xcdef },
	     data[]= { 0x4e6f, 0x7720, 0x6973, 0x2074 },
	     work[52];
#endif
void DES( unsigned int* text, unsigned int* key, unsigned int encrypt, unsigned int* work);

void ROL8(unsigned int* text)
{
    unsigned char t;

	t=text[0]>>8;
	text[0]=text[0]<<8|text[1]>>8;
	text[1]=text[1]<<8|text[2]>>8;
	text[2]=text[2]<<8|text[3]>>8;
	text[3]=text[3]<<8|t;
}

void ROR8(unsigned int* text)
{
    unsigned t;

	t=(text[3]&0xff)<<8;
	text[3]=text[3]>>8|text[2]<<8;
	text[2]=text[2]>>8|text[1]<<8;
	text[1]=text[1]>>8|text[0]<<8;
	text[0]=text[0]>>8|t;
}

void XOR(unsigned int* text1, unsigned int* text2)
{
	text1[0]=text1[0]^text2[0];
	text1[1]=text1[1]^text2[1];
	text1[2]=text1[2]^text2[2];
	text1[3]=text1[3]^text2[3];
}

void main (void)
{
  int i,j;
  char str[50];
  unsigned int RandA[] = {0x1212, 0x1212, 0x1212, 0x1212};
  unsigned int RandB[] = {0x0000, 0x0000, 0x0000, 0x0000};

  printf("Key=  %04X%04X%04X%04X\n", key[0], key[1], key[2], key[3]);
  printf("Data: ");
  gets(str);
  if (strlen(str)==16) {
	  for (i=0; i<4; i++) {
		j=3-i;
	    sscanf(&str[j*4],"%04x",data+j);
		str[j*4]='\0';
	  }
  }

#if 0
	printf("DES(RANDB)  =%04X%04X%04X%04X\n", data[0], data[1], data[2], data[3]);
	DES(data, key, FALSE, work);
	printf("      RANDB =%04X%04X%04X%04X\n", data[0], data[1], data[2], data[3]);
	ROL8(data);
	printf("ROL8(RANDB) =%04X%04X%04X%04X\n", data[0], data[1], data[2], data[3]);

	printf("RANDA=%04X%04X%04X%04X\n", RandA[0], RandA[1], RandA[2], RandA[3]);
	DES(RandA, key, TRUE, work);
	printf("block1=%04X%04X%04X%04X\n", RandA[0], RandA[1], RandA[2], RandA[3]);
	XOR(data,RandA);
	printf("XOR =%04X%04X%04X%04X\n", data[0], data[1], data[2], data[3]);
	DES(data, key, FALSE, work);
	printf("block2=%04X%04X%04X%04X\n", data[0], data[1], data[2], data[3]);
	printf("Challenge=%04X%04X%04X%04X%04X%04X%04X%04X\n",
		RandA[0], RandA[1], RandA[2], RandA[3],
		data[0], data[1], data[2], data[3]);

	printf("Response: ");
	gets(str);
	if (strlen(str)==16) {
		for (i=0; i<4; i++) {
			j=3-i;
			sscanf(&str[j*4],"%04x",data+j);
			str[j*4]='\0';
			}
	}
	DES(data, key, FALSE, work);
	printf("DES-1(RESP)=%04X%04X%04X%04X\n", data[0], data[1], data[2], data[3]);

#else

  printf( "   Plain Text          Cipher Text        Decipher text \n" );
  printf( "----------------    ----------------    ----------------\n" );

  printf( "%04X%04X%04X%04X    ", data[0], data[1], data[2], data[3] );

  DES( data, key, TRUE, work );

  printf( "%04X%04X%04X%04X    ", data[0], data[1], data[2], data[3] );

  DES( data, key, FALSE, work );
  DES( data, key, FALSE, work );

  printf( "%04X%04X%04X%04X\n", data[0], data[1], data[2], data[3] );
#endif
}
/*
     The output should look like


        Plain Text          Cipher Text        Decipher text
     ----------------    ----------------    ----------------
     4E6F772069732074    3FA40E8A984D4815    4E6F772069732074




   Calling this function from a non-C environment :

         In C, when an array is passed as an argument, the address of the
         start of the array is placed on the stack. When an int value is
         passed as a parameter, the value of that variable is placed on the
         stack.

         For this function, there will be three addresses ( for data, key,
         and work) and one value ( for encrypt ).

         It is necessary to establish exactly how the C compiler used to
         compile this function expects to see the parameters on the stack
         before being able to call this function from any non-C environment.


*/
/**/

/*
   Offsets to tranformation rules
 */
#define IP       0   /* Initial Permutation         64 * 64   */
#define IP_1    65   /* Inverse Initial Permutation 64 * 64   */
#define E      130   /* E Function                  32 * 48   */
#define P      179   /* P Function                  32 * 32   */
#define PC1A   212   /* Permutation Choice 1 - C0   64 * 28   */
#define PC1B   245   /* Permutation Choice 1 - D0   64 * 28   */
#define PC2    278   /* Permutation Choice 2        56 * 48   */

/*
   General defines
 */
#define TRUE  -1
#define FALSE 0

typedef unsigned char byte;     /* If not defined as standard */

/*
   The Microsoft C compiler will only support 8 parameters, so the
   tform macro has been split into two separate macros. The net effect
   is the same
 */
#define tform1(a,b,c,d,e,f,g,h)  a-1, b-1, c-1, d-1, e-1, f-1, g-1, h-1,
#define tform2(a,b,c,d,e,f,g,h)  a-1, b-1, c-1, d-1, e-1, f-1, g-1, h-1 | 0x80,

/**/
static byte rules[] =  {
/* 0    Initial Permutation             64 * 64            */
tform1( 58, 50, 42, 34, 26, 18, 10,  2)tform2( 60, 52, 44, 36, 28, 20, 12,  4)
tform1( 62, 54, 46, 38, 30, 22, 14,  6)tform2( 64, 56, 48, 40, 32, 24, 16,  8)
tform1( 57, 49, 41, 33, 25, 17,  9,  1)tform2( 59, 51, 43, 35, 27, 19, 11,  3)
tform1( 61, 53, 45, 37, 29, 21, 13,  5)tform2( 63, 55, 47, 39, 31, 23, 15,  7)
0xFF,
/* 65   Inverse Initial Permutation     64 * 64            */
tform1( 40,  8, 48, 16, 56, 24, 64, 32)tform2( 39,  7, 47, 15, 55, 23, 63, 31)
tform1( 38,  6, 46, 14, 54, 22, 62, 30)tform2( 37,  5, 45, 13, 53, 21, 61, 29)
tform1( 36,  4, 44, 12, 52, 20, 60, 28)tform2( 35,  3, 43, 11, 51, 19, 59, 27)
tform1( 34,  2, 42, 10, 50, 18, 58, 26)tform2( 33,  1, 41,  9, 49, 17, 57, 25)
0xFF,
/* 130  E Function                      32 * 48            */
tform1( 32,  1,  2,  3,  4,  5,  4,  5)tform2(  6,  7,  8,  9,  8,  9, 10, 11)
tform1( 12, 13, 12, 13, 14, 15, 16, 17)tform2( 16, 17, 18, 19, 20, 21, 20, 21)
tform1( 22, 23, 24, 25, 24, 25, 26, 27)tform2( 28, 29, 28, 29, 30, 31, 32,  1)
0xFF,
/* 179  P Function                      32 * 32            */
tform1( 16,  7, 20, 21, 29, 12, 28, 17)tform2(  1, 15, 23, 26,  5, 18, 31, 10)
tform1(  2,  8, 24, 14, 32, 27,  3,  9)tform2( 19, 13, 30,  6, 22, 11,  4, 25)
0xFF,
/* 212  Permutation Choice 1 - C0       64 * 28            */
tform1( 57, 49, 41, 33, 25, 17,  9,  1)tform2( 58, 50, 42, 34, 26, 18, 10,  2)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美在线影院| 日韩欧美在线综合网| 欧美久久久久久蜜桃| 久久综合一区二区| 亚洲综合在线视频| 国产成人福利片| 在线综合视频播放| 国产精品全国免费观看高清 | 欧美私人免费视频| 久久久久久久久岛国免费| 香蕉久久夜色精品国产使用方法| 国产成人综合在线播放| 在线播放亚洲一区| 亚洲一区视频在线观看视频| 高清不卡在线观看av| 日韩精品在线看片z| 日韩va亚洲va欧美va久久| 91在线视频播放地址| 国产欧美日韩精品在线| 麻豆91在线看| 欧美一区二区三级| 午夜精品成人在线视频| 在线区一区二视频| 一区二区三区四区不卡视频 | 久久综合久久99| 日韩电影一区二区三区四区| 欧美亚洲另类激情小说| 一区二区高清视频在线观看| 成人毛片老司机大片| 欧美国产精品中文字幕| 国产一二精品视频| 久久久久国色av免费看影院| 狠狠色综合色综合网络| 久久一区二区视频| 国产麻豆精品在线| 国产欧美日韩卡一| 97精品超碰一区二区三区| 99re6这里只有精品视频在线观看| av午夜精品一区二区三区| 奇米影视在线99精品| 在线不卡一区二区| 五月激情丁香一区二区三区| 久久午夜色播影院免费高清| 日韩电影在线观看电影| 91首页免费视频| 亚洲欧美欧美一区二区三区| 粉嫩在线一区二区三区视频| 欧美性高清videossexo| 久久精品水蜜桃av综合天堂| 成人免费看黄yyy456| 91国产精品成人| 国产日产欧产精品推荐色| 国产suv精品一区二区三区| 国产日韩欧美精品一区| 91九色02白丝porn| 国产精品亚洲专一区二区三区| 欧美日本一道本在线视频| 亚洲精品免费在线观看| 国产精品系列在线播放| 欧美不卡一区二区三区| 国产高清成人在线| 日韩avvvv在线播放| 中文字幕一区不卡| 国产高清精品在线| 88在线观看91蜜桃国自产| 欧美肥妇毛茸茸| 91精品国产乱| 欧美经典一区二区| 毛片不卡一区二区| 国产拍欧美日韩视频二区| 欧美性猛交xxxx黑人交| 国产成人精品一区二区三区四区| 中文字幕综合网| 久久综合狠狠综合久久激情 | 老司机精品视频一区二区三区| 久久久久国产精品厨房| 国产高清一区日本| 日本成人在线一区| 欧美日韩一区二区三区不卡| 又紧又大又爽精品一区二区| 成人av网址在线| 亚洲少妇中出一区| 在线影视一区二区三区| 亚洲一区视频在线观看视频| 在线免费不卡视频| 亚洲影视在线观看| 91精品国产综合久久精品| 男男视频亚洲欧美| 久久伊人中文字幕| 成年人国产精品| 亚洲激情图片qvod| 在线播放/欧美激情| 久久99精品国产麻豆婷婷| 精品国产百合女同互慰| 国产成人精品1024| 一区二区三区精品在线| 欧美美女网站色| 韩国女主播一区| 中文字幕欧美国产| 欧美在线观看视频一区二区三区| 亚洲成人动漫av| 久久亚洲精精品中文字幕早川悠里 | 国产精品第一页第二页第三页| 成人免费毛片片v| 亚洲国产精品一区二区久久| 6080国产精品一区二区| 国产精品自在在线| 亚洲免费三区一区二区| 日韩一区二区视频在线观看| 国产精品一区二区黑丝| 一区二区三国产精华液| 精品乱码亚洲一区二区不卡| 99视频在线精品| 日本午夜精品视频在线观看| 国产精品乱子久久久久| 欧美日韩免费观看一区二区三区| 激情欧美日韩一区二区| 亚洲精品视频自拍| 精品国产髙清在线看国产毛片| 99视频精品全部免费在线| 青青青爽久久午夜综合久久午夜 | 色成人在线视频| 裸体一区二区三区| 亚洲国产毛片aaaaa无费看 | 亚洲免费毛片网站| 久久一区二区三区四区| 欧美性受xxxx黑人xyx性爽| 国产一区二区主播在线| 性做久久久久久久免费看| 欧美国产精品一区二区| 日韩午夜在线影院| 欧美无砖专区一中文字| 成人h精品动漫一区二区三区| 日韩av在线发布| 亚洲一区二区五区| 亚洲精品视频免费观看| 中文字幕av不卡| 久久你懂得1024| 精品少妇一区二区三区在线视频| 91激情五月电影| 波波电影院一区二区三区| 国产伦精品一区二区三区视频青涩| 图片区小说区国产精品视频 | 91成人免费网站| 成人av影院在线| 国产传媒欧美日韩成人| 久久精品国产精品青草| 奇米精品一区二区三区四区 | 精品sm捆绑视频| 日韩欧美中文字幕制服| 91精品国产黑色紧身裤美女| 欧美精品黑人性xxxx| 欧美精品三级日韩久久| 在线91免费看| 日韩一本二本av| 精品成人一区二区三区四区| 欧美一区二区三区成人| 欧美一级片在线| 精品乱人伦一区二区三区| 精品国产伦一区二区三区观看体验| 欧美一级高清片| 精品国产免费视频| 久久精品视频免费| 中文字幕一区免费在线观看| 亚洲欧美在线观看| 一区二区三区蜜桃| 五月天激情综合网| 精品一区二区三区免费观看 | 亚洲高清免费观看| 日韩在线一二三区| 蜜臀av国产精品久久久久| 久久99精品久久久久久久久久久久| 久久99久久99小草精品免视看| 久久99国产精品成人| 国产成人免费9x9x人网站视频| 不卡在线观看av| 在线视频国产一区| 欧美大黄免费观看| 国产精品久久国产精麻豆99网站 | 8v天堂国产在线一区二区| 日韩一区二区电影网| 欧美国产精品v| 亚洲一区二区三区自拍| 蜜乳av一区二区三区| 成人激情文学综合网| 欧美性生活久久| 26uuuu精品一区二区| 亚洲欧美日韩中文播放| 免费三级欧美电影| 91网页版在线| 精品国产免费久久| 亚洲国产欧美一区二区三区丁香婷| 久久99蜜桃精品| 91色婷婷久久久久合中文| 日韩视频免费观看高清完整版在线观看 | 亚洲激情五月婷婷| 国产伦精品一区二区三区视频青涩| 色婷婷精品大在线视频| 久久久久久免费网| 日韩精品亚洲一区二区三区免费|