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

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

?? lib_cast.c

?? 提供了很多種加密算法和CA認證及相關服務如CMP、OCSP等的開發
?? C
字號:
/****************************************************************************
*																			*
*					  cryptlib CAST-128 Encryption Routines					*
*						Copyright Peter Gutmann 1996-1997					*
*																			*
****************************************************************************/

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "crypt.h"
#include "cryptctx.h"
#ifdef INC_ALL
  #include "cast.h"
#else
  #include "crypt/cast.h"
#endif /* Compiler-specific includes */

/* Defines to map from EAY to native naming */

#define CAST_BLOCKSIZE		CAST_BLOCK

/* The size of the keyscheduled CAST key */

#define CAST_EXPANDED_KEYSIZE	sizeof( CAST_KEY )

/****************************************************************************
*																			*
*								CAST Self-test Routines						*
*																			*
****************************************************************************/

/* CAST test vectors from CAST specification */

static struct CAST_TEST {
	BYTE key[ CAST_KEY_LENGTH ];
	BYTE plainText[ CAST_BLOCKSIZE ];
	BYTE cipherText[ CAST_BLOCKSIZE ];
	} testCAST[] = {
	{ { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
		0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A },
	  { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
	  { 0x23, 0x8B, 0x4F, 0xE5, 0x84, 0x7E, 0x44, 0xB2 } }
	};

/* Test the CAST code against the CAST test vectors */

int castSelfTest( void )
	{
	BYTE temp[ CAST_BLOCKSIZE ];
	CAST_KEY castKey;
	int i;

	for( i = 0; i < sizeof( testCAST ) / sizeof( struct CAST_TEST ); i++ )
		{
		memcpy( temp, testCAST[ i ].plainText, CAST_BLOCKSIZE );
		CAST_set_key( &castKey, CAST_KEY_LENGTH, testCAST[ i ].key );
		CAST_ecb_encrypt( temp, temp, &castKey, CAST_ENCRYPT );
		if( memcmp( testCAST[ i ].cipherText, temp, CAST_BLOCKSIZE ) )
			return( CRYPT_ERROR );
		}

	return( CRYPT_OK );
	}

/****************************************************************************
*																			*
*							Init/Shutdown Routines							*
*																			*
****************************************************************************/

/* Perform init and shutdown actions on an encryption context */

int castInit( CRYPT_INFO *cryptInfo )
	{
	int status;

	/* Allocate memory for the key and the algorithm-specific data within
	   the crypt context and set up any pointers we need */
	if( ( status = krnlMemalloc( &cryptInfo->ctxConv.key, CAST_EXPANDED_KEYSIZE ) ) != CRYPT_OK )
		return( status );
	cryptInfo->ctxConv.keyLength = CAST_EXPANDED_KEYSIZE;

	return( CRYPT_OK );
	}

int castEnd( CRYPT_INFO *cryptInfo )
	{
	/* Free any allocated memory */
	krnlMemfree( &cryptInfo->ctxConv.key );

	return( CRYPT_OK );
	}

/****************************************************************************
*																			*
*							CAST En/Decryption Routines						*
*																			*
****************************************************************************/

/* Encrypt/decrypt data in ECB mode */

int castEncryptECB( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
	int blockCount = noBytes / CAST_BLOCKSIZE;

	while( blockCount-- )
		{
		/* Encrypt a block of data */
		CAST_ecb_encrypt( buffer, buffer, cryptInfo->ctxConv.key, CAST_ENCRYPT );

		/* Move on to next block of data */
		buffer += CAST_BLOCKSIZE;
		}

	return( CRYPT_OK );
	}

int castDecryptECB( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
	int blockCount = noBytes / CAST_BLOCKSIZE;

	while( blockCount-- )
		{
		/* Decrypt a block of data */
		CAST_ecb_encrypt( buffer, buffer, cryptInfo->ctxConv.key, CAST_DECRYPT );

		/* Move on to next block of data */
		buffer += CAST_BLOCKSIZE;
		}

	return( CRYPT_OK );
	}

/* Encrypt/decrypt data in CBC mode */

int castEncryptCBC( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
#if 0
#ifdef ASM_X86
	if( noBytes )	/* CAST asm code doesn't like 0-length blocks */
		castEncryptCBC86( buffer, buffer, noBytes, cryptInfo->ctxConv.key,
						  cryptInfo->ctxConv.currentIV );
#else
	int blockCount = noBytes / CAST_BLOCKSIZE;

	while( blockCount-- )
		{
		int i;

		/* XOR the buffer contents with the IV */
		for( i = 0; i < CAST_BLOCKSIZE; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i ];

		/* Encrypt a block of data */
		CAST_ecb_encrypt( buffer, buffer, cryptInfo->ctxConv.key, CAST_ENCRYPT );

		/* Shift ciphertext into IV */
		memcpy( cryptInfo->ctxConv.currentIV, buffer, CAST_BLOCKSIZE );

		/* Move on to next block of data */
		buffer += CAST_BLOCKSIZE;
		}
#endif /* ASM_X86 */
#endif
	CAST_cbc_encrypt( buffer, buffer, noBytes, cryptInfo->ctxConv.key,
					  cryptInfo->ctxConv.currentIV, CAST_ENCRYPT );

	return( CRYPT_OK );
	}

int castDecryptCBC( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
#if 0
#ifdef ASM_X86
	if( noBytes )	/* CAST asm code doesn't like 0-length blocks */
		castDecryptCBC86( buffer, buffer, noBytes, cryptInfo->ctxConv.key,
						  cryptInfo->ctxConv.currentIV );
#else
	BYTE temp[ CAST_BLOCKSIZE ];
	int blockCount = noBytes / CAST_BLOCKSIZE;

	while( blockCount-- )
		{
		int i;

		/* Save the ciphertext */
		memcpy( temp, buffer, CAST_BLOCKSIZE );

		/* Decrypt a block of data */
		CAST_ecb_encrypt( buffer, buffer, cryptInfo->ctxConv.key, CAST_DECRYPT );

		/* XOR the buffer contents with the IV */
		for( i = 0; i < CAST_BLOCKSIZE; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i ];

		/* Shift the ciphertext into the IV */
		memcpy( cryptInfo->ctxConv.currentIV, temp, CAST_BLOCKSIZE );

		/* Move on to next block of data */
		buffer += CAST_BLOCKSIZE;
		}

	/* Clear the temporary buffer */
	zeroise( temp, CAST_BLOCKSIZE );
#endif /* ASM_X86 */
#endif
	CAST_cbc_encrypt( buffer, buffer, noBytes, cryptInfo->ctxConv.key,
					  cryptInfo->ctxConv.currentIV, CAST_DECRYPT );

	return( CRYPT_OK );
	}

/* Encrypt/decrypt data in CFB mode */

int castEncryptCFB( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
	int i, ivCount = cryptInfo->ctxConv.ivCount;

	/* If there's any encrypted material left in the IV, use it now */
	if( ivCount )
		{
		int bytesToUse;

		/* Find out how much material left in the encrypted IV we can use */
		bytesToUse = CAST_BLOCKSIZE - ivCount;
		if( noBytes < bytesToUse )
			bytesToUse = noBytes;

		/* Encrypt the data */
		for( i = 0; i < bytesToUse; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i + ivCount ];
		memcpy( cryptInfo->ctxConv.currentIV + ivCount, buffer, bytesToUse );

		/* Adjust the byte count and buffer position */
		noBytes -= bytesToUse;
		buffer += bytesToUse;
		ivCount += bytesToUse;
		}

	while( noBytes )
		{
		ivCount = ( noBytes > CAST_BLOCKSIZE ) ? CAST_BLOCKSIZE : noBytes;

		/* Encrypt the IV */
		CAST_ecb_encrypt( cryptInfo->ctxConv.currentIV,
						  cryptInfo->ctxConv.currentIV,
						  cryptInfo->ctxConv.key,
						  CAST_ENCRYPT );

		/* XOR the buffer contents with the encrypted IV */
		for( i = 0; i < ivCount; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i ];

		/* Shift the ciphertext into the IV */
		memcpy( cryptInfo->ctxConv.currentIV, buffer, ivCount );

		/* Move on to next block of data */
		noBytes -= ivCount;
		buffer += ivCount;
		}

	/* Remember how much of the IV is still available for use */
	cryptInfo->ctxConv.ivCount = ( ivCount % CAST_BLOCKSIZE );

	return( CRYPT_OK );
	}

/* Decrypt data in CFB mode.  Note that the transformation can be made
   faster (but less clear) with temp = buffer, buffer ^= iv, iv = temp
   all in one loop */

int castDecryptCFB( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
	BYTE temp[ CAST_BLOCKSIZE ];
	int i, ivCount = cryptInfo->ctxConv.ivCount;

	/* If there's any encrypted material left in the IV, use it now */
	if( ivCount )
		{
		int bytesToUse;

		/* Find out how much material left in the encrypted IV we can use */
		bytesToUse = CAST_BLOCKSIZE - ivCount;
		if( noBytes < bytesToUse )
			bytesToUse = noBytes;

		/* Decrypt the data */
		memcpy( temp, buffer, bytesToUse );
		for( i = 0; i < bytesToUse; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i + ivCount ];
		memcpy( cryptInfo->ctxConv.currentIV + ivCount, temp, bytesToUse );

		/* Adjust the byte count and buffer position */
		noBytes -= bytesToUse;
		buffer += bytesToUse;
		ivCount += bytesToUse;
		}

	while( noBytes )
		{
		ivCount = ( noBytes > CAST_BLOCKSIZE ) ? CAST_BLOCKSIZE : noBytes;

		/* Encrypt the IV */
		CAST_ecb_encrypt( cryptInfo->ctxConv.currentIV,
						  cryptInfo->ctxConv.currentIV,
						  cryptInfo->ctxConv.key, CAST_ENCRYPT );

		/* Save the ciphertext */
		memcpy( temp, buffer, ivCount );

		/* XOR the buffer contents with the encrypted IV */
		for( i = 0; i < ivCount; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i ];

		/* Shift the ciphertext into the IV */
		memcpy( cryptInfo->ctxConv.currentIV, temp, ivCount );

		/* Move on to next block of data */
		noBytes -= ivCount;
		buffer += ivCount;
		}

	/* Remember how much of the IV is still available for use */
	cryptInfo->ctxConv.ivCount = ( ivCount % CAST_BLOCKSIZE );

	/* Clear the temporary buffer */
	zeroise( temp, CAST_BLOCKSIZE );

	return( CRYPT_OK );
	}

/* Encrypt/decrypt data in OFB mode */

int castEncryptOFB( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
	int i, ivCount = cryptInfo->ctxConv.ivCount;

	/* If there's any encrypted material left in the IV, use it now */
	if( ivCount )
		{
		int bytesToUse;

		/* Find out how much material left in the encrypted IV we can use */
		bytesToUse = CAST_BLOCKSIZE - ivCount;
		if( noBytes < bytesToUse )
			bytesToUse = noBytes;

		/* Encrypt the data */
		for( i = 0; i < bytesToUse; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i + ivCount ];

		/* Adjust the byte count and buffer position */
		noBytes -= bytesToUse;
		buffer += bytesToUse;
		ivCount += bytesToUse;
		}

	while( noBytes )
		{
		ivCount = ( noBytes > CAST_BLOCKSIZE ) ? CAST_BLOCKSIZE : noBytes;

		/* Encrypt the IV */
		CAST_ecb_encrypt( cryptInfo->ctxConv.currentIV,
						  cryptInfo->ctxConv.currentIV,
						  cryptInfo->ctxConv.key, CAST_ENCRYPT );

		/* XOR the buffer contents with the encrypted IV */
		for( i = 0; i < ivCount; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i ];

		/* Move on to next block of data */
		noBytes -= ivCount;
		buffer += ivCount;
		}

	/* Remember how much of the IV is still available for use */
	cryptInfo->ctxConv.ivCount = ( ivCount % CAST_BLOCKSIZE );

	return( CRYPT_OK );
	}

/* Decrypt data in OFB mode */

int castDecryptOFB( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
	int i, ivCount = cryptInfo->ctxConv.ivCount;

	/* If there's any encrypted material left in the IV, use it now */
	if( ivCount )
		{
		int bytesToUse;

		/* Find out how much material left in the encrypted IV we can use */
		bytesToUse = CAST_BLOCKSIZE - ivCount;
		if( noBytes < bytesToUse )
			bytesToUse = noBytes;

		/* Decrypt the data */
		for( i = 0; i < bytesToUse; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i + ivCount ];

		/* Adjust the byte count and buffer position */
		noBytes -= bytesToUse;
		buffer += bytesToUse;
		ivCount += bytesToUse;
		}

	while( noBytes )
		{
		ivCount = ( noBytes > CAST_BLOCKSIZE ) ? CAST_BLOCKSIZE : noBytes;

		/* Encrypt the IV */
		CAST_ecb_encrypt( cryptInfo->ctxConv.currentIV,
						  cryptInfo->ctxConv.currentIV,
						  cryptInfo->ctxConv.key, CAST_ENCRYPT );

		/* XOR the buffer contents with the encrypted IV */
		for( i = 0; i < ivCount; i++ )
			buffer[ i ] ^= cryptInfo->ctxConv.currentIV[ i ];

		/* Move on to next block of data */
		noBytes -= ivCount;
		buffer += ivCount;
		}

	/* Remember how much of the IV is still available for use */
	cryptInfo->ctxConv.ivCount = ( ivCount % CAST_BLOCKSIZE );

	return( CRYPT_OK );
	}

/****************************************************************************
*																			*
*							CAST Key Management Routines					*
*																			*
****************************************************************************/

/* Key schedule an CAST key */

int castInitKey( CRYPT_INFO *cryptInfo, const void *key, const int keyLength )
	{
	/* Copy the key to internal storage */
	if( cryptInfo->ctxConv.userKey != key )
		memcpy( cryptInfo->ctxConv.userKey, key, keyLength );
	cryptInfo->ctxConv.userKeyLength = keyLength;

	CAST_set_key( cryptInfo->ctxConv.key, CAST_KEY_LENGTH, ( BYTE * ) key );
	return( CRYPT_OK );
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91在线观看美女| 亚洲欧美在线视频| 国产精品系列在线| 日韩国产欧美在线观看| 成人精品视频一区二区三区尤物| 欧美日韩国产天堂| 国产精品久久三| 国产精品一区二区在线观看网站| 成人黄色在线看| 欧美r级电影在线观看| 亚洲第一成年网| 91福利国产成人精品照片| 欧美国产一区在线| 国产美女精品人人做人人爽| 日韩三级伦理片妻子的秘密按摩| 亚洲午夜视频在线观看| 色综合天天综合色综合av | 亚洲综合色婷婷| 国内不卡的二区三区中文字幕| 欧美精品tushy高清| 亚洲精品第一国产综合野| 9人人澡人人爽人人精品| 国产三区在线成人av| 国产一区二区按摩在线观看| 欧美va在线播放| 久久99国产精品久久99果冻传媒| 欧美日韩成人在线| 婷婷亚洲久悠悠色悠在线播放| 欧美一级在线免费| 亚洲色图制服诱惑 | 日本色综合中文字幕| 欧美少妇bbb| 亚洲午夜久久久久久久久久久| 91久久精品午夜一区二区| 亚洲乱码国产乱码精品精的特点| 93久久精品日日躁夜夜躁欧美| 国产精品免费视频网站| 国产高清在线观看免费不卡| 中文在线一区二区| 91丨porny丨国产| 一区二区欧美视频| 欧美日韩电影一区| 麻豆精品视频在线观看视频| 久久影院午夜片一区| 国产99精品在线观看| 国产精品萝li| 在线观看www91| 秋霞午夜鲁丝一区二区老狼| 久久久久久久久一| 成人永久免费视频| 自拍偷拍国产精品| 在线不卡欧美精品一区二区三区| 美女视频黄免费的久久| 国产精品污www在线观看| 在线观看日韩电影| 日本三级亚洲精品| 国产片一区二区| 欧美系列一区二区| 国产一区二区三区在线看麻豆| 亚洲国产高清在线| 欧美日韩精品一区二区| 黄色成人免费在线| 亚洲人妖av一区二区| 欧美一区二区三区啪啪| 国产精品一卡二卡| 亚洲综合清纯丝袜自拍| 久久久久成人黄色影片| 色婷婷国产精品| 国产精品综合一区二区| 一区二区三区中文在线| 欧美一级二级在线观看| 91视视频在线观看入口直接观看www | 国产精品美女一区二区三区| 欧美视频在线观看一区| 国产精品 欧美精品| 亚洲综合激情另类小说区| 精品电影一区二区| 精品视频一区二区三区免费| 从欧美一区二区三区| 天堂一区二区在线| 自拍偷拍亚洲综合| 久久精品欧美日韩精品| 欧美一级片在线看| 欧美日韩一区二区在线观看| 成人激情开心网| 极品少妇xxxx偷拍精品少妇| 亚洲永久免费视频| 国产精品欧美精品| 精品伦理精品一区| 欧美老年两性高潮| 色综合一个色综合亚洲| 不卡的av在线| 成人在线视频一区二区| 韩国三级在线一区| 日本午夜精品一区二区三区电影 | 国产欧美一区二区三区网站 | 国产精品美女久久久久av爽李琼| 欧美一区二区网站| 精品视频在线免费看| 91久久精品一区二区三| 97精品久久久久中文字幕| 国产精品亚洲一区二区三区在线| 日本在线观看不卡视频| 亚洲成人免费在线| 亚洲国产视频在线| 一区二区成人在线| 亚洲影视在线播放| 亚洲福利视频导航| 亚洲国产人成综合网站| 一区av在线播放| 亚洲国产一区二区视频| 亚洲国产另类av| 午夜欧美2019年伦理| 亚洲成人自拍偷拍| 奇米综合一区二区三区精品视频| 日韩精品一二三区| 日韩国产欧美在线播放| 欧美a一区二区| 国内一区二区视频| 成人黄色大片在线观看| 国产91对白在线观看九色| 国产suv一区二区三区88区| 成人国产一区二区三区精品| av一区二区不卡| 色拍拍在线精品视频8848| 欧洲精品中文字幕| 69精品人人人人| 久久亚洲欧美国产精品乐播 | 欧美大片在线观看一区| 日韩欧美国产小视频| 337p粉嫩大胆噜噜噜噜噜91av | 国产激情精品久久久第一区二区 | 国产高清不卡一区二区| 国产99久久久久久免费看农村| 国产成人啪午夜精品网站男同| hitomi一区二区三区精品| 色先锋资源久久综合| 在线成人av网站| 久久精品亚洲麻豆av一区二区 | 国产精品五月天| 一区二区三区**美女毛片| 视频一区欧美精品| 国产白丝精品91爽爽久久| 91国产免费看| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 久久精品视频在线看| 最新国产精品久久精品| 天天综合色天天综合色h| 国产精品一区二区黑丝| 欧美亚洲综合色| 久久久亚洲高清| 亚洲综合一区二区三区| 激情久久久久久久久久久久久久久久| 成人美女视频在线观看18| 69堂成人精品免费视频| 国产精品久久久久久久久久免费看| 亚洲香肠在线观看| 成人在线视频一区| 欧美tickling网站挠脚心| 一区二区三区在线观看动漫| 国产一区二区网址| 91精品欧美一区二区三区综合在| 国产欧美精品国产国产专区| 日韩av网站在线观看| av欧美精品.com| 亚洲精品一区二区在线观看| 亚洲最新视频在线观看| 成人亚洲一区二区一| 欧美一级爆毛片| 午夜视频在线观看一区二区三区| 成人高清免费观看| 精品国产乱码久久久久久牛牛| 亚洲第一狼人社区| 色综合色综合色综合 | 精品理论电影在线观看| 亚洲一区在线看| 99久久久无码国产精品| 精品久久久久久久一区二区蜜臀| 一区二区三国产精华液| 99精品桃花视频在线观看| 国产肉丝袜一区二区| 国产一区二区三区观看| 欧美精品电影在线播放| 亚洲一卡二卡三卡四卡| 色欧美乱欧美15图片| 国产精品成人一区二区三区夜夜夜| 国产一区二区三区四| 精品日产卡一卡二卡麻豆| 全部av―极品视觉盛宴亚洲| 欧美三区免费完整视频在线观看| 亚洲精品中文在线影院| 99r国产精品| 中文字幕一区二区5566日韩| 成人免费福利片| 国产女人18水真多18精品一级做| 国产福利视频一区二区三区| 久久久久久免费网| 国产福利精品导航| 欧美国产激情二区三区 | 国产精品久久久久影院老司|