⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test04.c

📁 一个免费的SMART CARD OS系统。
💻 C
字号:
/* ============================================================================   Project Name : jayaCard TCK   Module Name  : proto/tck/hal/test04/test04.c   Version : $Id: test04.c,v 1.4 2004/01/11 09:56:35 dgil Exp $	Description: HAL TEST04 - SHA-1    The Original Code is jayaCard TCK code.    The Initial Developer of the Original Code is Gilles Dumortier.	Portions created by the Initial Developer are Copyright (C) 2002-2004 the    Initial Developer. All Rights Reserved.    Contributor(s):	Permission is granted to any individual to use, copy, or redistribute	this software so long as all of the original files are included	unmodified, that it is not sold for profit, and that this copyright	notice is retained.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   History Rev	Description   042503 dgil	wrote it from scratch   ============================================================================*/#include "precomp.h"/* ============================================================================	TEST OUR SHA-1 IMPLEMENTATION	Test Vectors (from FIPS PUB 180-1)	"abc"	A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D	"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"	84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1	A million repetitions of "a"	34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F   ========================================================================= *//* ============================================================================	SHA1_display_digest()   ========================================================================= */void SHA1_display_digest(void){	printf("\tsha-1 digest is %.4lX %.4lX %.4lX %.4lX %.4lX\n",			r.dwBlock[JAYA_DWCRYPTO_DIGEST_0],			r.dwBlock[JAYA_DWCRYPTO_DIGEST_1],			r.dwBlock[JAYA_DWCRYPTO_DIGEST_2],			r.dwBlock[JAYA_DWCRYPTO_DIGEST_3],			r.dwBlock[JAYA_DWCRYPTO_DIGEST_4]			);}/* ============================================================================	SHA1_validate() -> ok or not   ========================================================================= */jbool SHA1_validate(void){	long	i;	printf("test string 'abc'\n");	__crypto_SHA1_init();	__crypto_SHA1_update((jbyte *)"abc",3);	__crypto_SHA1_final();	printf("\tsha-1 digest mb A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\n");	SHA1_display_digest();	printf("test string 'abc'\n");	__crypto_SHA1_init();	__crypto_SHA1_update((jbyte *)"ab",2);	__crypto_SHA1_update((jbyte *)"c",1);	__crypto_SHA1_final();	printf("\tsha-1 digest mb A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\n");	SHA1_display_digest();	printf("test string 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'\n");	__crypto_SHA1_init();	__crypto_SHA1_update((jbyte *)"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",strlen("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"));	__crypto_SHA1_final();	printf("\tsha-1 digest mb 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\n");	SHA1_display_digest();	printf("test 1,000,000 repetitions of 'a'\n");	__crypto_SHA1_init();	for (i=0; i<1000000;i++) {		__crypto_SHA1_update((jbyte *)"a",1);	}	__crypto_SHA1_final();	printf("\tsha-1 digest mb 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\n");	SHA1_display_digest();	return jtrue;}/* ============================================================================	main()   ========================================================================= */int main(void){	printf("Start of hal::test04\n");	SHA1_validate();	printf("\nEnd of hal::test04\n");	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -