make X509_EXTENSION opaque
Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
parent
c7f5b5d7bc
commit
4903abd50a
@ -216,7 +216,7 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags,
|
|||||||
goto err;
|
goto err;
|
||||||
if (!X509V3_EXT_print(bp, ex, cflag, 16)) {
|
if (!X509V3_EXT_print(bp, ex, cflag, 16)) {
|
||||||
BIO_printf(bp, "%16s", "");
|
BIO_printf(bp, "%16s", "");
|
||||||
ASN1_STRING_print(bp, ex->value);
|
ASN1_STRING_print(bp, X509_EXTENSION_get_data(ex));
|
||||||
}
|
}
|
||||||
if (BIO_write(bp, "\n", 1) <= 0)
|
if (BIO_write(bp, "\n", 1) <= 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -179,8 +179,8 @@ static int crl_set_issuers(X509_CRL *crl)
|
|||||||
|
|
||||||
for (j = 0; j < sk_X509_EXTENSION_num(exts); j++) {
|
for (j = 0; j < sk_X509_EXTENSION_num(exts); j++) {
|
||||||
ext = sk_X509_EXTENSION_value(exts, j);
|
ext = sk_X509_EXTENSION_value(exts, j);
|
||||||
if (ext->critical > 0) {
|
if (X509_EXTENSION_get_critical(ext)) {
|
||||||
if (OBJ_obj2nid(ext->object) == NID_certificate_issuer)
|
if (OBJ_obj2nid(X509_EXTENSION_get_object(ext)) == NID_certificate_issuer)
|
||||||
continue;
|
continue;
|
||||||
crl->flags |= EXFLAG_CRITICAL;
|
crl->flags |= EXFLAG_CRITICAL;
|
||||||
break;
|
break;
|
||||||
@ -253,10 +253,10 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
|||||||
for (idx = 0; idx < sk_X509_EXTENSION_num(exts); idx++) {
|
for (idx = 0; idx < sk_X509_EXTENSION_num(exts); idx++) {
|
||||||
int nid;
|
int nid;
|
||||||
ext = sk_X509_EXTENSION_value(exts, idx);
|
ext = sk_X509_EXTENSION_value(exts, idx);
|
||||||
nid = OBJ_obj2nid(ext->object);
|
nid = OBJ_obj2nid(X509_EXTENSION_get_object(ext));
|
||||||
if (nid == NID_freshest_crl)
|
if (nid == NID_freshest_crl)
|
||||||
crl->flags |= EXFLAG_FRESHEST;
|
crl->flags |= EXFLAG_FRESHEST;
|
||||||
if (ext->critical > 0) {
|
if (X509_EXTENSION_get_critical(ext)) {
|
||||||
/* We handle IDP and deltas */
|
/* We handle IDP and deltas */
|
||||||
if ((nid == NID_issuing_distribution_point)
|
if ((nid == NID_issuing_distribution_point)
|
||||||
|| (nid == NID_authority_key_identifier)
|
|| (nid == NID_authority_key_identifier)
|
||||||
|
@ -388,7 +388,8 @@ int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs)
|
|||||||
*/
|
*/
|
||||||
req_ext = OCSP_REQUEST_get_ext(req, req_idx);
|
req_ext = OCSP_REQUEST_get_ext(req, req_idx);
|
||||||
resp_ext = OCSP_BASICRESP_get_ext(bs, resp_idx);
|
resp_ext = OCSP_BASICRESP_get_ext(bs, resp_idx);
|
||||||
if (ASN1_OCTET_STRING_cmp(req_ext->value, resp_ext->value))
|
if (ASN1_OCTET_STRING_cmp(X509_EXTENSION_get_data(req_ext),
|
||||||
|
X509_EXTENSION_get_data(resp_ext)))
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
#include "cryptlib.h"
|
#include "cryptlib.h"
|
||||||
#include <openssl/objects.h>
|
#include <openssl/objects.h>
|
||||||
#include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
|
#include <openssl/x509.h>
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
#include <openssl/ts.h>
|
#include <openssl/ts.h>
|
||||||
|
|
||||||
@ -115,7 +116,7 @@ int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions)
|
|||||||
BIO_printf(bio, ": %s\n", critical ? "critical" : "");
|
BIO_printf(bio, ": %s\n", critical ? "critical" : "");
|
||||||
if (!X509V3_EXT_print(bio, ex, 0, 4)) {
|
if (!X509V3_EXT_print(bio, ex, 0, 4)) {
|
||||||
BIO_printf(bio, "%4s", "");
|
BIO_printf(bio, "%4s", "");
|
||||||
ASN1_STRING_print(bio, ex->value);
|
ASN1_STRING_print(bio, X509_EXTENSION_get_data(ex));
|
||||||
}
|
}
|
||||||
BIO_write(bio, "\n", 1);
|
BIO_write(bio, "\n", 1);
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@ LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \
|
|||||||
x509_set.c x509cset.c x509rset.c x509_err.c \
|
x509_set.c x509cset.c x509rset.c x509_err.c \
|
||||||
x509name.c x509_v3.c x509_ext.c x509_att.c \
|
x509name.c x509_v3.c x509_ext.c x509_att.c \
|
||||||
x509type.c x509_lu.c x_all.c x509_txt.c \
|
x509type.c x509_lu.c x_all.c x509_txt.c \
|
||||||
x509_trs.c by_file.c by_dir.c x509_vpm.c x_attrib.c
|
x509_trs.c by_file.c by_dir.c x509_vpm.c x_attrib.c x_exten.c
|
||||||
LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \
|
LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \
|
||||||
x509_obj.o x509_req.o x509spki.o x509_vfy.o \
|
x509_obj.o x509_req.o x509spki.o x509_vfy.o \
|
||||||
x509_set.o x509cset.o x509rset.o x509_err.o \
|
x509_set.o x509cset.o x509rset.o x509_err.o \
|
||||||
x509name.o x509_v3.o x509_ext.o x509_att.o \
|
x509name.o x509_v3.o x509_ext.o x509_att.o \
|
||||||
x509type.o x509_lu.o x_all.o x509_txt.o \
|
x509type.o x509_lu.o x_all.o x509_txt.o \
|
||||||
x509_trs.o by_file.o by_dir.o x509_vpm.o x_attrib.o
|
x509_trs.o by_file.o by_dir.o x509_vpm.o x_attrib.o x_exten.o
|
||||||
|
|
||||||
SRC= $(LIBSRC)
|
SRC= $(LIBSRC)
|
||||||
|
|
||||||
|
@ -171,11 +171,7 @@ DECLARE_STACK_OF(X509_NAME)
|
|||||||
|
|
||||||
# define X509_EX_V_NETSCAPE_HACK 0x8000
|
# define X509_EX_V_NETSCAPE_HACK 0x8000
|
||||||
# define X509_EX_V_INIT 0x0001
|
# define X509_EX_V_INIT 0x0001
|
||||||
typedef struct X509_extension_st {
|
typedef struct X509_extension_st X509_EXTENSION;
|
||||||
ASN1_OBJECT *object;
|
|
||||||
ASN1_BOOLEAN critical;
|
|
||||||
ASN1_OCTET_STRING *value;
|
|
||||||
} X509_EXTENSION;
|
|
||||||
|
|
||||||
typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
|
typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
|
||||||
|
|
||||||
|
@ -86,3 +86,9 @@ struct x509_attributes_st {
|
|||||||
*/ ASN1_TYPE *single;
|
*/ ASN1_TYPE *single;
|
||||||
} value;
|
} value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct X509_extension_st {
|
||||||
|
ASN1_OBJECT *object;
|
||||||
|
ASN1_BOOLEAN critical;
|
||||||
|
ASN1_OCTET_STRING *value;
|
||||||
|
};
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
|
#include "x509_lcl.h"
|
||||||
|
|
||||||
int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x)
|
int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
#include <openssl/asn1.h>
|
#include <openssl/asn1.h>
|
||||||
#include <openssl/asn1t.h>
|
#include <openssl/asn1t.h>
|
||||||
|
#include "x509_lcl.h"
|
||||||
|
|
||||||
ASN1_SEQUENCE(X509_EXTENSION) = {
|
ASN1_SEQUENCE(X509_EXTENSION) = {
|
||||||
ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT),
|
ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT),
|
@ -117,7 +117,7 @@ const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid)
|
|||||||
const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext)
|
const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext)
|
||||||
{
|
{
|
||||||
int nid;
|
int nid;
|
||||||
if ((nid = OBJ_obj2nid(ext->object)) == NID_undef)
|
if ((nid = OBJ_obj2nid(X509_EXTENSION_get_object(ext))) == NID_undef)
|
||||||
return NULL;
|
return NULL;
|
||||||
return X509V3_EXT_get_nid(nid);
|
return X509V3_EXT_get_nid(nid);
|
||||||
}
|
}
|
||||||
@ -180,14 +180,17 @@ void *X509V3_EXT_d2i(X509_EXTENSION *ext)
|
|||||||
{
|
{
|
||||||
const X509V3_EXT_METHOD *method;
|
const X509V3_EXT_METHOD *method;
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
|
ASN1_STRING *extvalue;
|
||||||
|
int extlen;
|
||||||
|
|
||||||
if (!(method = X509V3_EXT_get(ext)))
|
if (!(method = X509V3_EXT_get(ext)))
|
||||||
return NULL;
|
return NULL;
|
||||||
p = ext->value->data;
|
extvalue = X509_EXTENSION_get_data(ext);
|
||||||
|
p = ASN1_STRING_data(extvalue);
|
||||||
|
extlen = ASN1_STRING_length(extvalue);
|
||||||
if (method->it)
|
if (method->it)
|
||||||
return ASN1_item_d2i(NULL, &p, ext->value->length,
|
return ASN1_item_d2i(NULL, &p, extlen, ASN1_ITEM_ptr(method->it));
|
||||||
ASN1_ITEM_ptr(method->it));
|
return method->d2i(NULL, &p, extlen);
|
||||||
return method->d2i(NULL, &p, ext->value->length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -226,7 +229,7 @@ void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit,
|
|||||||
lastpos = 0;
|
lastpos = 0;
|
||||||
for (i = lastpos; i < sk_X509_EXTENSION_num(x); i++) {
|
for (i = lastpos; i < sk_X509_EXTENSION_num(x); i++) {
|
||||||
ex = sk_X509_EXTENSION_value(x, i);
|
ex = sk_X509_EXTENSION_value(x, i);
|
||||||
if (OBJ_obj2nid(ex->object) == nid) {
|
if (OBJ_obj2nid(X509_EXTENSION_get_object(ex)) == nid) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
*idx = i;
|
*idx = i;
|
||||||
found_ex = ex;
|
found_ex = ex;
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
/* Extension printing routines */
|
/* Extension printing routines */
|
||||||
|
|
||||||
static int unknown_ext_print(BIO *out, X509_EXTENSION *ext,
|
static int unknown_ext_print(BIO *out, const unsigned char *ext, int extlen,
|
||||||
unsigned long flag, int indent, int supported);
|
unsigned long flag, int indent, int supported);
|
||||||
|
|
||||||
/* Print out a name+value stack */
|
/* Print out a name+value stack */
|
||||||
@ -120,23 +120,26 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
|
|||||||
{
|
{
|
||||||
void *ext_str = NULL;
|
void *ext_str = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
ASN1_OCTET_STRING *extoct;
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
|
int extlen;
|
||||||
const X509V3_EXT_METHOD *method;
|
const X509V3_EXT_METHOD *method;
|
||||||
STACK_OF(CONF_VALUE) *nval = NULL;
|
STACK_OF(CONF_VALUE) *nval = NULL;
|
||||||
int ok = 1;
|
int ok = 1;
|
||||||
|
|
||||||
|
extoct = X509_EXTENSION_get_data(ext);
|
||||||
|
p = ASN1_STRING_data(extoct);
|
||||||
|
extlen = ASN1_STRING_length(extoct);
|
||||||
|
|
||||||
if (!(method = X509V3_EXT_get(ext)))
|
if (!(method = X509V3_EXT_get(ext)))
|
||||||
return unknown_ext_print(out, ext, flag, indent, 0);
|
return unknown_ext_print(out, p, extlen, flag, indent, 0);
|
||||||
p = ext->value->data;
|
|
||||||
if (method->it)
|
if (method->it)
|
||||||
ext_str =
|
ext_str = ASN1_item_d2i(NULL, &p, extlen, ASN1_ITEM_ptr(method->it));
|
||||||
ASN1_item_d2i(NULL, &p, ext->value->length,
|
|
||||||
ASN1_ITEM_ptr(method->it));
|
|
||||||
else
|
else
|
||||||
ext_str = method->d2i(NULL, &p, ext->value->length);
|
ext_str = method->d2i(NULL, &p, extlen);
|
||||||
|
|
||||||
if (!ext_str)
|
if (!ext_str)
|
||||||
return unknown_ext_print(out, ext, flag, indent, 1);
|
return unknown_ext_print(out, p, extlen, flag, indent, 1);
|
||||||
|
|
||||||
if (method->i2s) {
|
if (method->i2s) {
|
||||||
if (!(value = method->i2s(method, ext_str))) {
|
if (!(value = method->i2s(method, ext_str))) {
|
||||||
@ -209,7 +212,7 @@ int X509V3_extensions_print(BIO *bp, char *title,
|
|||||||
return 0;
|
return 0;
|
||||||
if (!X509V3_EXT_print(bp, ex, flag, indent + 4)) {
|
if (!X509V3_EXT_print(bp, ex, flag, indent + 4)) {
|
||||||
BIO_printf(bp, "%*s", indent + 4, "");
|
BIO_printf(bp, "%*s", indent + 4, "");
|
||||||
ASN1_STRING_print(bp, ex->value);
|
ASN1_STRING_print(bp, X509_EXTENSION_get_data(ex));
|
||||||
}
|
}
|
||||||
if (BIO_write(bp, "\n", 1) <= 0)
|
if (BIO_write(bp, "\n", 1) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -217,7 +220,7 @@ int X509V3_extensions_print(BIO *bp, char *title,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unknown_ext_print(BIO *out, X509_EXTENSION *ext,
|
static int unknown_ext_print(BIO *out, const unsigned char *ext, int extlen,
|
||||||
unsigned long flag, int indent, int supported)
|
unsigned long flag, int indent, int supported)
|
||||||
{
|
{
|
||||||
switch (flag & X509V3_EXT_UNKNOWN_MASK) {
|
switch (flag & X509V3_EXT_UNKNOWN_MASK) {
|
||||||
@ -233,12 +236,9 @@ static int unknown_ext_print(BIO *out, X509_EXTENSION *ext,
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case X509V3_EXT_PARSE_UNKNOWN:
|
case X509V3_EXT_PARSE_UNKNOWN:
|
||||||
return ASN1_parse_dump(out,
|
return ASN1_parse_dump(out, ext, extlen, indent, -1);
|
||||||
ext->value->data, ext->value->length, indent,
|
|
||||||
-1);
|
|
||||||
case X509V3_EXT_DUMP_UNKNOWN:
|
case X509V3_EXT_DUMP_UNKNOWN:
|
||||||
return BIO_dump_indent(out, (char *)ext->value->data,
|
return BIO_dump_indent(out, (char *)ext, extlen, indent);
|
||||||
ext->value->length, indent);
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user