mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-08 06:03:47 +08:00
first step of v2 final release
This commit is contained in:
@@ -39,16 +39,39 @@ PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *
|
||||
int i;
|
||||
unsigned char keyid[EVP_MAX_MD_SIZE];
|
||||
unsigned int keyidlen = 0;
|
||||
const EVP_MD *md;
|
||||
|
||||
#ifndef OPENSSL_NO_SHA
|
||||
md = EVP_sha1();
|
||||
#elif !defined(OPENSSL_NO_SM3)
|
||||
md = EVP_sm3();
|
||||
#else
|
||||
PKCS12err(PKCS12_F_PKCS12_CREATE, PKCS12_R_NO_AVAIABLE_DIGEST);
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
/* Set defaults */
|
||||
if (!nid_cert)
|
||||
#ifdef OPENSSL_NO_RC2
|
||||
if (!nid_cert) {
|
||||
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DES)
|
||||
nid_cert = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
|
||||
#else
|
||||
#elif !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_RC2)
|
||||
nid_cert = NID_pbe_WithSHA1And40BitRC2_CBC;
|
||||
#elif !defined(OPENSSL_NO_SM3) && !defined(OPENSSL_NO_SMS4)
|
||||
nid_cert = NID_pbe_WithSM3AndSMS4_CBC;
|
||||
#else
|
||||
PKCS12err(PKCS12_F_PKCS12_CREATE, PKCS12_R_NO_AVAIABLE_CIPHER);
|
||||
return 0;
|
||||
#endif
|
||||
if (!nid_key)
|
||||
}
|
||||
|
||||
if (!nid_key) {
|
||||
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DES)
|
||||
nid_key = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
|
||||
#elif !defined(OPENSSL_NO_SM3) && !defined(OPENSSL_NO_SMS4)
|
||||
nid_key = NID_pbe_WithSM3AndSMS4_CBC;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!iter)
|
||||
iter = PKCS12_DEFAULT_ITER;
|
||||
if (!mac_iter)
|
||||
@@ -62,7 +85,7 @@ PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *
|
||||
if (pkey && cert) {
|
||||
if (!X509_check_private_key(cert, pkey))
|
||||
return NULL;
|
||||
X509_digest(cert, EVP_sha1(), keyid, &keyidlen);
|
||||
X509_digest(cert, md, keyid, &keyidlen);
|
||||
}
|
||||
|
||||
if (cert) {
|
||||
|
||||
@@ -176,8 +176,16 @@ int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
|
||||
unsigned int maclen;
|
||||
ASN1_OCTET_STRING *macoct;
|
||||
|
||||
if (!md_type)
|
||||
if (!md_type) {
|
||||
#ifndef OPENSSL_NO_SHA
|
||||
md_type = EVP_sha1();
|
||||
#elif !defined(OPENSSL_NO_SM3)
|
||||
md_type = EVP_sm3();
|
||||
#else
|
||||
PKCS12err(PKCS12_F_PKCS12_SET_MAC, PKCS12_R_NO_AVAIABLE_DIGEST);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
if (PKCS12_setup_mac(p12, iter, salt, saltlen, md_type) == PKCS12_ERROR) {
|
||||
PKCS12err(PKCS12_F_PKCS12_SET_MAC, PKCS12_R_MAC_SETUP_ERROR);
|
||||
return 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -68,6 +68,8 @@ static ERR_STRING_DATA PKCS12_str_reasons[] = {
|
||||
{ERR_REASON(PKCS12_R_MAC_SETUP_ERROR), "mac setup error"},
|
||||
{ERR_REASON(PKCS12_R_MAC_STRING_SET_ERROR), "mac string set error"},
|
||||
{ERR_REASON(PKCS12_R_MAC_VERIFY_FAILURE), "mac verify failure"},
|
||||
{ERR_REASON(PKCS12_R_NO_AVAIABLE_CIPHER), "no avaiable cipher"},
|
||||
{ERR_REASON(PKCS12_R_NO_AVAIABLE_DIGEST), "no avaiable digest"},
|
||||
{ERR_REASON(PKCS12_R_PARSE_ERROR), "parse error"},
|
||||
{ERR_REASON(PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR),
|
||||
"pkcs12 algor cipherinit error"},
|
||||
|
||||
Reference in New Issue
Block a user