obj_dat.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* 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
* 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 <stdio.h>
#include <ctype.h>
#include "cryptlib.h"
/* obj_dat.h is generated from objects.h by obj_dat.pl */
#ifndef OPENSSL_NO_OBJECT
#include "obj_dat.h"
#else
/* You will have to load all the objects needed manually in the application */
#define NUM_NID 0
#define NUM_SN 0
#define NUM_LN 0
#define NUM_OBJ 0
static unsigned char lvalues[1];
#endif
static int sn_cmp(const void *a, const void *b);
static int ln_cmp(const void *a, const void *b);
static int obj_cmp(const void *a, const void *b);
#define ADDED_DATA 0
#define ADDED_SNAME 1
#define ADDED_LNAME 2
#define ADDED_NID 3
typedef struct added_obj_st
{
int type;
} ADDED_OBJ;
static int sn_cmp(const void *a, const void *b)
{
}
static int ln_cmp(const void *a, const void *b)
{
}
/* static unsigned long add_hash(ADDED_OBJ *ca) */
{
const ASN1_OBJECT *a;
int i;
unsigned long ret=0;
unsigned char *p;
{
case ADDED_DATA:
p=(unsigned char *)a->data;
for (i=0; i<a->length; i++)
break;
case ADDED_SNAME:
break;
case ADDED_LNAME:
break;
case ADDED_NID:
break;
default:
/* abort(); */
return 0;
}
ret&=0x3fffffffL;
return(ret);
}
/* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */
{
ASN1_OBJECT *a,*b;
int i;
if (i) return(i);
{
case ADDED_DATA:
if (i) return(i);
case ADDED_SNAME:
case ADDED_LNAME:
case ADDED_NID:
default:
/* abort(); */
return 0;
}
}
static int init_added(void)
{
}
{
}
{
ASN1_OBJECT_free(a->obj);
OPENSSL_free(a);
}
void OBJ_cleanup(void)
{
}
int OBJ_new_nid(int num)
{
int i;
i=new_nid;
return(i);
}
{
ASN1_OBJECT *o;
int i;
if (!init_added()) return(0);
for (i=ADDED_DATA; i<=ADDED_NID; i++)
{
{
/* memory leak, buit should not normally matter */
}
}
return(o->nid);
err:
for (i=ADDED_DATA; i<=ADDED_NID; i++)
if (o != NULL) OPENSSL_free(o);
return(NID_undef);
}
ASN1_OBJECT *OBJ_nid2obj(int n)
{
if ((n >= 0) && (n < NUM_NID))
{
{
return(NULL);
}
return((ASN1_OBJECT *)&(nid_objs[n]));
}
return(NULL);
else
{
else
{
return(NULL);
}
}
}
const char *OBJ_nid2sn(int n)
{
if ((n >= 0) && (n < NUM_NID))
{
{
return(NULL);
}
}
return(NULL);
else
{
else
{
return(NULL);
}
}
}
const char *OBJ_nid2ln(int n)
{
if ((n >= 0) && (n < NUM_NID))
{
{
return(NULL);
}
}
return(NULL);
else
{
else
{
return(NULL);
}
}
}
int OBJ_obj2nid(const ASN1_OBJECT *a)
{
ASN1_OBJECT **op;
if (a == NULL)
return(NID_undef);
if (a->nid != 0)
return(a->nid);
{
}
sizeof(ASN1_OBJECT *),obj_cmp);
return(NID_undef);
}
/* Convert an object name into an ASN1_OBJECT
* if "noname" is not set then search for short and long names first.
* This will convert the "dotted" form into an object: unlike OBJ_txt2nid
* it can be used with any objects, not just registered ones.
*/
{
unsigned char *buf,*p;
int i, j;
if(!no_name) {
return OBJ_nid2obj(nid);
}
/* Work out size of content octets */
if (i <= 0) {
/* Clear the error */
return NULL;
}
/* Work out total size */
j = ASN1_object_size(0,i,V_ASN1_OBJECT);
p = buf;
/* Write out tag+length */
/* Write out contents */
a2d_ASN1_OBJECT(p,i,s,-1);
p=buf;
return op;
}
{
unsigned long l;
unsigned char *p;
const char *s;
if (buf_len <= 0) return(0);
buf[0]='\0';
return(0);
}
p=a->data;
idx=0;
l=0;
l|=(p[idx]&0x7f);
if (!(p[idx] & 0x80)) break;
l<<=7L;
idx++;
}
idx++;
i=(int)(l/40);
if (i > 2) i=2;
l-=(long)(i*40);
buf_len-=i;
buf+=i;
n+=i;
l=0;
l|=p[idx]&0x7f;
if (!(p[idx] & 0x80)) {
if (buf_len > 0)
buf_len-=i;
buf+=i;
n+=i;
l=0;
}
l<<=7L;
}
} else {
s=OBJ_nid2ln(nid);
if (s == NULL)
s=OBJ_nid2sn(nid);
n=strlen(s);
}
return(n);
}
int OBJ_txt2nid(const char *s)
{
int nid;
obj = OBJ_txt2obj(s, 0);
return nid;
}
int OBJ_ln2nid(const char *s)
{
o.ln=s;
{
}
sizeof(ASN1_OBJECT *),ln_cmp);
}
int OBJ_sn2nid(const char *s)
{
o.sn=s;
{
}
sizeof(ASN1_OBJECT *),sn_cmp);
}
{
int j;
if (j) return(j);
}
int (*cmp)(const void *, const void *))
{
int l,h,i,c;
const char *p;
l=0;
h=num;
while (l < h)
{
i=(l+h)/2;
if (c < 0)
h=i;
else if (c > 0)
l=i+1;
else
return(p);
}
#ifdef CHARSET_EBCDIC
/* THIS IS A KLUDGE - Because the *_obj is sorted in ASCII order, and
* I don't have perl (yet), we revert to a *LINEAR* search
* when the object wasn't found in the binary search.
*/
for (i=0; i<num; ++i) {
return p;
}
#endif
return(NULL);
}
{
int i,num=0;
char *o,*s,*l=NULL;
for (;;)
{
s=o=NULL;
if (i <= 0) return(num);
o=s=buf;
while (isdigit((unsigned char)*s) || (*s == '.'))
s++;
if (*s != '\0')
{
*(s++)='\0';
while (isspace((unsigned char)*s))
s++;
if (*s == '\0')
s=NULL;
else
{
l=s;
while ((*l != '\0') && !isspace((unsigned char)*l))
l++;
if (*l != '\0')
{
*(l++)='\0';
while (isspace((unsigned char)*l))
l++;
if (*l == '\0') l=NULL;
}
else
l=NULL;
}
}
else
s=NULL;
if (!OBJ_create(o,s,l)) return(num);
num++;
}
/* return(num); */
}
{
int ok=0;
unsigned char *buf;
int i;
if (i <= 0) return(0);
{
return(0);
}
if (i == 0)
goto err;
goto err;
err:
return(ok);
}