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

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

?? hmac.c

?? IBM開發(fā)的TPM的驅(qū)動(dòng), 有少量的例子可以供參考
?? C
字號(hào):
/****************************************************************************//*                                                                          *//*                               HMAC routines                              *//*                                                                          *//*                           Written by J. Kravitz                          *//*                                                                          *//*                     IBM Thomas J. Watson Research Center                 *//*                                                                          *//*                               Version 1.3                                *//*                                                                          *//*                         Last Revision 23 Feb 2004                        *//*                                                                          *//*                           Copyright (C) 2004 IBM                         *//*                                                                          *//****************************************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <netinet/in.h>#include <tpm.h>#include <tpmutil.h>#include <hmac.h>#include <openssl/sha.h>#include <openssl/hmac.h>#define TPM_TAG_RSP_COMMAND       0x00C4#define TPM_TAG_RSP_AUTH1_COMMAND 0x00C5#define TPM_TAG_RSP_AUTH2_COMMAND 0x00C6/****************************************************************************//*                                                                          *//* Validate the HMAC in an AUTH1 response                                   *//*                                                                          *//* This function validates the Authorization Digest for all AUTH1           *//* responses.                                                               *//*                                                                          *//* The arguments are...                                                     *//*                                                                          *//* buffer - a pointer to response buffer                                    *//* command - the command code from the original request                     *//* ononce - a pointer to a 20 byte array containing the oddNonce            *//* key    - a pointer to the key used in the request HMAC                   *//* keylen - the size of the key                                             *//* followed by a variable length set of arguments, which must come in       *//* pairs.                                                                   *//* The first value in each pair is the length of the data in the second     *//*   argument of the pair                                                   *//* The second value in each pair is an offset in the buffer to the data     *//*   to be included in the hash for the paramdigest                         *//* There should NOT be pairs for the TPM_RESULT or TPM_COMMAND_CODE         *//* The last pair must be followed by a pair containing 0,0                  *//*                                                                          *//****************************************************************************/uint32_t TSS_checkhmac1(unsigned char *buffer, uint32_t command,			unsigned char *ononce, unsigned char *key,			unsigned int keylen, ...){	uint32_t bufsize;	uint16_t tag;	uint32_t ordinal;	uint32_t result;	unsigned char *enonce;	unsigned char *continueflag;	unsigned char *authdata;	unsigned char testhmac[20];	unsigned char paramdigest[20];	SHA_CTX sha;	unsigned int dlen;	unsigned int dpos;	va_list argp;	bufsize = LOAD32(buffer, TPM_U16_SIZE);	tag = LOAD16(buffer, 0);	ordinal = command;	result = LOAD32N(buffer, TPM_RETURN_OFFSET);	if (tag == TPM_TAG_RSP_COMMAND)		return 0;	if (tag != TPM_TAG_RSP_AUTH1_COMMAND)		return ERR_HMAC_FAIL;	authdata = buffer + bufsize - TPM_HASH_SIZE;	continueflag = authdata - 1;	enonce = continueflag - TPM_NONCE_SIZE;	SHA1_Init(&sha);	SHA1_Update(&sha, &result, 4);	SHA1_Update(&sha, &ordinal, 4);	va_start(argp, keylen);	for (;;) {		dlen = (unsigned int) va_arg(argp, unsigned int);		if (dlen == 0)			break;		dpos = (unsigned int) va_arg(argp, unsigned int);		SHA1_Update(&sha, buffer + dpos, dlen);	}	va_end(argp);	SHA1_Final(paramdigest, &sha);	TSS_rawhmac(testhmac, key, keylen, TPM_HASH_SIZE, paramdigest,		    TPM_NONCE_SIZE, enonce,		    TPM_NONCE_SIZE, ononce, 1, continueflag, 0, 0);	if (memcmp(testhmac, authdata, TPM_HASH_SIZE) != 0)		return ERR_HMAC_FAIL;	return 0;}/****************************************************************************//*                                                                          *//* Validate the HMACS in an AUTH2 response                                  *//*                                                                          *//* This function validates the Authorization Digests for all AUTH2          *//* responses.                                                               *//*                                                                          *//* The arguments are...                                                     *//*                                                                          *//* buffer - a pointer to response buffer                                    *//* command - the command code from the original request                     *//* ononce - a pointer to a 20 byte array containing the oddNonce            *//* key1    - a pointer to the 1st   key used in the request HMAC            *//* keylen1 - the size of the key                                            *//* key2    - a pointer to the 2nd   key used in the request HMAC            *//* keylen2 - the size of the key                                            *//* followed by a variable length set of arguments, which must come in       *//* pairs.                                                                   *//* The first value in each pair is the length of the data in the second     *//*   argument of the pair                                                   *//* The second value in each pair is an offset in the buffer to the data     *//*   to be included in the hash for the paramdigest                         *//* There should NOT be pairs for the TPM_RESULT or TPM_COMMAND_CODE         *//* The last pair must be followed by a pair containing 0,0                  *//*                                                                          *//****************************************************************************/uint32_t TSS_checkhmac2(unsigned char *buffer, uint32_t command,			unsigned char *ononce, unsigned char *key1,			unsigned int keylen1, unsigned char *key2,			unsigned int keylen2, ...){	uint32_t bufsize;	uint16_t tag;	uint32_t ordinal;	uint32_t result;	unsigned char *enonce1;	unsigned char *continueflag1;	unsigned char *authdata1;	unsigned char *enonce2;	unsigned char *continueflag2;	unsigned char *authdata2;	unsigned char testhmac1[20];	unsigned char paramdigest[20];	unsigned char testhmac2[20];	SHA_CTX sha;	unsigned int dlen;	unsigned int dpos;	va_list argp;	bufsize = LOAD32(buffer, TPM_U16_SIZE);	tag = LOAD16(buffer, 0);	ordinal = command;	result = LOAD32N(buffer, TPM_RETURN_OFFSET);	if (tag == TPM_TAG_RSP_COMMAND)		return 0;	if (tag != TPM_TAG_RSP_AUTH2_COMMAND)		return ERR_HMAC_FAIL;	authdata1 =	    buffer + bufsize - (TPM_HASH_SIZE + 1 + TPM_HASH_SIZE +				TPM_HASH_SIZE);	authdata2 = buffer + bufsize - (TPM_HASH_SIZE);	continueflag1 = authdata1 - 1;	continueflag2 = authdata2 - 1;	enonce1 = continueflag1 - TPM_NONCE_SIZE;	enonce2 = continueflag2 - TPM_NONCE_SIZE;	SHA1_Init(&sha);	SHA1_Update(&sha, &result, 4);	SHA1_Update(&sha, &ordinal, 4);	va_start(argp, keylen2);	for (;;) {		dlen = (unsigned int) va_arg(argp, unsigned int);		if (dlen == 0)			break;		dpos = (unsigned int) va_arg(argp, unsigned int);		SHA1_Update(&sha, buffer + dpos, dlen);	}	SHA1_Final(paramdigest, &sha);	TSS_rawhmac(testhmac1, key1, keylen1, TPM_HASH_SIZE, paramdigest,		    TPM_NONCE_SIZE, enonce1,		    TPM_NONCE_SIZE, ononce, 1, continueflag1, 0, 0);	TSS_rawhmac(testhmac2, key2, keylen2, TPM_HASH_SIZE, paramdigest,		    TPM_NONCE_SIZE, enonce2,		    TPM_NONCE_SIZE, ononce, 1, continueflag2, 0, 0);	if (memcmp(testhmac1, authdata1, TPM_HASH_SIZE) != 0)		return ERR_HMAC_FAIL;	if (memcmp(testhmac2, authdata2, TPM_HASH_SIZE) != 0)		return ERR_HMAC_FAIL;	return 0;}/****************************************************************************//*                                                                          *//* Calculate HMAC value for an AUTH1 command                                *//*                                                                          *//* This function calculates the Authorization Digest for all OIAP           *//* commands.                                                                *//*                                                                          *//* The arguments are...                                                     *//*                                                                          *//* digest - a pointer to a 20 byte array that will receive the result       *//* key    - a pointer to the key to be used in the HMAC calculation         *//* keylen - the size of the key in bytes                                    *//* h1     - a pointer to a 20 byte array containing the evenNonce           *//* h2     - a pointer to a 20 byte array containing the oddNonce            *//* h3     - an unsigned character containing the continueAuthSession value  *//* followed by a variable length set of arguments, which must come in       *//* pairs.                                                                   *//* The first value in each pair is the length of the data in the second     *//*   argument of the pair                                                   *//* The second value in each pair is a pointer to the data to be hashed      *//*   into the paramdigest.                                                  *//* The last pair must be followed by a pair containing 0,0                  *//*                                                                          *//****************************************************************************/uint32_t TSS_authhmac(unsigned char *digest, unsigned char *key,		      unsigned int keylen, unsigned char *h1,		      unsigned char *h2, unsigned char h3, ...){	unsigned char paramdigest[TPM_HASH_SIZE];	SHA_CTX sha;	unsigned int dlen;	unsigned char *data;	unsigned char c;	va_list argp;	SHA1_Init(&sha);	if (h1 == NULL || h2 == NULL)		return ERR_NULL_ARG;	c = h3;	va_start(argp, h3);	for (;;) {		dlen = (unsigned int) va_arg(argp, unsigned int);		if (dlen == 0)			break;		data = (unsigned char *) va_arg(argp, int);		if (data == NULL)			return ERR_NULL_ARG;		SHA1_Update(&sha, data, dlen);	}	va_end(argp);	SHA1_Final(paramdigest, &sha);	TSS_rawhmac(digest, key, keylen, TPM_HASH_SIZE, paramdigest,		    TPM_NONCE_SIZE, h1, TPM_NONCE_SIZE, h2, 1, &c, 0, 0);	return 0;}/****************************************************************************//*                                                                          *//* Calculate Raw HMAC value                                                 *//*                                                                          *//* This function calculates an HMAC digest                                  *//*                                                                          *//* The arguments are...                                                     *//*                                                                          *//* digest - a pointer to a 20 byte array that will receive the result       *//* key    - a pointer to the key to be used in the HMAC calculation         *//* keylen - the size of the key in bytes                                    *//* followed by a variable length set of arguments, which must come in       *//* pairs.                                                                   *//* The first value in each pair is the length of the data in the second     *//*   argument of the pair                                                   *//* The second value in each pair is a pointer to the data to be hashed      *//*   into the paramdigest.                                                  *//* The last pair must be followed by a pair containing 0,0                  *//*                                                                          *//****************************************************************************/uint32_t TSS_rawhmac(unsigned char *digest, unsigned char *key,		     unsigned int keylen, ...){	HMAC_CTX hmac;	unsigned int dlen;	unsigned char *data;	va_list argp;#ifdef HAVE_HMAC_CTX_CLEANUP	HMAC_CTX_init(&hmac);#endif	HMAC_Init(&hmac, key, keylen, EVP_sha1());	va_start(argp, keylen);	for (;;) {		dlen = (unsigned int) va_arg(argp, unsigned int);		if (dlen == 0)			break;		data = (unsigned char *) va_arg(argp, int);		if (data == NULL)			return ERR_NULL_ARG;		HMAC_Update(&hmac, data, dlen);	}	HMAC_Final(&hmac, digest, &dlen);#ifdef HAVE_HMAC_CTX_CLEANUP	HMAC_CTX_cleanup(&hmac);#else	HMAC_cleanup(&hmac);#endif	va_end(argp);	return 0;}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人激情视频网站| 亚洲www啪成人一区二区麻豆| 久久久精品天堂| 欧美激情中文字幕| 一区二区三区高清不卡| 久久成人精品无人区| 国产69精品一区二区亚洲孕妇| 99久久婷婷国产精品综合| 精品污污网站免费看| 日韩一区和二区| 欧美国产乱子伦| 亚洲成人你懂的| 麻豆91在线播放免费| 成人免费高清在线观看| 欧美午夜一区二区三区| 国产日韩欧美a| 日韩av电影免费观看高清完整版 | 91亚洲精品久久久蜜桃网站 | 成人av资源网站| 日韩亚洲欧美在线| 国产精品丝袜久久久久久app| 亚洲国产日韩综合久久精品| 国产精品亚洲第一| 欧美精品v日韩精品v韩国精品v| 久久精品视频在线免费观看 | 久久久久9999亚洲精品| 亚洲小说欧美激情另类| 日本一道高清亚洲日美韩| 精品中文字幕一区二区小辣椒| 色94色欧美sute亚洲线路一ni| 久久免费国产精品| 亚洲一区二区三区三| 成人一区二区三区| 久久一二三国产| 麻豆91免费观看| 欧美伊人久久大香线蕉综合69| 国产女主播视频一区二区| 青草国产精品久久久久久| 一本大道av一区二区在线播放| 国产三级精品视频| 麻豆成人综合网| 欧美一级黄色大片| 亚洲女厕所小便bbb| 国产suv精品一区二区6| 久久久99精品久久| 美日韩一区二区| 欧美电影在线免费观看| 亚洲成人tv网| 在线观看亚洲一区| 亚洲激情图片qvod| 国产精品一二三| 精品乱人伦小说| 韩国成人福利片在线播放| 日韩一区二区精品| 久久精品久久精品| 日韩欧美一区在线| 韩国精品一区二区| 国产亚洲午夜高清国产拍精品 | 久久97超碰色| 日韩免费观看高清完整版| 久久不见久久见免费视频7 | 伊人一区二区三区| 欧美日韩三级一区二区| 亚洲地区一二三色| 在线成人小视频| 久久91精品久久久久久秒播| 精品99一区二区| 亚洲国产日韩精品| 日韩三级免费观看| 国产精品综合一区二区| 中文字幕在线视频一区| 91女厕偷拍女厕偷拍高清| 精品卡一卡二卡三卡四在线| 国产成人8x视频一区二区| 1区2区3区国产精品| 欧美日韩综合在线免费观看| 免费美女久久99| 欧美激情资源网| 色av成人天堂桃色av| 亚洲精品少妇30p| 色综合色狠狠天天综合色| 亚洲国产精品久久人人爱蜜臀 | 日韩成人午夜电影| 久久久久久久久久久久电影| 国产传媒一区在线| 成人欧美一区二区三区小说| 欧美三级韩国三级日本三斤| 免费在线看成人av| 国产精品视频线看| 欧美日本一区二区三区| 一区二区三区欧美在线观看| 国产精品一区二区在线观看网站| 91精品国产麻豆| 精品久久久久av影院| 国产精品久久久久7777按摩| 中文字幕五月欧美| 不卡电影免费在线播放一区| 免费精品99久久国产综合精品| 国产精品1区2区3区| 欧美mv日韩mv国产网站app| 成人动漫av在线| 国产成人在线影院| 日韩成人午夜电影| 成人黄页毛片网站| 日韩三级在线观看| 欧美成人伊人久久综合网| 免费一级欧美片在线观看| 欧美日韩免费一区二区三区 | 久久久久久黄色| 国产成人精品免费网站| 中文字幕在线不卡一区二区三区 | 丁香六月久久综合狠狠色| 欧美麻豆精品久久久久久| 久久国产三级精品| www.欧美.com| 日韩欧美不卡一区| 91成人网在线| 国产在线精品一区二区三区不卡| 国产精品短视频| 久久久99精品免费观看不卡| 99热精品国产| 国产东北露脸精品视频| 一区二区三区在线视频免费观看| 国产日韩精品一区二区三区在线| 精品少妇一区二区三区在线播放| 91成人看片片| 51精品国自产在线| 日韩免费电影一区| 在线观看日韩电影| 欧美美女激情18p| 日韩区在线观看| 亚洲精品乱码久久久久| 日韩美女精品在线| 亚洲精品成a人| 美国十次综合导航| 国产精品一区不卡| 粉嫩av一区二区三区在线播放| 99综合电影在线视频| 欧美天天综合网| 精品福利在线导航| 樱花草国产18久久久久| 国产一区二区三区四| 91色|porny| 色综合天天做天天爱| 日韩三级av在线播放| 亚洲精品写真福利| 久久91精品久久久久久秒播| 国产99精品国产| 精品1区2区3区| 国产精品福利在线播放| 国产麻豆精品在线| 欧美高清精品3d| 国产欧美日韩激情| 久久er99热精品一区二区| 国产亚洲欧美日韩在线一区| 日韩精品一区二区三区四区视频| 亚洲男同性视频| 99精品视频免费在线观看| 国产亚洲自拍一区| 国产成人亚洲综合色影视| 91麻豆精品国产91久久久久| 午夜精品久久久久影视| voyeur盗摄精品| 一区二区三区在线视频免费观看| 91在线免费视频观看| 欧美精品一区二区在线播放 | 国产亚洲一本大道中文在线| 久久精品久久综合| 久久久99精品免费观看不卡| 国产精品亚洲午夜一区二区三区 | 日本一区二区三区久久久久久久久不| 久久久精品国产免费观看同学| 亚洲国产激情av| 9色porny自拍视频一区二区| 日韩欧美国产系列| 国产高清久久久久| 一区二区在线观看不卡| 91精品国产高清一区二区三区| 国产在线精品一区二区不卡了 | 欧美久久免费观看| 日韩一区二区免费在线电影| 日韩av不卡在线观看| 亚洲欧美激情视频在线观看一区二区三区 | 性做久久久久久久免费看| 欧美精品18+| 一本色道久久综合亚洲精品按摩| 日本最新不卡在线| 午夜视频一区二区三区| 亚洲日本欧美天堂| 亚洲蜜桃精久久久久久久| 久久久久久一二三区| 免费在线观看精品| 亚洲视频一区二区在线| 国产精品私人影院| 国产精品国产自产拍高清av| 国产亚洲福利社区一区| 欧美激情在线免费观看| 国产精品欧美一区喷水| 久久精品网站免费观看| 国产欧美日韩视频在线观看|