• 大小: 4.06MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-16
  • 语言: C/C++
  • 标签: ecdh  qq  android  算法  

资源简介

openssl这个文件夹放在C盘根目录下, 或者添加你自定义目录到ECDH的工程 项目的头文件和lib文件的搜索目录 具体怎么修改,请自行百度, 该ECDH生成算法, 该算法不支持PCQQ,因为不是参照PCQQ实现的,安卓版本请自行测试 项目使用VC C++6.0编译通过。采用静态链接方式, 编译后的ECDH.exe可单独运行,不需要依赖于OPENSSL

资源截图

代码片段和文件信息

#include 
#include 

#include “openssl/ecdh.h“
#include “openssl/ec.h“
#include “openssl/md5.h“

#define BYTE unsigned char
//04928D8850673088B343264E0C6BACB8496D697799F37211DEB25BB73906CB089FEA9639B4E0260498B51A992D50813DA8
BYTE tk[] = {  
0x04 0x92 0x8D 0x88 0x50 0x67 0x30 0x88 
0xB3 0x43 0x26 0x4E 0x0C 0x6B 0xAC 0xB8
0x49 0x6D 0x69 0x77 0x99 0xF3 0x72 0x11 
0xDE 0xB2 0x5B 0xB7 0x39 0x06 0xCB 0x08 
0x9F 0xEA 0x96 0x39 0xB4 0xE0 0x26 0x04 
0x98 0xB5 0x1A 0x99 0x2D 0x50 0x81 0x3D 
0xA8
}; //客户端公钥服务端还有一个私有密钥pk

void GetLastECDHError(int);
int GenerateKey(unsigned char[] unsigned char* unsigned char*);
//int GenerateKeyByCustomPubKey(unsigned char[] unsigned char* unsigned char*);
void printBuffer(unsigned char[] int);

int main()
{
unsigned char publicKey[25] = {0}; 
unsigned char md5ShareKey[16] = {0}; 
unsigned char customPubKey[25] = {0}; 
int ret = GenerateKey(tk publicKey md5ShareKey);
printf(“PubKey:“);
printBuffer(publicKey25);
printf(“\n“);
printf(“ShareKey:“);
printBuffer(md5ShareKey16);
printf(“\n“);
system(“pause“);
return 0;
}

void GetLastECDHError(int code)
{
if(code == 1)
{

}
else
{

}
}
int GenerateKey(unsigned char S_PUB_KEY[]  unsigned char * rPubKey unsigned char * rShareKey)
{
int ret = 0;
unsigned char * PubKey = (unsigned char * )malloc(67);
unsigned char * ShareKey = (unsigned char * )malloc(512);
unsigned char * MD5ShareKey;
EC_KEY * ec_key;
const EC_POINT * ec_point;
EC_POINT * new_ec_point;
const EC_GROUP * ec_group;
const EC_GROUP * ec_group1;
size_t point2OctLen = 0;
int shareKeyLen = 0;

ec_key = EC_KEY_new_by_curve_name(711);
GetLastECDHError(ec_key);
ret = EC_KEY_generate_key(ec_key);
GetLastECDHError(ret);
ec_point = EC_KEY_get0_public_key(ec_key);
GetLastECDHError(ec_point);
ec_group = EC_KEY_get0_group(ec_key);
point2OctLen = EC_POINT_point2oct(ec_group ec_point POINT_CONVERSION_COMPRESSED PubKey 67 NULL);
GetLastECDHError(point2OctLen);
ec_group1 = EC_KEY_get0_group(ec_key);
GetLastECDHError(ec_group1);
new_ec_point = EC_POINT_new(ec_group1);
ret = EC_POINT_oct2point(ec_group1 new_ec_point S_PUB_KEY strlen(S_PUB_KEY) NULL);
GetLastECDHError(ret);
shareKeyLen = ECDH_compute_key(ShareKey 512 new_ec_point ec_key NULL);
GetLastECDHError(shareKeyLen);
MD5ShareKey = (unsigned char * )malloc(16);
MD5(ShareKey shareKeyLen MD5ShareKey);

EC_KEY_free(ec_key);
if(new_ec_point)
{
EC_POINT_free(new_ec_point);
}
memcpy(rPubKey PubKey point2OctLen);
memcpy(rShareKey MD5ShareKey 16);
free(PubKey);
free(ShareKey);
free(MD5ShareKey);
return 0;
}
/*int GenerateKeyByCustomPubKey(unsigned char S_PUB_KEY[]  unsigned char * rPubKey unsigned char * rShareKey)
{
int ret = 0;
unsigned char * PubKey = (unsigned char * )malloc(67);
unsigned char * ShareKey = 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     353280  2015-02-05 22:01  ECDH\ECDH\Debug\ECDH.bsc

     文件    1511468  2015-02-05 22:01  ECDH\ECDH\Debug\ECDH.exe

     文件    1958312  2015-02-05 22:01  ECDH\ECDH\Debug\ECDH.ilk

     文件     822652  2015-02-05 21:24  ECDH\ECDH\Debug\ECDH.pch

     文件    3712000  2015-02-05 22:01  ECDH\ECDH\Debug\ECDH.pdb

     文件       6843  2015-02-05 22:01  ECDH\ECDH\Debug\main.obj

     文件          0  2015-02-05 22:01  ECDH\ECDH\Debug\main.sbr

     文件      33792  2015-02-05 22:01  ECDH\ECDH\Debug\vc60.idb

     文件      45056  2015-02-05 22:01  ECDH\ECDH\Debug\vc60.pdb

     文件       4310  2015-02-05 21:57  ECDH\ECDH\ECDH.dsp

     文件        514  2015-02-01 21:18  ECDH\ECDH\ECDH.dsw

     文件      41984  2015-02-05 22:07  ECDH\ECDH\ECDH.ncb

     文件      53760  2015-02-05 22:07  ECDH\ECDH\ECDH.opt

     文件       2121  2015-02-05 22:01  ECDH\ECDH\ECDH.plg

     文件       4631  2015-02-05 22:01  ECDH\ECDH\main.c

     目录          0  2015-02-05 22:01  ECDH\ECDH\Debug

     目录          0  2015-02-05 22:07  ECDH\ECDH

     目录          0  2015-02-01 21:18  ECDH

     文件       6182  2015-01-26 10:31  openssl\include\openssl\aes.h

     文件       3176  2015-01-26 10:31  openssl\include\openssl\applink.c

     文件      63097  2015-01-26 10:31  openssl\include\openssl\asn1.h

     文件      34475  2015-01-26 10:31  openssl\include\openssl\asn1t.h

     文件      24435  2015-01-26 10:31  openssl\include\openssl\asn1_mac.h

     文件      38505  2015-01-26 10:31  openssl\include\openssl\bio.h

     文件       5351  2015-01-26 10:31  openssl\include\openssl\blowfish.h

     文件      40791  2015-01-26 10:31  openssl\include\openssl\bn.h

     文件       4907  2015-01-26 10:31  openssl\include\openssl\buffer.h

     文件       5601  2015-01-26 10:31  openssl\include\openssl\camellia.h

     文件       4659  2015-01-26 10:31  openssl\include\openssl\cast.h

     文件       3257  2015-01-26 10:31  openssl\include\openssl\cmac.h

............此处省略73个文件信息

评论

共有 条评论