Crypto移植笔记
2018.06.12 许静
1. 环境: vs2017, crypto7.0
2. 修改代码,使编译通过。测试crylib项目。
无法打开源文件stdio.h, stddef.h,stdlib.h等文件, 在包含目录中添加:
C:\Program Files(x86)\Windows Kits\10\Include\10.0.16299.0\ucrt
注意10.0.16299.0版本是否存在本机目录下。
“找不到Windows SDK版本8.1. 请安装所需的版本的Windows SDK或者在项目属性页中或通过右键单击解决方案并选择“重定解决方案目标”来更改SDK版本”。更改一下,不出现错误。
3. 添加cryptlib.lib和所有.h文件。
4. 属性->c/c++->代码生成->运行库 多线程调试。
出错。
#error指令:Please use the /MD switch for _AFXDLL builds.
原因:将MFC设置成在共享dll中使用MFC.
解决方案:属性->常规->MFC的使用->在静态库中使用MFC.
5. 源文件
#ifndef __RSA_MAIN_H__
#define __RSA_MAIN_H__
#include <iostream>
#include <string>
#define _GEN_RSA 1
#if !_GEN_RSA
#define _SPE_RSA 1
#endif
class RSA_C {
public:
RSA_C(void);
~RSA_C(void);
std::string PubEn(const char* message);
std::string PriDe(const char* chiphtertext);
void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed);
private:
unsigned int keyLen;
char *privFilename;
char *pubFilename;
char *seed;
/*
#if _SPE_RSA
RSA::PrivateKey k1;
RSA::PublicKey k2;
AutoSeededRandomPool rnd;
#endif
*/
};
extern RSA_C g_RSA_App;
#endif
- #include "RSA_main.h"
- #include "rsa.h"
- #include "randpool.h"
- #include "hex.h"
- #include "files.h"
- #include "cryptlib.h"