mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-11 00:13:55 +08:00
paillier pen support
and some bug fixes
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "internal/x509_int.h"
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/paillier.h>
|
||||
|
||||
struct X509_pubkey_st {
|
||||
X509_ALGOR *algor;
|
||||
@@ -255,6 +256,46 @@ int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_PAILLIER
|
||||
PAILLIER *d2i_PAILLIER_PUBKEY(PAILLIER **a, const unsigned char **pp, long length)
|
||||
{
|
||||
EVP_PKEY *pkey;
|
||||
PAILLIER *key;
|
||||
const unsigned char *q;
|
||||
q = *pp;
|
||||
pkey = d2i_PUBKEY(NULL, &q, length);
|
||||
if (!pkey)
|
||||
return NULL;
|
||||
key = EVP_PKEY_get1_PAILLIER(pkey);
|
||||
EVP_PKEY_free(pkey);
|
||||
if (!key)
|
||||
return NULL;
|
||||
*pp = q;
|
||||
if (a) {
|
||||
PAILLIER_free(*a);
|
||||
*a = key;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
int i2d_PAILLIER_PUBKEY(PAILLIER *a, unsigned char **pp)
|
||||
{
|
||||
EVP_PKEY *pktmp;
|
||||
int ret;
|
||||
if (!a)
|
||||
return 0;
|
||||
pktmp = EVP_PKEY_new();
|
||||
if (pktmp == NULL) {
|
||||
ASN1err(ASN1_F_I2D_PAILLIER_PUBKEY, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
EVP_PKEY_set1_PAILLIER(pktmp, a);
|
||||
ret = i2d_PUBKEY(pktmp, pp);
|
||||
EVP_PKEY_free(pktmp);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
DSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user