// sign.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <openssl/rsa.h>
#include <openssl/evp.h>
#include <openssl/objects.h>
#include <openssl/x509.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#pragma comment(lib, "libeay32.lib")
#pragma comment(lib, "ssleay32.lib")
/*
PKCS7Sign.cpp
Auth:Kagula
功能:调用OpenSSL实现数字签名功能例程(一)
环境:VS2008+SP1,OpenSSL1.0.1
*/
void InitOpenSSL()
{
ERR_load_crypto_strings();
}
unsigned char * GetSign(char* keyFile,char* plainText,unsigned char* cipherText,unsigned int *cipherTextLen)
{
FILE* fp = fopen (keyFile, "r");
if (fp == NULL)
return NULL;
/* Read private key */
EVP_PKEY* pkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL);
fclose (fp);
if
调用OpenSSL实现数字签名功能例程(一)
最新推荐文章于 2024-05-14 16:34:43 发布