提交 fc875472 编写于 作者: B Ben Laurie

Another stack.

上级 e5e932d2
......@@ -68,14 +68,16 @@ int i2d_PKCS8_PRIV_KEY_INFO (PKCS8_PRIV_KEY_INFO *a, unsigned char **pp)
M_ASN1_I2D_len (a->version, i2d_ASN1_INTEGER);
M_ASN1_I2D_len (a->pkeyalg, i2d_X509_ALGOR);
M_ASN1_I2D_len (a->pkey, i2d_ASN1_TYPE);
M_ASN1_I2D_len_IMP_SET_opt (a->attributes, i2d_X509_ATTRIBUTE, 0);
M_ASN1_I2D_len_IMP_SET_opt_type (X509_ATTRIBUTE, a->attributes,
i2d_X509_ATTRIBUTE, 0);
M_ASN1_I2D_seq_total ();
M_ASN1_I2D_put (a->version, i2d_ASN1_INTEGER);
M_ASN1_I2D_put (a->pkeyalg, i2d_X509_ALGOR);
M_ASN1_I2D_put (a->pkey, i2d_ASN1_TYPE);
M_ASN1_I2D_put_IMP_SET_opt (a->attributes, i2d_X509_ATTRIBUTE, 0);
M_ASN1_I2D_put_IMP_SET_opt_type (X509_ATTRIBUTE, a->attributes,
i2d_X509_ATTRIBUTE, 0);
M_ASN1_I2D_finish();
}
......@@ -103,8 +105,9 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,
M_ASN1_D2I_get (ret->version, d2i_ASN1_INTEGER);
M_ASN1_D2I_get (ret->pkeyalg, d2i_X509_ALGOR);
M_ASN1_D2I_get (ret->pkey, d2i_ASN1_TYPE);
M_ASN1_D2I_get_IMP_set_opt(ret->attributes, d2i_X509_ATTRIBUTE,
X509_ATTRIBUTE_free, 0);
M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes,
d2i_X509_ATTRIBUTE,
X509_ATTRIBUTE_free, 0);
if (ASN1_TYPE_get(ret->pkey) == V_ASN1_SEQUENCE)
ret->broken = PKCS8_NO_OCTET;
M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO);
......@@ -120,6 +123,6 @@ void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a)
memset (a->pkey->value.octet_string->data,
0, a->pkey->value.octet_string->length);
ASN1_TYPE_free (a->pkey);
sk_pop_free (a->attributes, X509_ATTRIBUTE_free);
Free ((char *)a);
sk_X509_ATTRIBUTE_pop_free (a->attributes, X509_ATTRIBUTE_free);
Free (a);
}
......@@ -135,11 +135,12 @@ int PKCS8_add_keyusage (PKCS8_PRIV_KEY_INFO *p8, int usage)
}
sk_ASN1_TYPE_push (attrib->value.set,keyid);
attrib->set = 1;
if (!p8->attributes && !(p8->attributes = sk_new (NULL))) {
if (!p8->attributes
&& !(p8->attributes = sk_X509_ATTRIBUTE_new (NULL))) {
PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
return 0;
}
sk_push (p8->attributes, (char *)attrib);
sk_X509_ATTRIBUTE_push (p8->attributes, attrib);
return 1;
}
......
......@@ -375,7 +375,7 @@ typedef struct pkcs8_priv_key_info_st
ASN1_INTEGER *version;
X509_ALGOR *pkeyalg;
ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
STACK *attributes;
STACK_OF(X509_ATTRIBUTE) *attributes;
} PKCS8_PRIV_KEY_INFO;
#include <openssl/x509_vfy.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册