Latest update.

This commit is contained in:
2019-10-17 23:54:38 +09:00
parent 41a23ae6f6
commit ee84d0dd84
1357 changed files with 41111 additions and 9603 deletions
+2 -2
View File
@@ -10,7 +10,7 @@
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
#include "p12_lcl.h"
#include "p12_local.h"
/* Pack an object into an OCTET STRING and turn into a safebag */
@@ -106,7 +106,7 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
else
pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
if (!pbe) {
if (pbe == NULL) {
PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
goto err;
}
+1 -1
View File
@@ -11,7 +11,7 @@
#include "internal/cryptlib.h"
#include <openssl/asn1t.h>
#include <openssl/pkcs12.h>
#include "p12_lcl.h"
#include "p12_local.h"
/* PKCS#12 ASN1 module */
+1 -1
View File
@@ -10,7 +10,7 @@
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
#include "p12_lcl.h"
#include "p12_local.h"
/* Add a local keyid to a safebag */
+1 -1
View File
@@ -44,7 +44,7 @@ int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
return 0;
}
if (!pbe->iter)
if (pbe->iter == NULL)
iter = 1;
else
iter = ASN1_INTEGER_get(pbe->iter);
+15 -16
View File
@@ -10,7 +10,7 @@
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
#include "p12_lcl.h"
#include "p12_local.h"
static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags,
PKCS12_SAFEBAG *bag);
@@ -54,7 +54,7 @@ PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *
if (!mac_iter)
mac_iter = 1;
if (!pkey && !cert && !ca) {
if (pkey == NULL && cert == NULL && ca == NULL) {
PKCS12err(PKCS12_F_PKCS12_CREATE, PKCS12_R_INVALID_NULL_ARGUMENT);
return NULL;
}
@@ -110,7 +110,7 @@ PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *
p12 = PKCS12_add_safes(safes, 0);
if (!p12)
if (p12 == NULL)
goto err;
sk_PKCS7_pop_free(safes, PKCS7_free);
@@ -208,13 +208,12 @@ int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
PKCS7 *p7 = NULL;
int free_safes = 0;
if (!*psafes) {
if (*psafes == NULL) {
*psafes = sk_PKCS7_new_null();
if (!*psafes)
if (*psafes == NULL)
return 0;
free_safes = 1;
} else
free_safes = 0;
}
if (nid_safe == 0)
#ifdef OPENSSL_NO_RC2
@@ -227,7 +226,7 @@ int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
p7 = PKCS12_pack_p7data(bags);
else
p7 = PKCS12_pack_p7encdata(nid_safe, pass, -1, NULL, 0, iter, bags);
if (!p7)
if (p7 == NULL)
goto err;
if (!sk_PKCS7_push(*psafes, p7))
@@ -248,16 +247,16 @@ int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags,
PKCS12_SAFEBAG *bag)
{
int free_bags;
if (!pbags)
int free_bags = 0;
if (pbags == NULL)
return 1;
if (!*pbags) {
if (*pbags == NULL) {
*pbags = sk_PKCS12_SAFEBAG_new_null();
if (!*pbags)
if (*pbags == NULL)
return 0;
free_bags = 1;
} else
free_bags = 0;
}
if (!sk_PKCS12_SAFEBAG_push(*pbags, bag)) {
if (free_bags) {
@@ -274,11 +273,11 @@ static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags,
PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int nid_p7)
{
PKCS12 *p12;
if (nid_p7 <= 0)
nid_p7 = NID_pkcs7_data;
p12 = PKCS12_init(nid_p7);
if (!p12)
if (p12 == NULL)
return NULL;
if (!PKCS12_pack_authsafes(p12, safes)) {
+1 -1
View File
@@ -10,7 +10,7 @@
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
#include "p12_lcl.h"
#include "p12_local.h"
/* Initialise a PKCS12 structure to take data */
+2 -2
View File
@@ -26,7 +26,7 @@ int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
unsigned char *unipass;
int uniplen;
if (!pass) {
if (pass == NULL) {
unipass = NULL;
uniplen = 0;
} else if (!OPENSSL_asc2uni(pass, passlen, &unipass, &uniplen)) {
@@ -49,7 +49,7 @@ int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt,
unsigned char *unipass;
int uniplen;
if (!pass) {
if (pass == NULL) {
unipass = NULL;
uniplen = 0;
} else if (!OPENSSL_utf82uni(pass, passlen, &unipass, &uniplen)) {
+8 -7
View File
@@ -42,7 +42,7 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
/* Check for NULL PKCS12 structure */
if (!p12) {
if (p12 == NULL) {
PKCS12err(PKCS12_F_PKCS12_PARSE,
PKCS12_R_INVALID_NULL_PKCS12_POINTER);
return 0;
@@ -57,7 +57,7 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
* password are two different things...
*/
if (!pass || !*pass) {
if (pass == NULL || *pass == '\0') {
if (PKCS12_verify_mac(p12, NULL, 0))
pass = NULL;
else if (PKCS12_verify_mac(p12, "", 0))
@@ -85,7 +85,8 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
}
while ((x = sk_X509_pop(ocerts))) {
if (pkey && *pkey && cert && !*cert) {
if (pkey != NULL && *pkey != NULL
&& cert != NULL && *cert == NULL) {
ERR_set_mark();
if (X509_check_private_key(x, *pkey)) {
*cert = x;
@@ -95,9 +96,9 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
}
if (ca && x) {
if (!*ca)
if (*ca == NULL)
*ca = sk_X509_new_null();
if (!*ca)
if (*ca == NULL)
goto err;
if (!sk_X509_push(*ca, x))
goto err;
@@ -191,7 +192,7 @@ static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
switch (PKCS12_SAFEBAG_get_nid(bag)) {
case NID_keyBag:
if (!pkey || *pkey)
if (pkey == NULL || *pkey != NULL)
return 1;
*pkey = EVP_PKCS82PKEY(PKCS12_SAFEBAG_get0_p8inf(bag));
if (*pkey == NULL)
@@ -199,7 +200,7 @@ static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
break;
case NID_pkcs8ShroudedKeyBag:
if (!pkey || *pkey)
if (pkey == NULL || *pkey != NULL)
return 1;
if ((p8 = PKCS12_decrypt_skey(bag, pass, passlen)) == NULL)
return 0;
+2 -2
View File
@@ -13,7 +13,7 @@
#include <openssl/hmac.h>
#include <openssl/rand.h>
#include <openssl/pkcs12.h>
#include "p12_lcl.h"
#include "p12_local.h"
int PKCS12_mac_present(const PKCS12 *p12)
{
@@ -95,7 +95,7 @@ static int pkcs12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
salt = p12->mac->salt->data;
saltlen = p12->mac->salt->length;
if (!p12->mac->iter)
if (p12->mac->iter == NULL)
iter = 1;
else
iter = ASN1_INTEGER_get(p12->mac->iter);
+5 -4
View File
@@ -13,7 +13,7 @@
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/pkcs12.h>
#include "p12_lcl.h"
#include "p12_local.h"
/* PKCS#12 password change routine */
@@ -33,7 +33,7 @@ int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass)
{
/* Check for NULL PKCS12 structure */
if (!p12) {
if (p12 == NULL) {
PKCS12err(PKCS12_F_PKCS12_NEWPASS,
PKCS12_R_INVALID_NULL_PKCS12_POINTER);
return 0;
@@ -94,7 +94,7 @@ static int newpass_p12(PKCS12 *p12, const char *oldpass, const char *newpass)
else
p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
pbe_saltlen, pbe_iter, bags);
if (!p7new || !sk_PKCS7_push(newsafes, p7new))
if (p7new == NULL || !sk_PKCS7_push(newsafes, p7new))
goto err;
sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
bags = NULL;
@@ -173,8 +173,9 @@ static int alg_get(const X509_ALGOR *alg, int *pnid, int *piter,
int *psaltlen)
{
PBEPARAM *pbe;
pbe = ASN1_TYPE_unpack_sequence(ASN1_ITEM_rptr(PBEPARAM), alg->parameter);
if (!pbe)
if (pbe == NULL)
return 0;
*pnid = OBJ_obj2nid(alg->algorithm);
*piter = ASN1_INTEGER_get(pbe->iter);
+2 -2
View File
@@ -10,7 +10,7 @@
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
#include "internal/x509_int.h"
#include "crypto/x509.h"
X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
const char *pass, int passlen,
@@ -28,7 +28,7 @@ X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
ERR_clear_error();
pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
}
if (!pbe) {
if (pbe == NULL) {
PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB);
return NULL;
}
+1 -1
View File
@@ -10,7 +10,7 @@
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/pkcs12.h>
#include "p12_lcl.h"
#include "p12_local.h"
#if !OPENSSL_API_1_1_0
ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid)