projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reorganize local header files
[openssl.git]
/
crypto
/
asn1
/
tasn_prn.c
diff --git
a/crypto/asn1/tasn_prn.c
b/crypto/asn1/tasn_prn.c
index 930ef97a9e9554d8875df8f2f16b5d1ea8f2e89c..ff86400d66893c8cd44d794c8ac1f8df51a7efaf 100644
(file)
--- a/
crypto/asn1/tasn_prn.c
+++ b/
crypto/asn1/tasn_prn.c
@@
-1,7
+1,7
@@
/*
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
*
/*
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
*
- * Licensed under the
OpenSSL license
(the "License"). You may not use
+ * Licensed under the
Apache License 2.0
(the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
@@
-15,8
+15,8
@@
#include <openssl/buffer.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
#include <openssl/buffer.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
-#include "
internal/asn1_int
.h"
-#include "asn1_locl.h"
+#include "
crypto/asn1
.h"
+#include "asn1_loc
a
l.h"
/*
* Print routines.
/*
* Print routines.
@@
-49,7
+49,7
@@
void ASN1_PCTX_free(ASN1_PCTX *p)
OPENSSL_free(p);
}
OPENSSL_free(p);
}
-unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p)
+unsigned long ASN1_PCTX_get_flags(
const
ASN1_PCTX *p)
{
return p->flags;
}
{
return p->flags;
}
@@
-59,7
+59,7
@@
void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags)
p->flags = flags;
}
p->flags = flags;
}
-unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p)
+unsigned long ASN1_PCTX_get_nm_flags(
const
ASN1_PCTX *p)
{
return p->nm_flags;
}
{
return p->nm_flags;
}
@@
-69,7
+69,7
@@
void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags)
p->nm_flags = flags;
}
p->nm_flags = flags;
}
-unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p)
+unsigned long ASN1_PCTX_get_cert_flags(
const
ASN1_PCTX *p)
{
return p->cert_flags;
}
{
return p->cert_flags;
}
@@
-79,7
+79,7
@@
void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags)
p->cert_flags = flags;
}
p->cert_flags = flags;
}
-unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p)
+unsigned long ASN1_PCTX_get_oid_flags(
const
ASN1_PCTX *p)
{
return p->oid_flags;
}
{
return p->oid_flags;
}
@@
-89,7
+89,7
@@
void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags)
p->oid_flags = flags;
}
p->oid_flags = flags;
}
-unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p)
+unsigned long ASN1_PCTX_get_str_flags(
const
ASN1_PCTX *p)
{
return p->str_flags;
}
{
return p->str_flags;
}
@@
-101,15
+101,15
@@
void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags)
/* Main print routines */
/* Main print routines */
-static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
+static int asn1_item_print_ctx(BIO *out,
const
ASN1_VALUE **fld, int indent,
const ASN1_ITEM *it,
const char *fname, const char *sname,
int nohdr, const ASN1_PCTX *pctx);
const ASN1_ITEM *it,
const char *fname, const char *sname,
int nohdr, const ASN1_PCTX *pctx);
-
int asn1_template_print_ctx(BIO *out,
ASN1_VALUE **fld, int indent,
+
static int asn1_template_print_ctx(BIO *out, const
ASN1_VALUE **fld, int indent,
const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx);
const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx);
-static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
+static int asn1_primitive_print(BIO *out,
const
ASN1_VALUE **fld,
const ASN1_ITEM *it, int indent,
const char *fname, const char *sname,
const ASN1_PCTX *pctx);
const ASN1_ITEM *it, int indent,
const char *fname, const char *sname,
const ASN1_PCTX *pctx);
@@
-118,7
+118,7
@@
static int asn1_print_fsname(BIO *out, int indent,
const char *fname, const char *sname,
const ASN1_PCTX *pctx);
const char *fname, const char *sname,
const ASN1_PCTX *pctx);
-int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
+int ASN1_item_print(BIO *out,
const
ASN1_VALUE *ifld, int indent,
const ASN1_ITEM *it, const ASN1_PCTX *pctx)
{
const char *sname;
const ASN1_ITEM *it, const ASN1_PCTX *pctx)
{
const char *sname;
@@
-131,27
+131,28
@@
int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
return asn1_item_print_ctx(out, &ifld, indent, it, NULL, sname, 0, pctx);
}
return asn1_item_print_ctx(out, &ifld, indent, it, NULL, sname, 0, pctx);
}
-static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
+static int asn1_item_print_ctx(BIO *out,
const
ASN1_VALUE **fld, int indent,
const ASN1_ITEM *it,
const char *fname, const char *sname,
int nohdr, const ASN1_PCTX *pctx)
{
const ASN1_TEMPLATE *tt;
const ASN1_EXTERN_FUNCS *ef;
const ASN1_ITEM *it,
const char *fname, const char *sname,
int nohdr, const ASN1_PCTX *pctx)
{
const ASN1_TEMPLATE *tt;
const ASN1_EXTERN_FUNCS *ef;
- ASN1_VALUE **tmpfld;
+
const
ASN1_VALUE **tmpfld;
const ASN1_AUX *aux = it->funcs;
const ASN1_AUX *aux = it->funcs;
- ASN1_aux_c
b *asn1_cb
;
+ ASN1_aux_c
onst_cb *asn1_cb = NULL
;
ASN1_PRINT_ARG parg;
int i;
ASN1_PRINT_ARG parg;
int i;
- if (aux
&& aux->asn1_cb
) {
+ if (aux
!= NULL
) {
parg.out = out;
parg.indent = indent;
parg.pctx = pctx;
parg.out = out;
parg.indent = indent;
parg.pctx = pctx;
- asn1_cb =
aux->asn1_cb;
- } else
- asn1_cb = 0;
+ asn1_cb =
((aux->flags & ASN1_AFLG_CONST_CB) != 0) ? aux->asn1_const_cb
+ : (ASN1_aux_const_cb *)aux->asn1_cb; /* backward compatibility */
+ }
- if (*fld == NULL) {
+ if (((it->itype != ASN1_ITYPE_PRIMITIVE)
+ || (it->utype != V_ASN1_BOOLEAN)) && *fld == NULL) {
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) {
if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
return 0;
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) {
if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
return 0;
@@
-194,7
+195,7
@@
static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
case ASN1_ITYPE_CHOICE:
/* CHOICE type, get selector */
case ASN1_ITYPE_CHOICE:
/* CHOICE type, get selector */
- i = asn1_get_choice_selector(fld, it);
+ i = asn1_get_choice_selector
_const
(fld, it);
/* This should never happen... */
if ((i < 0) || (i >= it->tcount)) {
if (BIO_printf(out, "ERROR: selector [%d] invalid\n", i) <= 0)
/* This should never happen... */
if ((i < 0) || (i >= it->tcount)) {
if (BIO_printf(out, "ERROR: selector [%d] invalid\n", i) <= 0)
@@
-202,7
+203,7
@@
static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
return 1;
}
tt = it->templates + i;
return 1;
}
tt = it->templates + i;
- tmpfld = asn1_get_field_ptr(fld, tt);
+ tmpfld = asn1_get_
const_
field_ptr(fld, tt);
if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx))
return 0;
break;
if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx))
return 0;
break;
@@
-232,10
+233,10
@@
static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
/* Print each field entry */
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
const ASN1_TEMPLATE *seqtt;
/* Print each field entry */
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
const ASN1_TEMPLATE *seqtt;
- seqtt = asn1_do_adb(fld, tt, 1);
+ seqtt = asn1_do_adb(
*
fld, tt, 1);
if (!seqtt)
return 0;
if (!seqtt)
return 0;
- tmpfld = asn1_get_field_ptr(fld, seqtt);
+ tmpfld = asn1_get_
const_
field_ptr(fld, seqtt);
if (!asn1_template_print_ctx(out, tmpfld,
indent + 2, seqtt, pctx))
return 0;
if (!asn1_template_print_ctx(out, tmpfld,
indent + 2, seqtt, pctx))
return 0;
@@
-260,12
+261,12
@@
static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
return 1;
}
return 1;
}
-
int asn1_template_print_ctx(BIO *out,
ASN1_VALUE **fld, int indent,
+
static int asn1_template_print_ctx(BIO *out, const
ASN1_VALUE **fld, int indent,
const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx)
{
int i, flags;
const char *sname, *fname;
const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx)
{
int i, flags;
const char *sname, *fname;
- ASN1_VALUE *tfld;
+
const
ASN1_VALUE *tfld;
flags = tt->flags;
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME)
sname = ASN1_ITEM_ptr(tt->item)->sname;
flags = tt->flags;
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME)
sname = ASN1_ITEM_ptr(tt->item)->sname;
@@
-281,14
+282,14
@@
int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
* a pointer to a field.
*/
if (flags & ASN1_TFLG_EMBED) {
* a pointer to a field.
*/
if (flags & ASN1_TFLG_EMBED) {
- tfld = (ASN1_VALUE *)fld;
+ tfld = (
const
ASN1_VALUE *)fld;
fld = &tfld;
}
if (flags & ASN1_TFLG_SK_MASK) {
char *tname;
fld = &tfld;
}
if (flags & ASN1_TFLG_SK_MASK) {
char *tname;
- ASN1_VALUE *skitem;
- STACK_OF(ASN1_VALUE) *stack;
+
const
ASN1_VALUE *skitem;
+ STACK_OF(
const_
ASN1_VALUE) *stack;
/* SET OF, SEQUENCE OF */
if (fname) {
/* SET OF, SEQUENCE OF */
if (fname) {
@@
-303,18
+304,19
@@
int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
} else if (BIO_printf(out, "%*s%s:\n", indent, "", fname) <= 0)
return 0;
}
} else if (BIO_printf(out, "%*s%s:\n", indent, "", fname) <= 0)
return 0;
}
- stack = (STACK_OF(ASN1_VALUE) *)*fld;
- for (i = 0; i < sk_ASN1_VALUE_num(stack); i++) {
+ stack = (STACK_OF(
const_
ASN1_VALUE) *)*fld;
+ for (i = 0; i < sk_
const_
ASN1_VALUE_num(stack); i++) {
if ((i > 0) && (BIO_puts(out, "\n") <= 0))
return 0;
if ((i > 0) && (BIO_puts(out, "\n") <= 0))
return 0;
- skitem = sk_ASN1_VALUE_value(stack, i);
+ skitem = sk_
const_
ASN1_VALUE_value(stack, i);
if (!asn1_item_print_ctx(out, &skitem, indent + 2,
ASN1_ITEM_ptr(tt->item), NULL, NULL, 1,
pctx))
return 0;
}
if (!asn1_item_print_ctx(out, &skitem, indent + 2,
ASN1_ITEM_ptr(tt->item), NULL, NULL, 1,
pctx))
return 0;
}
- if (!i && BIO_printf(out, "%*s<EMPTY>\n", indent + 2, "") <= 0)
+ if (i == 0 && BIO_printf(out, "%*s<%s>\n", indent + 2, "",
+ stack == NULL ? "ABSENT" : "EMPTY") <= 0)
return 0;
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) {
if (BIO_printf(out, "%*s}\n", indent, "") <= 0)
return 0;
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) {
if (BIO_printf(out, "%*s}\n", indent, "") <= 0)
@@
-388,7
+390,7
@@
static int asn1_print_boolean(BIO *out, int boolval)
}
}
-static int asn1_print_integer(BIO *out, ASN1_INTEGER *str)
+static int asn1_print_integer(BIO *out,
const
ASN1_INTEGER *str)
{
char *s;
int ret = 1;
{
char *s;
int ret = 1;
@@
-408,13
+410,13
@@
static int asn1_print_oid(BIO *out, const ASN1_OBJECT *oid)
ln = OBJ_nid2ln(OBJ_obj2nid(oid));
if (!ln)
ln = "";
ln = OBJ_nid2ln(OBJ_obj2nid(oid));
if (!ln)
ln = "";
- OBJ_obj2txt(objbuf, sizeof
objbuf
, oid, 1);
+ OBJ_obj2txt(objbuf, sizeof
(objbuf)
, oid, 1);
if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0)
return 0;
return 1;
}
if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0)
return 0;
return 1;
}
-static int asn1_print_obstring(BIO *out, ASN1_STRING *str, int indent)
+static int asn1_print_obstring(BIO *out,
const
ASN1_STRING *str, int indent)
{
if (str->type == V_ASN1_BIT_STRING) {
if (BIO_printf(out, " (%ld unused bits)\n", str->flags & 0x7) <= 0)
{
if (str->type == V_ASN1_BIT_STRING) {
if (BIO_printf(out, " (%ld unused bits)\n", str->flags & 0x7) <= 0)
@@
-422,13
+424,13
@@
static int asn1_print_obstring(BIO *out, ASN1_STRING *str, int indent)
} else if (BIO_puts(out, "\n") <= 0)
return 0;
if ((str->length > 0)
} else if (BIO_puts(out, "\n") <= 0)
return 0;
if ((str->length > 0)
- && BIO_dump_indent(out, (char *)str->data, str->length,
+ && BIO_dump_indent(out, (c
onst c
har *)str->data, str->length,
indent + 2) <= 0)
return 0;
return 1;
}
indent + 2) <= 0)
return 0;
return 1;
}
-static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
+static int asn1_primitive_print(BIO *out,
const
ASN1_VALUE **fld,
const ASN1_ITEM *it, int indent,
const char *fname, const char *sname,
const ASN1_PCTX *pctx)
const ASN1_ITEM *it, int indent,
const char *fname, const char *sname,
const ASN1_PCTX *pctx)
@@
-443,15
+445,20
@@
static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
return 0;
if (pf && pf->prim_print)
return pf->prim_print(out, fld, it, indent, pctx);
return 0;
if (pf && pf->prim_print)
return pf->prim_print(out, fld, it, indent, pctx);
- str = (ASN1_STRING *)*fld;
- if (it->itype == ASN1_ITYPE_MSTRING)
+ if (it->itype == ASN1_ITYPE_MSTRING) {
+ str = (ASN1_STRING *)*fld;
utype = str->type & ~V_ASN1_NEG;
utype = str->type & ~V_ASN1_NEG;
- else
+ } else {
utype = it->utype;
utype = it->utype;
+ if (utype == V_ASN1_BOOLEAN)
+ str = NULL;
+ else
+ str = (ASN1_STRING *)*fld;
+ }
if (utype == V_ASN1_ANY) {
if (utype == V_ASN1_ANY) {
-
ASN1_TYPE *atype = (
ASN1_TYPE *)*fld;
+
const ASN1_TYPE *atype = (const
ASN1_TYPE *)*fld;
utype = atype->type;
utype = atype->type;
- fld =
&atype->value.asn1_value;
+ fld =
(const ASN1_VALUE **)&atype->value.asn1_value; /* actually is const */
str = (ASN1_STRING *)*fld;
if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE)
pname = NULL;
str = (ASN1_STRING *)*fld;
if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE)
pname = NULL;