#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
#include <openssl/des.h>
#include "util/Base.h"
typedef unsigned char BYTE;
/*
*
*产生随机数
*
*/
unsigned char *getRandom(unsigned char *buf, size_t l) {
if (!RAND_bytes(buf, l)) {
fprintf(stderr, "The PRNG is not seeded!\n");
return NULL;
}
printf((char*)buf);
return buf;
}
/**
*
*信封加密解密
*参考openssl编程.chm 21.10编程实例4
*
*/
int EVP_enc()
{
int ret,ekl[2],npubk,inl,outl,total=0,total2=0;
unsigned long e=RSA_3;
char *ek[2],iv[8],in[100],out[500],de[500];
EVP_CIPHER_CTX ctx,ctx2;
EVP_CIPHER *type;
EVP_PKEY *pubkey[2];
RSA *rkey;
BIGNUM *bne;
int i;
/* 生成RSA密钥*/
bne=BN_new();
openssl签名验证、信封加密解密、产生随机数、md5摘要
最新推荐文章于 2023-10-24 07:30:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)