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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? lib_hsha.c

?? 提供了很多種加密算法和CA認(rèn)證及相關(guān)服務(wù)如CMP、OCSP等的開發(fā)
?? C
字號(hào):
/****************************************************************************
*																			*
*						cryptlib HMAC-SHA Hash Routines						*
*						Copyright Peter Gutmann 1997-2000					*
*																			*
****************************************************************************/

#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 "sha.h"
#else
  #include "hash/sha.h"
#endif /* Compiler-specific includes */

/* A structure to hold the initial and current MAC state info.  Rather than
   redoing the key processing each time when we're calculating multiple MACs
   with the same key, we just copy the initial state into the current state */

typedef struct {
	SHA_CTX macState, initialMacState;
	} MAC_STATE;

/****************************************************************************
*																			*
*							HMAC-SHA Self-test Routines						*
*																			*
****************************************************************************/

/* Test the HMAC-SHA output against the test vectors given in RFC ???? */

int hmacSHAInitKey( CRYPT_INFO *cryptInfo, const void *key, const int keyLength );
int hmacSHAHash( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes );

static const struct {
	const char *key;						/* HMAC key */
	const int keyLength;					/* Length of key */
	const char *data;						/* Data to hash */
	const int length;						/* Length of data */
	const BYTE digest[ SHA_DIGEST_LENGTH ];	/* Digest of data */
	} hmacValues[] = {
	{ "\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B\x0B"
	  "\x0B\x0B\x0B\x0B", 20,
	  "Hi There", 8,
	  { 0xB6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
		0xE2, 0x8B, 0xC0, 0xB6, 0xFB, 0x37, 0x8C, 0x8E,
		0xF1, 0x46, 0xBE, 0x00 } },
	{ "Jefe", 4,
		"what do ya want for nothing?", 28,
	  { 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don't do truncation */
	{ "\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C\x0C"
	  "\x0C\x0C\x0C\x0C", 20,
	  "Test With Truncation", 20,
	  { 0x4C, 0x1A, 0x03, 0x42, 0x4B, 0x55, 0xE0, 0x7F,
		0xE7, 0xF2, 0x7B, 0xE1, 0xD5, 0x8B, 0xB9, 0x32,
		0x4A, 0x9A, 0x5A, 0x04 } },
#endif /* 0 */
	{ "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", 80,
	  "Test Using Larger Than Block-Size Key - Hash Key First", 54,
	  { 0xAA, 0x4A, 0xE5, 0xE1, 0x52, 0x72, 0xD0, 0x0E,
		0x95, 0x70, 0x56, 0x37, 0xCE, 0x8A, 0x3B, 0x55,
		0xED, 0x40, 0x21, 0x12 } },
	{ "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
	  "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", 80,
	  "Test Using Larger Than Block-Size Key and Larger Than One "
	  "Block-Size Data", 73,
	  { 0xE8, 0xE9, 0x9D, 0x0F, 0x45, 0x23, 0x7D, 0x78,
		0x6D, 0x6B, 0xBA, 0xA7, 0x96, 0x5C, 0x78, 0x08,
		0xBB, 0xFF, 0x1A, 0x91 } },
	{ "", 0, NULL, 0, { 0 } }
	};

int hmacSHASelfTest( void )
	{
	CRYPT_INFO cryptInfo;
	MAC_STATE macState;
	int i;

	/* Set up the dummy cryptInfo structure */
	memset( &cryptInfo, 0, sizeof( CRYPT_INFO ) );
	cryptInfo.ctxMAC.macInfo = &macState;

	/* Test HMAC-SHA against the test vectors given in RFC ???? */
	for( i = 0; hmacValues[ i ].data != NULL; i++ )
		{
		/* Initialise the encryption context with enough information to test
		   the HMAC functionality */
		cryptInfo.ctxMAC.done = FALSE;
		SHA1_Init( &macState.macState );

		/* Load the HMAC key and perform the hashing */
		hmacSHAInitKey( &cryptInfo, hmacValues[ i ].key,
						hmacValues[ i ].keyLength );
		hmacSHAHash( &cryptInfo, ( BYTE * ) hmacValues[ i ].data,
					 hmacValues[ i ].length );
		hmacSHAHash( &cryptInfo, NULL, 0 );

		/* Retrieve the hash and make sure it matches the expected value */
		if( memcmp( cryptInfo.ctxMAC.mac, hmacValues[ i ].digest,
					SHA_DIGEST_LENGTH ) )
			break;
		}

	return( ( hmacValues[ i ].data == NULL ) ? \
			CRYPT_OK : CRYPT_ERROR );
	}

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

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

int hmacSHAInit( CRYPT_INFO *cryptInfo )
	{
	MAC_STATE *macState;
	int status;

	/* Allocate memory for the SHA context within the encryption context.
	   Since MAC contexts can be reset by deleting the MAC values, this may 
	   already have been allocated previously so we only perform the alloc
	   if it's actually required */
	if( cryptInfo->ctxMAC.macInfo == NULL )
		{
		if( ( status = krnlMemalloc( &cryptInfo->ctxMAC.macInfo,
									 sizeof( MAC_STATE ) ) ) != CRYPT_OK )
			return( status );
		macState = cryptInfo->ctxMAC.macInfo;
		SHA1_Init( &macState->macState );
		}
	else
		{
		/* Copy the initial MAC state over into the current MAC state */
		macState = cryptInfo->ctxMAC.macInfo;
		memcpy( &macState->macState, &macState->initialMacState, 
				sizeof( SHA_CTX ) );
		}

	return( CRYPT_OK );
	}

int hmacSHAEnd( CRYPT_INFO *cryptInfo )
	{
	/* Free any allocated memory */
	krnlMemfree( &cryptInfo->ctxMAC.macInfo );

	return( CRYPT_OK );
	}

/****************************************************************************
*																			*
*							HMAC-SHA Hash Routines							*
*																			*
****************************************************************************/

/* Hash data using HMAC-SHA */

int hmacSHAHash( CRYPT_INFO *cryptInfo, BYTE *buffer, int noBytes )
	{
	SHA_CTX *shaInfo = &( ( MAC_STATE * ) cryptInfo->ctxMAC.macInfo )->macState;

	/* If we've already called SHA1_Final(), we can't continue */
	if( cryptInfo->ctxMAC.done )
		return( CRYPT_ERROR_COMPLETE );

	if( !noBytes )
		{
		BYTE hashBuffer[ SHA_CBLOCK ], digestBuffer[ SHA_DIGEST_LENGTH ];
		int i;

		/* Complete the inner hash and extract the digest */
		SHA1_Final( digestBuffer, shaInfo );

		/* Perform the of the outer hash using the zero-padded key XOR'd
		   with the opad value followed by the digest from the inner hash */
		memset( hashBuffer, HMAC_OPAD, SHA_CBLOCK );
		memcpy( hashBuffer, cryptInfo->ctxMAC.userKey,
				cryptInfo->ctxMAC.userKeyLength );
		for( i = 0; i < cryptInfo->ctxMAC.userKeyLength; i++ )
			hashBuffer[ i ] ^= HMAC_OPAD;
		SHA1_Init( shaInfo );
		SHA1_Update( shaInfo, hashBuffer, SHA_CBLOCK );
		memset( hashBuffer, 0, SHA_CBLOCK );
		SHA1_Update( shaInfo, digestBuffer, SHA_DIGEST_LENGTH );
		memset( digestBuffer, 0, SHA_DIGEST_LENGTH );
		SHA1_Final( cryptInfo->ctxMAC.mac, shaInfo );
		cryptInfo->ctxMAC.done = TRUE;
		}
	else
		SHA1_Update( shaInfo, buffer, noBytes );

	return( CRYPT_OK );
	}

/****************************************************************************
*																			*
*							HMAC-SHA Key Management Routines				*
*																			*
****************************************************************************/

/* Set up an HMAC-SHA key */

int hmacSHAInitKey( CRYPT_INFO *cryptInfo, const void *key, const int keyLength )
	{
	SHA_CTX *shaInfo = &( ( MAC_STATE * ) cryptInfo->ctxMAC.macInfo )->macState;
	BYTE hashBuffer[ SHA_CBLOCK ];
	int i;

	/* If the key size is larger than tha SHA data size, reduce it to the
	   SHA hash size before processing it (yuck.  You're required to do this
	   though) */
	if( keyLength > SHA_CBLOCK )
		{
		/* Hash the user key down to the hash size (SHA1_Init() has already
		   been called when the context was created) and use the hashed form
		   of the key */
		SHA1_Update( shaInfo, ( void * ) key, keyLength );
		SHA1_Final( cryptInfo->ctxMAC.userKey, shaInfo );
		cryptInfo->ctxMAC.userKeyLength = SHA_DIGEST_LENGTH;

		/* Reset the SHA state */
		SHA1_Init( shaInfo );
		}
	else
		{
		/* Copy the key to internal storage */
		memcpy( cryptInfo->ctxMAC.userKey, key, keyLength );
		cryptInfo->ctxMAC.userKeyLength = keyLength;
		}

	/* Perform the start of the inner hash using the zero-padded key XOR'd
	   with the ipad value */
	memset( hashBuffer, HMAC_IPAD, SHA_CBLOCK );
	memcpy( hashBuffer, cryptInfo->ctxMAC.userKey,
			cryptInfo->ctxMAC.userKeyLength );
	for( i = 0; i < cryptInfo->ctxMAC.userKeyLength; i++ )
		hashBuffer[ i ] ^= HMAC_IPAD;
	SHA1_Update( shaInfo, hashBuffer, SHA_CBLOCK );
	memset( hashBuffer, 0, SHA_CBLOCK );

	/* Save a copy of the initial state in case it's needed later */
	memcpy( &( ( MAC_STATE * ) cryptInfo->ctxMAC.macInfo )->initialMacState,
			shaInfo, sizeof( SHA_CTX ) );

	return( CRYPT_OK );
	}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
肉肉av福利一精品导航| 一区二区在线观看免费| 99久久精品国产网站| 日韩国产欧美一区二区三区| 国产亚洲精品7777| 51午夜精品国产| caoporm超碰国产精品| 麻豆精品久久精品色综合| 国产精品久久看| 日韩免费观看高清完整版| 91在线精品一区二区| 国产综合久久久久影院| 亚洲一区在线观看网站| 国产精品久久久久久久久久久免费看| 欧美日本在线播放| 97成人超碰视| 国产电影精品久久禁18| 日韩高清在线观看| 一区二区三区四区激情| 国产精品妹子av| 久久夜色精品一区| 91精品国产品国语在线不卡| 在线视频一区二区三区| 99精品视频在线播放观看| 国产一区二区三区久久悠悠色av| 午夜免费久久看| 一区二区国产盗摄色噜噜| 国产精品久久久爽爽爽麻豆色哟哟| 日韩精品一区二区三区视频在线观看| 欧美日韩综合在线免费观看| 99久久亚洲一区二区三区青草| 国产精品一区二区在线播放| 蜜臀av国产精品久久久久| 日韩精品五月天| 婷婷中文字幕综合| 亚洲无人区一区| 亚洲欧美视频在线观看视频| 国产精品福利电影一区二区三区四区| 久久女同精品一区二区| 精品国偷自产国产一区| 欧美va天堂va视频va在线| 欧美一级高清大全免费观看| 91精品国产综合久久婷婷香蕉 | 精品欧美乱码久久久久久 | 国产精品欧美极品| 国产欧美综合色| 欧美激情一区二区三区不卡| 国产日产欧美一区二区三区 | 欧美激情综合五月色丁香| 国产亚洲精品免费| 中文字幕av一区二区三区高 | 中文字幕一区二区在线播放| 国产精品欧美经典| 亚洲欧洲性图库| 亚洲精品国久久99热| 一区二区三区精品| 午夜精品久久久| 男女男精品网站| 久久er精品视频| 国产精品一级黄| 99精品国产热久久91蜜凸| 99精品久久99久久久久| 欧美视频一区二区| 91精品一区二区三区久久久久久 | 99久久精品免费观看| 99精品久久久久久| 精品视频999| 欧美va亚洲va| 国产精品美女久久久久久久久久久 | 国产一区二区三区在线观看免费视频| 国产一区二区三区不卡在线观看| 丁香亚洲综合激情啪啪综合| 在线一区二区三区| 欧美精品成人一区二区三区四区| 日韩一区二区精品| 久久久国产精品麻豆| 国产精品不卡在线| 亚洲.国产.中文慕字在线| 国产一区在线视频| 91香蕉视频在线| 7777精品伊人久久久大香线蕉| 欧美精品一区二区三区蜜桃| 国产精品大尺度| 日韩av中文字幕一区二区| 国产传媒久久文化传媒| 欧美丝袜丝交足nylons| 精品福利一二区| 一区二区三区av电影| 久久99在线观看| 91首页免费视频| 欧美电视剧在线看免费| 国产精品女上位| 日本不卡123| 99re这里都是精品| 欧美v国产在线一区二区三区| 亚洲视频在线观看一区| 精品一区二区免费在线观看| 91福利视频网站| 国产亲近乱来精品视频 | 日韩中文字幕区一区有砖一区| 国产精品77777| 56国语精品自产拍在线观看| 自拍偷拍亚洲欧美日韩| 国产一区二区美女| 91精品视频网| 一区二区三区在线不卡| 国产91精品一区二区麻豆网站| 欧美一区二区三区视频在线观看| 中文字幕日韩一区二区| 国产在线一区观看| 欧美日韩在线免费视频| 国产精品久久久久久久久果冻传媒| 免费视频一区二区| 欧美视频精品在线观看| 国产精品久久久久一区二区三区| 久久99这里只有精品| 欧美日韩午夜在线| 亚洲人成网站精品片在线观看| 国产精品资源在线看| 日韩欧美中文字幕一区| 香蕉乱码成人久久天堂爱免费| 91网站黄www| 国产精品福利一区| 成人激情校园春色| 国产亚洲精品免费| 国产一区二区视频在线播放| 欧美一区二区三区精品| 午夜激情久久久| 欧美在线视频全部完| 亚洲精品综合在线| 99久久久精品| 亚洲欧美日韩人成在线播放| 成人午夜私人影院| 国产精品麻豆一区二区| 成人动漫在线一区| 欧美激情一区二区三区四区| 国产成人亚洲综合a∨猫咪| 337p粉嫩大胆色噜噜噜噜亚洲| 麻豆精品一区二区三区| 日韩精品中文字幕在线一区| 蜜臀久久久久久久| 欧美一区二区视频观看视频| 免费视频最近日韩| 欧美成人a在线| 韩国欧美国产一区| 国产欧美日韩激情| 成人激情小说乱人伦| 国产精品国产三级国产aⅴ原创| 成年人网站91| 亚洲乱码日产精品bd| 欧美午夜一区二区| 三级久久三级久久久| 欧美一区二区三区在线视频| 久久爱www久久做| 久久久久久久国产精品影院| 成人免费的视频| 亚洲久草在线视频| 欧美精品在线观看一区二区| 日本不卡123| 久久久精品国产免费观看同学| 亚洲精品一区二区三区四区高清 | 日本韩国精品一区二区在线观看| 一区二区三区精品在线观看| 欧美精品亚洲一区二区在线播放| 日本aⅴ亚洲精品中文乱码| 久久综合九色综合97婷婷女人 | 黄色日韩三级电影| 国产精品美女久久久久aⅴ| 日本福利一区二区| 美女视频网站黄色亚洲| 久久九九久精品国产免费直播| 99久久伊人精品| 亚洲成精国产精品女| 久久综合精品国产一区二区三区| 99久久免费国产| 首页欧美精品中文字幕| 国产亚洲精品bt天堂精选| 色欧美88888久久久久久影院| 三级影片在线观看欧美日韩一区二区 | 欧美精品成人一区二区三区四区| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产偷国产偷精品高清尤物| 91搞黄在线观看| 国产高清精品久久久久| 亚洲制服丝袜在线| 久久婷婷成人综合色| 91国偷自产一区二区使用方法| 精品一区二区三区的国产在线播放| 中文字幕一区二区在线播放| 91精品国模一区二区三区| 成人动漫在线一区| 美国毛片一区二区| 亚洲精品成人精品456| 亚洲精品一线二线三线| 欧美日韩国产影片| www.日韩精品| 开心九九激情九九欧美日韩精美视频电影| 国产精品国产三级国产aⅴ原创| 日韩精品一区二区在线| 欧美中文字幕一区|