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

📄 test_hmaverifysign.cpp

📁 UDP对QQ来说太重要了。 UDP和TCP是同一个层上的协议
💻 CPP
字号:
// test_HMAVerifySign.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <string.h>

#include "../../HMACCESS/HMAVerifySignature.h"
#include "../../HMACCESS/HMASignature.h"
#include <openssl/md5.h>
#include <openssl/rsa.h>
#include <openssl/objects.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/bio.h>


int main(int argc, char* argv[])
{
	printf("test HMAVerifySignature");
	FILE* fp;
	unsigned char buf[1024]={0};
	unsigned char md5[]="\xB4\x73\xE3\xEE\x5E\x0A\x09\x02\xF9\x36\xD2\x84\x75\xDD\x2C\x22";

	BIO *bio, *b64;
	fp=fopen("sign1024.txt","rb");
	if (fp==NULL)
	{
		printf("can not open signature data file sign1024.txt.\n");
		return 0;
	}
	
	b64 = BIO_new(BIO_f_base64());
	bio = BIO_new_fp(fp, BIO_NOCLOSE);
	bio = BIO_push(b64, bio);
	int inlen=0;
	inlen = BIO_read(bio, buf, 1024) ;
	fclose(fp);
	BIO_free_all(bio);	
	
	if (HMAVerifySignature((const unsigned char *)"123",(const unsigned char *)buf,inlen,md5,16,(const unsigned char *)"rsa")==0)
		printf("...ok\n");
	else
		printf("...err\n");

	unsigned char des[1024] = {0};
	void* pSignatureBuff ;
	pSignatureBuff = des;
	unsigned char sou[_MAX_PATH] = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const void* pSrcBuf;
	pSrcBuf = sou;
	unsigned char sm[] = "RSA";

	printf("test HMASignature\n");
	inlen=1024;
	
	if(HMASignature((const void *)0x008, 16, sm, pSignatureBuff, &inlen) == 0)
	{
		printf("num=%d...ok\n",inlen);
	
	}
	else
	printf("...failure\n");
	if(HMASignature(pSrcBuf, 16, sm, pSignatureBuff, &inlen) == 0)
	{
		printf("num=%d...ok\n",inlen);
		return 0;
	}
	printf("...failure\n");
	return 0;
}

⌨️ 快捷键说明

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