DSA具体过程:
需要特别说明的是全局参数p,q的生成方法,不要只想着先求素数p再求p-1的素因子,官方的方法是先生成素数q,再用素数q去反过来求p.
stackoverflow的解决方案:https://stackoverflow.com/questions/8350568/dsa-how-to-generate-the-subprime
C++代码实现:dsa.cpp
#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<openssl/sha.h>
#include<string.h>
#include<gmp.h>
#include<vector>
#include<cmath>
#include<time.h>
using namespace std;
gmp_randstate_t gmp_state;
//读取文件
//输入:文件名,buffer数组(用于存读取结果)
//输出:buffer数组长度
long readfile(char *filename,char *&buffer){
long len;
ifstream rf;
rf.open(filename,ios::in|ios::binary|ios::ate);
len=rf.tellg();
rf.seekg(0,ios::beg);
buffer=new char[len];
rf.read(buffer,len);
rf.close();

本文介绍了如何利用DSA(Digital Signature Algorithm)结合GMP库和OpenSSL进行文件的数字签名验证。重点在于DSA的详细过程,特别是p和q参数的生成,强调了应先生成素数q,再据此求得p。文中提供了C++代码实现,用于实际操作签名验证。

6500

被折叠的 条评论
为什么被折叠?



