Remove some dead code from crypto/asn1.
Change-Id: I36d90356550d8a377af0dd248c6ec72bcdde4351 Reviewed-on: https://boringssl-review.googlesource.com/17027 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
parent
2dfa1ba680
commit
1845d0dbdb
@ -28,7 +28,6 @@ add_library(
|
||||
f_enum.c
|
||||
f_int.c
|
||||
f_string.c
|
||||
t_bitst.c
|
||||
tasn_dec.c
|
||||
tasn_enc.c
|
||||
tasn_fre.c
|
||||
|
@ -140,6 +140,21 @@ void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef struct asn1_const_ctx_st
|
||||
{
|
||||
const unsigned char *p;/* work char pointer */
|
||||
int eos; /* end of sequence read for indefinite encoding */
|
||||
int error; /* error code to use when returning an error */
|
||||
int inf; /* constructed if 0x20, indefinite is 0x21 */
|
||||
int tag; /* tag from last 'get object' */
|
||||
int xclass; /* class from last 'get object' */
|
||||
long slen; /* length of last 'get object' */
|
||||
const unsigned char *max; /* largest value of p allowed */
|
||||
const unsigned char *q;/* temporary variable */
|
||||
const unsigned char **pp;/* variable */
|
||||
int line; /* used in error processing */
|
||||
} ASN1_const_CTX;
|
||||
|
||||
#define HEADER_SIZE 8
|
||||
#define ASN1_CHUNK_INITIAL_SIZE (16 * 1024)
|
||||
static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
|
@ -91,31 +91,3 @@ int ASN1_PRINTABLE_type(const unsigned char *s, int len)
|
||||
return (V_ASN1_IA5STRING);
|
||||
return (V_ASN1_PRINTABLESTRING);
|
||||
}
|
||||
|
||||
int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
|
||||
{
|
||||
int i;
|
||||
unsigned char *p;
|
||||
|
||||
if (s->type != V_ASN1_UNIVERSALSTRING)
|
||||
return (0);
|
||||
if ((s->length % 4) != 0)
|
||||
return (0);
|
||||
p = s->data;
|
||||
for (i = 0; i < s->length; i += 4) {
|
||||
if ((p[0] != '\0') || (p[1] != '\0') || (p[2] != '\0'))
|
||||
break;
|
||||
else
|
||||
p += 4;
|
||||
}
|
||||
if (i < s->length)
|
||||
return (0);
|
||||
p = s->data;
|
||||
for (i = 3; i < s->length; i += 4) {
|
||||
*(p++) = s->data[i];
|
||||
}
|
||||
*(p) = '\0';
|
||||
s->length /= 4;
|
||||
s->type = ASN1_PRINTABLE_type(s->data, s->length);
|
||||
return (1);
|
||||
}
|
||||
|
@ -107,30 +107,6 @@ static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
|
||||
long max);
|
||||
static void asn1_put_length(unsigned char **pp, int length);
|
||||
|
||||
static int _asn1_check_infinite_end(const unsigned char **p, long len)
|
||||
{
|
||||
/*
|
||||
* If there is 0 or 1 byte left, the length check should pick things up
|
||||
*/
|
||||
if (len <= 0)
|
||||
return (1);
|
||||
else if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0)) {
|
||||
(*p) += 2;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ASN1_check_infinite_end(unsigned char **p, long len)
|
||||
{
|
||||
return _asn1_check_infinite_end((const unsigned char **)p, len);
|
||||
}
|
||||
|
||||
int ASN1_const_check_infinite_end(const unsigned char **p, long len)
|
||||
{
|
||||
return _asn1_check_infinite_end(p, len);
|
||||
}
|
||||
|
||||
int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
|
||||
int *pclass, long omax)
|
||||
{
|
||||
@ -327,31 +303,6 @@ int ASN1_object_size(int constructed, int length, int tag)
|
||||
return ret + length;
|
||||
}
|
||||
|
||||
static int _asn1_Finish(ASN1_const_CTX *c)
|
||||
{
|
||||
if ((c->inf == (1 | V_ASN1_CONSTRUCTED)) && (!c->eos)) {
|
||||
if (!ASN1_const_check_infinite_end(&c->p, c->slen)) {
|
||||
c->error = ASN1_R_MISSING_ASN1_EOS;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
if (((c->slen != 0) && !(c->inf & 1)) || ((c->slen < 0) && (c->inf & 1))) {
|
||||
c->error = ASN1_R_ASN1_LENGTH_MISMATCH;
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int asn1_Finish(ASN1_CTX *c)
|
||||
{
|
||||
return _asn1_Finish((ASN1_const_CTX *)c);
|
||||
}
|
||||
|
||||
int asn1_const_Finish(ASN1_const_CTX *c)
|
||||
{
|
||||
return _asn1_Finish(c);
|
||||
}
|
||||
|
||||
int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
|
||||
{
|
||||
if (str == NULL)
|
||||
|
@ -1,103 +0,0 @@
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.] */
|
||||
|
||||
#include <openssl/asn1.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/mem.h>
|
||||
|
||||
int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
|
||||
BIT_STRING_BITNAME *tbl, int indent)
|
||||
{
|
||||
BIT_STRING_BITNAME *bnam;
|
||||
char first = 1;
|
||||
BIO_printf(out, "%*s", indent, "");
|
||||
for (bnam = tbl; bnam->lname; bnam++) {
|
||||
if (ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) {
|
||||
if (!first)
|
||||
BIO_puts(out, ", ");
|
||||
BIO_puts(out, bnam->lname);
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
BIO_puts(out, "\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
|
||||
BIT_STRING_BITNAME *tbl)
|
||||
{
|
||||
int bitnum;
|
||||
bitnum = ASN1_BIT_STRING_num_asc(name, tbl);
|
||||
if (bitnum < 0)
|
||||
return 0;
|
||||
if (bs) {
|
||||
if (!ASN1_BIT_STRING_set_bit(bs, bitnum, value))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl)
|
||||
{
|
||||
BIT_STRING_BITNAME *bnam;
|
||||
for (bnam = tbl; bnam->lname; bnam++) {
|
||||
if (!strcmp(bnam->sname, name) || !strcmp(bnam->lname, name))
|
||||
return bnam->bitnum;
|
||||
}
|
||||
return -1;
|
||||
}
|
@ -86,7 +86,6 @@ extern "C" {
|
||||
|
||||
#define V_ASN1_CONSTRUCTED 0x20
|
||||
#define V_ASN1_PRIMITIVE_TAG 0x1f
|
||||
#define V_ASN1_PRIMATIVE_TAG 0x1f
|
||||
|
||||
#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */
|
||||
#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */
|
||||
@ -157,51 +156,12 @@ extern "C" {
|
||||
#define MBSTRING_BMP (MBSTRING_FLAG|2)
|
||||
#define MBSTRING_UNIV (MBSTRING_FLAG|4)
|
||||
|
||||
#define SMIME_OLDMIME 0x400
|
||||
#define SMIME_CRLFEOL 0x800
|
||||
#define SMIME_STREAM 0x1000
|
||||
|
||||
#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */
|
||||
#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */
|
||||
|
||||
/* We MUST make sure that, except for constness, asn1_ctx_st and
|
||||
asn1_const_ctx are exactly the same. Fortunately, as soon as
|
||||
the old ASN1 parsing macros are gone, we can throw this away
|
||||
as well... */
|
||||
typedef struct asn1_ctx_st
|
||||
{
|
||||
unsigned char *p;/* work char pointer */
|
||||
int eos; /* end of sequence read for indefinite encoding */
|
||||
int error; /* error code to use when returning an error */
|
||||
int inf; /* constructed if 0x20, indefinite is 0x21 */
|
||||
int tag; /* tag from last 'get object' */
|
||||
int xclass; /* class from last 'get object' */
|
||||
long slen; /* length of last 'get object' */
|
||||
unsigned char *max; /* largest value of p allowed */
|
||||
unsigned char *q;/* temporary variable */
|
||||
unsigned char **pp;/* variable */
|
||||
int line; /* used in error processing */
|
||||
} ASN1_CTX;
|
||||
|
||||
typedef struct asn1_const_ctx_st
|
||||
{
|
||||
const unsigned char *p;/* work char pointer */
|
||||
int eos; /* end of sequence read for indefinite encoding */
|
||||
int error; /* error code to use when returning an error */
|
||||
int inf; /* constructed if 0x20, indefinite is 0x21 */
|
||||
int tag; /* tag from last 'get object' */
|
||||
int xclass; /* class from last 'get object' */
|
||||
long slen; /* length of last 'get object' */
|
||||
const unsigned char *max; /* largest value of p allowed */
|
||||
const unsigned char *q;/* temporary variable */
|
||||
const unsigned char **pp;/* variable */
|
||||
int line; /* used in error processing */
|
||||
} ASN1_const_CTX;
|
||||
|
||||
/* These are used internally in the ASN1_OBJECT to keep track of
|
||||
* whether the names and data need to be free()ed */
|
||||
#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */
|
||||
#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */
|
||||
#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */
|
||||
#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */
|
||||
struct asn1_object_st
|
||||
@ -222,12 +182,6 @@ DEFINE_STACK_OF(ASN1_OBJECT)
|
||||
*/
|
||||
#define ASN1_STRING_FLAG_NDEF 0x010
|
||||
|
||||
/* This flag is used by the CMS code to indicate that a string is not
|
||||
* complete and is a place holder for content when it had all been
|
||||
* accessed. The flag will be reset when content has been written to it.
|
||||
*/
|
||||
|
||||
#define ASN1_STRING_FLAG_CONT 0x020
|
||||
/* This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING
|
||||
* type.
|
||||
*/
|
||||
@ -354,11 +308,8 @@ typedef struct ASN1_VALUE_st ASN1_VALUE;
|
||||
#define CHECKED_PPTR_OF(type, p) \
|
||||
((void**) (1 ? p : (type**)0))
|
||||
|
||||
#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
|
||||
#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(const type *,unsigned char **)
|
||||
#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)
|
||||
|
||||
TYPEDEF_D2I2D_OF(void);
|
||||
typedef void *d2i_of_void(void **, const unsigned char **, long);
|
||||
typedef int i2d_of_void(const void *, unsigned char **);
|
||||
|
||||
/* The following macros and typedefs allow an ASN1_ITEM
|
||||
* to be embedded in a structure and referenced. Since
|
||||
@ -537,12 +488,6 @@ struct X509_algor_st
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
|
||||
|
||||
typedef struct NETSCAPE_X509_st
|
||||
{
|
||||
ASN1_OCTET_STRING *header;
|
||||
X509 *cert;
|
||||
} NETSCAPE_X509;
|
||||
|
||||
/* This is used to contain a list of bit names */
|
||||
typedef struct BIT_STRING_BITNAME_st {
|
||||
int bitnum;
|
||||
@ -724,10 +669,6 @@ OPENSSL_EXPORT int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value
|
||||
OPENSSL_EXPORT int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
|
||||
OPENSSL_EXPORT int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, unsigned char *flags, int flags_len);
|
||||
|
||||
OPENSSL_EXPORT int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, BIT_STRING_BITNAME *tbl, int indent);
|
||||
OPENSSL_EXPORT int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
|
||||
OPENSSL_EXPORT int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, BIT_STRING_BITNAME *tbl);
|
||||
|
||||
OPENSSL_EXPORT int i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
|
||||
OPENSSL_EXPORT int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length);
|
||||
|
||||
@ -814,14 +755,8 @@ OPENSSL_EXPORT int ASN1_PRINTABLE_type(const unsigned char *s, int max);
|
||||
|
||||
OPENSSL_EXPORT unsigned long ASN1_tag2bit(int tag);
|
||||
|
||||
/* PARSING */
|
||||
OPENSSL_EXPORT int asn1_Finish(ASN1_CTX *c);
|
||||
OPENSSL_EXPORT int asn1_const_Finish(ASN1_const_CTX *c);
|
||||
|
||||
/* SPECIALS */
|
||||
OPENSSL_EXPORT int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, int *pclass, long omax);
|
||||
OPENSSL_EXPORT int ASN1_check_infinite_end(unsigned char **p,long len);
|
||||
OPENSSL_EXPORT int ASN1_const_check_infinite_end(const unsigned char **p,long len);
|
||||
OPENSSL_EXPORT void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, int xclass);
|
||||
OPENSSL_EXPORT int ASN1_put_eoc(unsigned char **pp);
|
||||
OPENSSL_EXPORT int ASN1_object_size(int constructed, int length, int tag);
|
||||
@ -906,10 +841,6 @@ OPENSSL_EXPORT const char *ASN1_tag2str(int tag);
|
||||
|
||||
/* Used to load and write netscape format cert */
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)
|
||||
|
||||
int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
|
||||
|
||||
OPENSSL_EXPORT void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
|
||||
|
||||
OPENSSL_EXPORT ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct);
|
||||
|
Loading…
Reference in New Issue
Block a user