Latest update.
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include "asn1_local.h"
|
||||
#include <openssl/asn1t.h>
|
||||
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(ASN1_GENERALIZEDTIME)
|
||||
|
||||
/* This is the primary function used to parse ASN1_GENERALIZEDTIME */
|
||||
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ASN1_TIME)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(ASN1_TIME)
|
||||
|
||||
static int is_utc(const int year)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include "asn1_local.h"
|
||||
#include <openssl/asn1t.h>
|
||||
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(ASN1_UTCTIME)
|
||||
|
||||
/* This is the primary function used to parse ASN1_UTCTIME */
|
||||
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
|
||||
|
||||
@@ -78,7 +78,7 @@ static ASN1_ITEM_EXP *asn1_item_list[] = {
|
||||
ASN1_ITEM_ref(IPAddressRange),
|
||||
#endif
|
||||
ASN1_ITEM_ref(ISSUING_DIST_POINT),
|
||||
#if !OPENSSL_API_3
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
ASN1_ITEM_ref(LONG),
|
||||
#endif
|
||||
ASN1_ITEM_ref(NAME_CONSTRAINTS),
|
||||
@@ -164,7 +164,7 @@ static ASN1_ITEM_EXP *asn1_item_list[] = {
|
||||
ASN1_ITEM_ref(X509_SIG),
|
||||
ASN1_ITEM_ref(X509_VAL),
|
||||
ASN1_ITEM_ref(X509),
|
||||
#if !OPENSSL_API_3
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
ASN1_ITEM_ref(ZLONG),
|
||||
#endif
|
||||
ASN1_ITEM_ref(INT32),
|
||||
|
||||
@@ -383,7 +383,7 @@ const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x)
|
||||
return x->data;
|
||||
}
|
||||
|
||||
# if !OPENSSL_API_1_1_0
|
||||
# ifndef OPENSSL_NO_DEPRECATED_1_1_0
|
||||
unsigned char *ASN1_STRING_data(ASN1_STRING *x)
|
||||
{
|
||||
return x->data;
|
||||
|
||||
+58
-40
@@ -17,25 +17,44 @@
|
||||
#define ASN1_PARSE_MAXDEPTH 128
|
||||
#endif
|
||||
|
||||
static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
|
||||
int indent);
|
||||
static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
int offset, int depth, int indent, int dump);
|
||||
static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
|
||||
int indent)
|
||||
static int asn1_print_info(BIO *bp, long offset, int depth, int hl, long len,
|
||||
int tag, int xclass, int constructed, int indent)
|
||||
{
|
||||
static const char fmt[] = "%-18s";
|
||||
char str[128];
|
||||
const char *p;
|
||||
int pop_f_prefix = 0;
|
||||
long saved_indent = -1;
|
||||
int i = 0;
|
||||
|
||||
if (constructed & V_ASN1_CONSTRUCTED)
|
||||
p = "cons: ";
|
||||
else
|
||||
p = "prim: ";
|
||||
if (BIO_write(bp, p, 6) < 6)
|
||||
if (constructed != (V_ASN1_CONSTRUCTED | 1)) {
|
||||
if (BIO_snprintf(str, sizeof(str), "%5ld:d=%-2d hl=%ld l=%4ld %s",
|
||||
offset, depth, (long)hl, len, p) <= 0)
|
||||
goto err;
|
||||
} else {
|
||||
if (BIO_snprintf(str, sizeof(str), "%5ld:d=%-2d hl=%ld l=inf %s",
|
||||
offset, depth, (long)hl, p) <= 0)
|
||||
goto err;
|
||||
}
|
||||
if (BIO_set_prefix(bp, str) <= 0) {
|
||||
if ((bp = BIO_push(BIO_new(BIO_f_prefix()), bp)) == NULL)
|
||||
goto err;
|
||||
pop_f_prefix = 1;
|
||||
}
|
||||
saved_indent = BIO_get_indent(bp);
|
||||
if (BIO_set_prefix(bp, str) <= 0
|
||||
|| BIO_set_indent(bp, indent) < 0)
|
||||
goto err;
|
||||
BIO_indent(bp, indent, 128);
|
||||
|
||||
/*
|
||||
* BIO_set_prefix made a copy of |str|, so we can safely use it for
|
||||
* something else, ASN.1 tag printout.
|
||||
*/
|
||||
p = str;
|
||||
if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
|
||||
BIO_snprintf(str, sizeof(str), "priv [ %d ] ", tag);
|
||||
@@ -48,11 +67,17 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
|
||||
else
|
||||
p = ASN1_tag2str(tag);
|
||||
|
||||
if (BIO_printf(bp, fmt, p) <= 0)
|
||||
goto err;
|
||||
return 1;
|
||||
i = (BIO_printf(bp, "%-18s", p) > 0);
|
||||
err:
|
||||
return 0;
|
||||
if (saved_indent >= 0)
|
||||
BIO_set_indent(bp, saved_indent);
|
||||
if (pop_f_prefix) {
|
||||
BIO *next = BIO_pop(bp);
|
||||
|
||||
BIO_free(bp);
|
||||
bp = next;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent)
|
||||
@@ -75,6 +100,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
int nl, hl, j, r;
|
||||
ASN1_OBJECT *o = NULL;
|
||||
ASN1_OCTET_STRING *os = NULL;
|
||||
ASN1_INTEGER *ai = NULL;
|
||||
ASN1_ENUMERATED *ae = NULL;
|
||||
/* ASN1_BMPSTRING *bmp=NULL; */
|
||||
int dump_indent, dump_cont = 0;
|
||||
|
||||
@@ -100,19 +127,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
/*
|
||||
* if j == 0x21 it is a constructed indefinite length object
|
||||
*/
|
||||
if (BIO_printf(bp, "%5ld:", (long)offset + (long)(op - *pp))
|
||||
<= 0)
|
||||
goto end;
|
||||
|
||||
if (j != (V_ASN1_CONSTRUCTED | 1)) {
|
||||
if (BIO_printf(bp, "d=%-2d hl=%ld l=%4ld ",
|
||||
depth, (long)hl, len) <= 0)
|
||||
goto end;
|
||||
} else {
|
||||
if (BIO_printf(bp, "d=%-2d hl=%ld l=inf ", depth, (long)hl) <= 0)
|
||||
goto end;
|
||||
}
|
||||
if (!asn1_print_info(bp, tag, xclass, j, (indent) ? depth : 0))
|
||||
if (!asn1_print_info(bp, (long)offset + (long)(op - *pp), depth,
|
||||
hl, len, tag, xclass, j, (indent) ? depth : 0))
|
||||
goto end;
|
||||
if (j & V_ASN1_CONSTRUCTED) {
|
||||
const unsigned char *sp = p;
|
||||
@@ -250,22 +266,21 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
ASN1_OCTET_STRING_free(os);
|
||||
os = NULL;
|
||||
} else if (tag == V_ASN1_INTEGER) {
|
||||
ASN1_INTEGER *bs;
|
||||
int i;
|
||||
|
||||
opp = op;
|
||||
bs = d2i_ASN1_INTEGER(NULL, &opp, len + hl);
|
||||
if (bs != NULL) {
|
||||
ai = d2i_ASN1_INTEGER(NULL, &opp, len + hl);
|
||||
if (ai != NULL) {
|
||||
if (BIO_write(bp, ":", 1) <= 0)
|
||||
goto end;
|
||||
if (bs->type == V_ASN1_NEG_INTEGER)
|
||||
if (ai->type == V_ASN1_NEG_INTEGER)
|
||||
if (BIO_write(bp, "-", 1) <= 0)
|
||||
goto end;
|
||||
for (i = 0; i < bs->length; i++) {
|
||||
if (BIO_printf(bp, "%02X", bs->data[i]) <= 0)
|
||||
for (i = 0; i < ai->length; i++) {
|
||||
if (BIO_printf(bp, "%02X", ai->data[i]) <= 0)
|
||||
goto end;
|
||||
}
|
||||
if (bs->length == 0) {
|
||||
if (ai->length == 0) {
|
||||
if (BIO_write(bp, "00", 2) <= 0)
|
||||
goto end;
|
||||
}
|
||||
@@ -274,24 +289,24 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
goto end;
|
||||
dump_cont = 1;
|
||||
}
|
||||
ASN1_INTEGER_free(bs);
|
||||
ASN1_INTEGER_free(ai);
|
||||
ai = NULL;
|
||||
} else if (tag == V_ASN1_ENUMERATED) {
|
||||
ASN1_ENUMERATED *bs;
|
||||
int i;
|
||||
|
||||
opp = op;
|
||||
bs = d2i_ASN1_ENUMERATED(NULL, &opp, len + hl);
|
||||
if (bs != NULL) {
|
||||
ae = d2i_ASN1_ENUMERATED(NULL, &opp, len + hl);
|
||||
if (ae != NULL) {
|
||||
if (BIO_write(bp, ":", 1) <= 0)
|
||||
goto end;
|
||||
if (bs->type == V_ASN1_NEG_ENUMERATED)
|
||||
if (ae->type == V_ASN1_NEG_ENUMERATED)
|
||||
if (BIO_write(bp, "-", 1) <= 0)
|
||||
goto end;
|
||||
for (i = 0; i < bs->length; i++) {
|
||||
if (BIO_printf(bp, "%02X", bs->data[i]) <= 0)
|
||||
for (i = 0; i < ae->length; i++) {
|
||||
if (BIO_printf(bp, "%02X", ae->data[i]) <= 0)
|
||||
goto end;
|
||||
}
|
||||
if (bs->length == 0) {
|
||||
if (ae->length == 0) {
|
||||
if (BIO_write(bp, "00", 2) <= 0)
|
||||
goto end;
|
||||
}
|
||||
@@ -300,7 +315,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
goto end;
|
||||
dump_cont = 1;
|
||||
}
|
||||
ASN1_ENUMERATED_free(bs);
|
||||
ASN1_ENUMERATED_free(ae);
|
||||
ae = NULL;
|
||||
} else if (len > 0 && dump) {
|
||||
if (!nl) {
|
||||
if (BIO_write(bp, "\n", 1) <= 0)
|
||||
@@ -341,6 +357,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
end:
|
||||
ASN1_OBJECT_free(o);
|
||||
ASN1_OCTET_STRING_free(os);
|
||||
ASN1_INTEGER_free(ai);
|
||||
ASN1_ENUMERATED_free(ae);
|
||||
*pp = p;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* WARNING: do not edit!
|
||||
* Generated by crypto/asn1/charmap.pl
|
||||
*
|
||||
* Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -82,8 +82,8 @@ $arr[ord("?")] |= $PSTRING_CHAR;
|
||||
|
||||
# Now generate the C code
|
||||
|
||||
# Output year depends on the year of the script.
|
||||
my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
|
||||
# Year the file was generated.
|
||||
my $YEAR = [localtime()]->[5] + 1900;
|
||||
print <<EOF;
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1t.h>
|
||||
|
||||
#if OPENSSL_API_3
|
||||
#ifdef OPENSSL_NO_DEPRECATED_3_0
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
|
||||
Reference in New Issue
Block a user