mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Upgrade openssl from 1.1.0e to 1.1.1b, with source code. 4.0.78
This commit is contained in:
parent
8f1c992379
commit
96dbd7bced
1476 changed files with 616554 additions and 4 deletions
44
trunk/3rdparty/openssl-1.1-fit/crypto/objects/README
vendored
Normal file
44
trunk/3rdparty/openssl-1.1-fit/crypto/objects/README
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
objects.txt syntax
|
||||
------------------
|
||||
|
||||
To cover all the naming hacks that were previously in objects.h needed some
|
||||
kind of hacks in objects.txt.
|
||||
|
||||
The basic syntax for adding an object is as follows:
|
||||
|
||||
1 2 3 4 : shortName : Long Name
|
||||
|
||||
If Long Name contains only word characters and hyphen-minus
|
||||
(0x2D) or full stop (0x2E) then Long Name is used as basis
|
||||
for the base name in C. Otherwise, the shortName is used.
|
||||
|
||||
The base name (let's call it 'base') will then be used to
|
||||
create the C macros SN_base, LN_base, NID_base and OBJ_base.
|
||||
|
||||
Note that if the base name contains spaces, dashes or periods,
|
||||
those will be converted to underscore.
|
||||
|
||||
Then there are some extra commands:
|
||||
|
||||
!Alias foo 1 2 3 4
|
||||
|
||||
This just makes a name foo for an OID. The C macro
|
||||
OBJ_foo will be created as a result.
|
||||
|
||||
!Cname foo
|
||||
|
||||
This makes sure that the name foo will be used as base name
|
||||
in C.
|
||||
|
||||
!module foo
|
||||
1 2 3 4 : shortName : Long Name
|
||||
!global
|
||||
|
||||
The !module command was meant to define a kind of modularity.
|
||||
What it does is to make sure the module name is prepended
|
||||
to the base name. !global turns this off. This construction
|
||||
is not recursive.
|
||||
|
||||
Lines starting with # are treated as comments, as well as any line starting
|
||||
with ! and not matching the commands above.
|
||||
|
3
trunk/3rdparty/openssl-1.1-fit/crypto/objects/build.info
vendored
Normal file
3
trunk/3rdparty/openssl-1.1-fit/crypto/objects/build.info
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=\
|
||||
o_names.c obj_dat.c obj_lib.c obj_err.c obj_xref.c
|
406
trunk/3rdparty/openssl-1.1-fit/crypto/objects/o_names.c
vendored
Normal file
406
trunk/3rdparty/openssl-1.1-fit/crypto/objects/o_names.c
vendored
Normal file
|
@ -0,0 +1,406 @@
|
|||
/*
|
||||
* Copyright 1998-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/safestack.h>
|
||||
#include <openssl/e_os2.h>
|
||||
#include "internal/thread_once.h"
|
||||
#include "internal/lhash.h"
|
||||
#include "obj_lcl.h"
|
||||
#include "e_os.h"
|
||||
|
||||
/*
|
||||
* We define this wrapper for two reasons. Firstly, later versions of
|
||||
* DEC C add linkage information to certain functions, which makes it
|
||||
* tricky to use them as values to regular function pointers.
|
||||
* Secondly, in the EDK2 build environment, the strcasecmp function is
|
||||
* actually an external function with the Microsoft ABI, so we can't
|
||||
* transparently assign function pointers to it.
|
||||
*/
|
||||
#if defined(OPENSSL_SYS_VMS_DECC) || defined(OPENSSL_SYS_UEFI)
|
||||
static int obj_strcasecmp(const char *a, const char *b)
|
||||
{
|
||||
return strcasecmp(a, b);
|
||||
}
|
||||
#else
|
||||
#define obj_strcasecmp strcasecmp
|
||||
#endif
|
||||
|
||||
/*
|
||||
* I use the ex_data stuff to manage the identifiers for the obj_name_types
|
||||
* that applications may define. I only really use the free function field.
|
||||
*/
|
||||
static LHASH_OF(OBJ_NAME) *names_lh = NULL;
|
||||
static int names_type_num = OBJ_NAME_TYPE_NUM;
|
||||
static CRYPTO_RWLOCK *obj_lock = NULL;
|
||||
|
||||
struct name_funcs_st {
|
||||
unsigned long (*hash_func) (const char *name);
|
||||
int (*cmp_func) (const char *a, const char *b);
|
||||
void (*free_func) (const char *, int, const char *);
|
||||
};
|
||||
|
||||
static STACK_OF(NAME_FUNCS) *name_funcs_stack;
|
||||
|
||||
/*
|
||||
* The LHASH callbacks now use the raw "void *" prototypes and do
|
||||
* per-variable casting in the functions. This prevents function pointer
|
||||
* casting without the need for macro-generated wrapper functions.
|
||||
*/
|
||||
|
||||
static unsigned long obj_name_hash(const OBJ_NAME *a);
|
||||
static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b);
|
||||
|
||||
static CRYPTO_ONCE init = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(o_names_init)
|
||||
{
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
|
||||
names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
|
||||
obj_lock = CRYPTO_THREAD_lock_new();
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
|
||||
return names_lh != NULL && obj_lock != NULL;
|
||||
}
|
||||
|
||||
int OBJ_NAME_init(void)
|
||||
{
|
||||
return RUN_ONCE(&init, o_names_init);
|
||||
}
|
||||
|
||||
int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),
|
||||
int (*cmp_func) (const char *, const char *),
|
||||
void (*free_func) (const char *, int, const char *))
|
||||
{
|
||||
int ret = 0, i, push;
|
||||
NAME_FUNCS *name_funcs;
|
||||
|
||||
if (!OBJ_NAME_init())
|
||||
return 0;
|
||||
|
||||
CRYPTO_THREAD_write_lock(obj_lock);
|
||||
|
||||
if (name_funcs_stack == NULL) {
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
|
||||
name_funcs_stack = sk_NAME_FUNCS_new_null();
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
|
||||
}
|
||||
if (name_funcs_stack == NULL) {
|
||||
/* ERROR */
|
||||
goto out;
|
||||
}
|
||||
ret = names_type_num;
|
||||
names_type_num++;
|
||||
for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
|
||||
name_funcs = OPENSSL_zalloc(sizeof(*name_funcs));
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
|
||||
if (name_funcs == NULL) {
|
||||
OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
name_funcs->hash_func = openssl_lh_strcasehash;
|
||||
name_funcs->cmp_func = obj_strcasecmp;
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
|
||||
|
||||
push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
|
||||
|
||||
if (!push) {
|
||||
OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);
|
||||
OPENSSL_free(name_funcs);
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);
|
||||
if (hash_func != NULL)
|
||||
name_funcs->hash_func = hash_func;
|
||||
if (cmp_func != NULL)
|
||||
name_funcs->cmp_func = cmp_func;
|
||||
if (free_func != NULL)
|
||||
name_funcs->free_func = free_func;
|
||||
|
||||
out:
|
||||
CRYPTO_THREAD_unlock(obj_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = a->type - b->type;
|
||||
if (ret == 0) {
|
||||
if ((name_funcs_stack != NULL)
|
||||
&& (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) {
|
||||
ret = sk_NAME_FUNCS_value(name_funcs_stack,
|
||||
a->type)->cmp_func(a->name, b->name);
|
||||
} else
|
||||
ret = strcasecmp(a->name, b->name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static unsigned long obj_name_hash(const OBJ_NAME *a)
|
||||
{
|
||||
unsigned long ret;
|
||||
|
||||
if ((name_funcs_stack != NULL)
|
||||
&& (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) {
|
||||
ret =
|
||||
sk_NAME_FUNCS_value(name_funcs_stack,
|
||||
a->type)->hash_func(a->name);
|
||||
} else {
|
||||
ret = openssl_lh_strcasehash(a->name);
|
||||
}
|
||||
ret ^= a->type;
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *OBJ_NAME_get(const char *name, int type)
|
||||
{
|
||||
OBJ_NAME on, *ret;
|
||||
int num = 0, alias;
|
||||
const char *value = NULL;
|
||||
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
if (!OBJ_NAME_init())
|
||||
return NULL;
|
||||
CRYPTO_THREAD_read_lock(obj_lock);
|
||||
|
||||
alias = type & OBJ_NAME_ALIAS;
|
||||
type &= ~OBJ_NAME_ALIAS;
|
||||
|
||||
on.name = name;
|
||||
on.type = type;
|
||||
|
||||
for (;;) {
|
||||
ret = lh_OBJ_NAME_retrieve(names_lh, &on);
|
||||
if (ret == NULL)
|
||||
break;
|
||||
if ((ret->alias) && !alias) {
|
||||
if (++num > 10)
|
||||
break;
|
||||
on.name = ret->data;
|
||||
} else {
|
||||
value = ret->data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CRYPTO_THREAD_unlock(obj_lock);
|
||||
return value;
|
||||
}
|
||||
|
||||
int OBJ_NAME_add(const char *name, int type, const char *data)
|
||||
{
|
||||
OBJ_NAME *onp, *ret;
|
||||
int alias, ok = 0;
|
||||
|
||||
if (!OBJ_NAME_init())
|
||||
return 0;
|
||||
|
||||
alias = type & OBJ_NAME_ALIAS;
|
||||
type &= ~OBJ_NAME_ALIAS;
|
||||
|
||||
onp = OPENSSL_malloc(sizeof(*onp));
|
||||
if (onp == NULL) {
|
||||
/* ERROR */
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
onp->name = name;
|
||||
onp->alias = alias;
|
||||
onp->type = type;
|
||||
onp->data = data;
|
||||
|
||||
CRYPTO_THREAD_write_lock(obj_lock);
|
||||
|
||||
ret = lh_OBJ_NAME_insert(names_lh, onp);
|
||||
if (ret != NULL) {
|
||||
/* free things */
|
||||
if ((name_funcs_stack != NULL)
|
||||
&& (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) {
|
||||
/*
|
||||
* XXX: I'm not sure I understand why the free function should
|
||||
* get three arguments... -- Richard Levitte
|
||||
*/
|
||||
sk_NAME_FUNCS_value(name_funcs_stack,
|
||||
ret->type)->free_func(ret->name, ret->type,
|
||||
ret->data);
|
||||
}
|
||||
OPENSSL_free(ret);
|
||||
} else {
|
||||
if (lh_OBJ_NAME_error(names_lh)) {
|
||||
/* ERROR */
|
||||
OPENSSL_free(onp);
|
||||
goto unlock;
|
||||
}
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
|
||||
unlock:
|
||||
CRYPTO_THREAD_unlock(obj_lock);
|
||||
return ok;
|
||||
}
|
||||
|
||||
int OBJ_NAME_remove(const char *name, int type)
|
||||
{
|
||||
OBJ_NAME on, *ret;
|
||||
int ok = 0;
|
||||
|
||||
if (!OBJ_NAME_init())
|
||||
return 0;
|
||||
|
||||
CRYPTO_THREAD_write_lock(obj_lock);
|
||||
|
||||
type &= ~OBJ_NAME_ALIAS;
|
||||
on.name = name;
|
||||
on.type = type;
|
||||
ret = lh_OBJ_NAME_delete(names_lh, &on);
|
||||
if (ret != NULL) {
|
||||
/* free things */
|
||||
if ((name_funcs_stack != NULL)
|
||||
&& (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) {
|
||||
/*
|
||||
* XXX: I'm not sure I understand why the free function should
|
||||
* get three arguments... -- Richard Levitte
|
||||
*/
|
||||
sk_NAME_FUNCS_value(name_funcs_stack,
|
||||
ret->type)->free_func(ret->name, ret->type,
|
||||
ret->data);
|
||||
}
|
||||
OPENSSL_free(ret);
|
||||
ok = 1;
|
||||
}
|
||||
|
||||
CRYPTO_THREAD_unlock(obj_lock);
|
||||
return ok;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
void (*fn) (const OBJ_NAME *, void *arg);
|
||||
void *arg;
|
||||
} OBJ_DOALL;
|
||||
|
||||
static void do_all_fn(const OBJ_NAME *name, OBJ_DOALL *d)
|
||||
{
|
||||
if (name->type == d->type)
|
||||
d->fn(name, d->arg);
|
||||
}
|
||||
|
||||
IMPLEMENT_LHASH_DOALL_ARG_CONST(OBJ_NAME, OBJ_DOALL);
|
||||
|
||||
void OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
OBJ_DOALL d;
|
||||
|
||||
d.type = type;
|
||||
d.fn = fn;
|
||||
d.arg = arg;
|
||||
|
||||
lh_OBJ_NAME_doall_OBJ_DOALL(names_lh, do_all_fn, &d);
|
||||
}
|
||||
|
||||
struct doall_sorted {
|
||||
int type;
|
||||
int n;
|
||||
const OBJ_NAME **names;
|
||||
};
|
||||
|
||||
static void do_all_sorted_fn(const OBJ_NAME *name, void *d_)
|
||||
{
|
||||
struct doall_sorted *d = d_;
|
||||
|
||||
if (name->type != d->type)
|
||||
return;
|
||||
|
||||
d->names[d->n++] = name;
|
||||
}
|
||||
|
||||
static int do_all_sorted_cmp(const void *n1_, const void *n2_)
|
||||
{
|
||||
const OBJ_NAME *const *n1 = n1_;
|
||||
const OBJ_NAME *const *n2 = n2_;
|
||||
|
||||
return strcmp((*n1)->name, (*n2)->name);
|
||||
}
|
||||
|
||||
void OBJ_NAME_do_all_sorted(int type,
|
||||
void (*fn) (const OBJ_NAME *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
struct doall_sorted d;
|
||||
int n;
|
||||
|
||||
d.type = type;
|
||||
d.names =
|
||||
OPENSSL_malloc(sizeof(*d.names) * lh_OBJ_NAME_num_items(names_lh));
|
||||
/* Really should return an error if !d.names...but its a void function! */
|
||||
if (d.names != NULL) {
|
||||
d.n = 0;
|
||||
OBJ_NAME_do_all(type, do_all_sorted_fn, &d);
|
||||
|
||||
qsort((void *)d.names, d.n, sizeof(*d.names), do_all_sorted_cmp);
|
||||
|
||||
for (n = 0; n < d.n; ++n)
|
||||
fn(d.names[n], arg);
|
||||
|
||||
OPENSSL_free((void *)d.names);
|
||||
}
|
||||
}
|
||||
|
||||
static int free_type;
|
||||
|
||||
static void names_lh_free_doall(OBJ_NAME *onp)
|
||||
{
|
||||
if (onp == NULL)
|
||||
return;
|
||||
|
||||
if (free_type < 0 || free_type == onp->type)
|
||||
OBJ_NAME_remove(onp->name, onp->type);
|
||||
}
|
||||
|
||||
static void name_funcs_free(NAME_FUNCS *ptr)
|
||||
{
|
||||
OPENSSL_free(ptr);
|
||||
}
|
||||
|
||||
void OBJ_NAME_cleanup(int type)
|
||||
{
|
||||
unsigned long down_load;
|
||||
|
||||
if (names_lh == NULL)
|
||||
return;
|
||||
|
||||
free_type = type;
|
||||
down_load = lh_OBJ_NAME_get_down_load(names_lh);
|
||||
lh_OBJ_NAME_set_down_load(names_lh, 0);
|
||||
|
||||
lh_OBJ_NAME_doall(names_lh, names_lh_free_doall);
|
||||
if (type < 0) {
|
||||
lh_OBJ_NAME_free(names_lh);
|
||||
sk_NAME_FUNCS_pop_free(name_funcs_stack, name_funcs_free);
|
||||
CRYPTO_THREAD_lock_free(obj_lock);
|
||||
names_lh = NULL;
|
||||
name_funcs_stack = NULL;
|
||||
obj_lock = NULL;
|
||||
} else
|
||||
lh_OBJ_NAME_set_down_load(names_lh, down_load);
|
||||
}
|
739
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_dat.c
vendored
Normal file
739
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_dat.c
vendored
Normal file
|
@ -0,0 +1,739 @@
|
|||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "internal/ctype.h"
|
||||
#include <limits.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include "internal/objects.h"
|
||||
#include <openssl/bn.h>
|
||||
#include "internal/asn1_int.h"
|
||||
#include "obj_lcl.h"
|
||||
|
||||
/* obj_dat.h is generated from objects.h by obj_dat.pl */
|
||||
#include "obj_dat.h"
|
||||
|
||||
DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn);
|
||||
DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln);
|
||||
DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
|
||||
|
||||
#define ADDED_DATA 0
|
||||
#define ADDED_SNAME 1
|
||||
#define ADDED_LNAME 2
|
||||
#define ADDED_NID 3
|
||||
|
||||
struct added_obj_st {
|
||||
int type;
|
||||
ASN1_OBJECT *obj;
|
||||
};
|
||||
|
||||
static int new_nid = NUM_NID;
|
||||
static LHASH_OF(ADDED_OBJ) *added = NULL;
|
||||
|
||||
static int sn_cmp(const ASN1_OBJECT *const *a, const unsigned int *b)
|
||||
{
|
||||
return strcmp((*a)->sn, nid_objs[*b].sn);
|
||||
}
|
||||
|
||||
IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn);
|
||||
|
||||
static int ln_cmp(const ASN1_OBJECT *const *a, const unsigned int *b)
|
||||
{
|
||||
return strcmp((*a)->ln, nid_objs[*b].ln);
|
||||
}
|
||||
|
||||
IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln);
|
||||
|
||||
static unsigned long added_obj_hash(const ADDED_OBJ *ca)
|
||||
{
|
||||
const ASN1_OBJECT *a;
|
||||
int i;
|
||||
unsigned long ret = 0;
|
||||
unsigned char *p;
|
||||
|
||||
a = ca->obj;
|
||||
switch (ca->type) {
|
||||
case ADDED_DATA:
|
||||
ret = a->length << 20L;
|
||||
p = (unsigned char *)a->data;
|
||||
for (i = 0; i < a->length; i++)
|
||||
ret ^= p[i] << ((i * 3) % 24);
|
||||
break;
|
||||
case ADDED_SNAME:
|
||||
ret = OPENSSL_LH_strhash(a->sn);
|
||||
break;
|
||||
case ADDED_LNAME:
|
||||
ret = OPENSSL_LH_strhash(a->ln);
|
||||
break;
|
||||
case ADDED_NID:
|
||||
ret = a->nid;
|
||||
break;
|
||||
default:
|
||||
/* abort(); */
|
||||
return 0;
|
||||
}
|
||||
ret &= 0x3fffffffL;
|
||||
ret |= ((unsigned long)ca->type) << 30L;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb)
|
||||
{
|
||||
ASN1_OBJECT *a, *b;
|
||||
int i;
|
||||
|
||||
i = ca->type - cb->type;
|
||||
if (i)
|
||||
return i;
|
||||
a = ca->obj;
|
||||
b = cb->obj;
|
||||
switch (ca->type) {
|
||||
case ADDED_DATA:
|
||||
i = (a->length - b->length);
|
||||
if (i)
|
||||
return i;
|
||||
return memcmp(a->data, b->data, (size_t)a->length);
|
||||
case ADDED_SNAME:
|
||||
if (a->sn == NULL)
|
||||
return -1;
|
||||
else if (b->sn == NULL)
|
||||
return 1;
|
||||
else
|
||||
return strcmp(a->sn, b->sn);
|
||||
case ADDED_LNAME:
|
||||
if (a->ln == NULL)
|
||||
return -1;
|
||||
else if (b->ln == NULL)
|
||||
return 1;
|
||||
else
|
||||
return strcmp(a->ln, b->ln);
|
||||
case ADDED_NID:
|
||||
return a->nid - b->nid;
|
||||
default:
|
||||
/* abort(); */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int init_added(void)
|
||||
{
|
||||
if (added != NULL)
|
||||
return 1;
|
||||
added = lh_ADDED_OBJ_new(added_obj_hash, added_obj_cmp);
|
||||
return added != NULL;
|
||||
}
|
||||
|
||||
static void cleanup1_doall(ADDED_OBJ *a)
|
||||
{
|
||||
a->obj->nid = 0;
|
||||
a->obj->flags |= ASN1_OBJECT_FLAG_DYNAMIC |
|
||||
ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||
}
|
||||
|
||||
static void cleanup2_doall(ADDED_OBJ *a)
|
||||
{
|
||||
a->obj->nid++;
|
||||
}
|
||||
|
||||
static void cleanup3_doall(ADDED_OBJ *a)
|
||||
{
|
||||
if (--a->obj->nid == 0)
|
||||
ASN1_OBJECT_free(a->obj);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
void obj_cleanup_int(void)
|
||||
{
|
||||
if (added == NULL)
|
||||
return;
|
||||
lh_ADDED_OBJ_set_down_load(added, 0);
|
||||
lh_ADDED_OBJ_doall(added, cleanup1_doall); /* zero counters */
|
||||
lh_ADDED_OBJ_doall(added, cleanup2_doall); /* set counters */
|
||||
lh_ADDED_OBJ_doall(added, cleanup3_doall); /* free objects */
|
||||
lh_ADDED_OBJ_free(added);
|
||||
added = NULL;
|
||||
}
|
||||
|
||||
int OBJ_new_nid(int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = new_nid;
|
||||
new_nid += num;
|
||||
return i;
|
||||
}
|
||||
|
||||
int OBJ_add_object(const ASN1_OBJECT *obj)
|
||||
{
|
||||
ASN1_OBJECT *o;
|
||||
ADDED_OBJ *ao[4] = { NULL, NULL, NULL, NULL }, *aop;
|
||||
int i;
|
||||
|
||||
if (added == NULL)
|
||||
if (!init_added())
|
||||
return 0;
|
||||
if ((o = OBJ_dup(obj)) == NULL)
|
||||
goto err;
|
||||
if ((ao[ADDED_NID] = OPENSSL_malloc(sizeof(*ao[0]))) == NULL)
|
||||
goto err2;
|
||||
if ((o->length != 0) && (obj->data != NULL))
|
||||
if ((ao[ADDED_DATA] = OPENSSL_malloc(sizeof(*ao[0]))) == NULL)
|
||||
goto err2;
|
||||
if (o->sn != NULL)
|
||||
if ((ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(*ao[0]))) == NULL)
|
||||
goto err2;
|
||||
if (o->ln != NULL)
|
||||
if ((ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(*ao[0]))) == NULL)
|
||||
goto err2;
|
||||
|
||||
for (i = ADDED_DATA; i <= ADDED_NID; i++) {
|
||||
if (ao[i] != NULL) {
|
||||
ao[i]->type = i;
|
||||
ao[i]->obj = o;
|
||||
aop = lh_ADDED_OBJ_insert(added, ao[i]);
|
||||
/* memory leak, but should not normally matter */
|
||||
OPENSSL_free(aop);
|
||||
}
|
||||
}
|
||||
o->flags &=
|
||||
~(ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |
|
||||
ASN1_OBJECT_FLAG_DYNAMIC_DATA);
|
||||
|
||||
return o->nid;
|
||||
err2:
|
||||
OBJerr(OBJ_F_OBJ_ADD_OBJECT, ERR_R_MALLOC_FAILURE);
|
||||
err:
|
||||
for (i = ADDED_DATA; i <= ADDED_NID; i++)
|
||||
OPENSSL_free(ao[i]);
|
||||
ASN1_OBJECT_free(o);
|
||||
return NID_undef;
|
||||
}
|
||||
|
||||
ASN1_OBJECT *OBJ_nid2obj(int n)
|
||||
{
|
||||
ADDED_OBJ ad, *adp;
|
||||
ASN1_OBJECT ob;
|
||||
|
||||
if ((n >= 0) && (n < NUM_NID)) {
|
||||
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
|
||||
OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
|
||||
return NULL;
|
||||
}
|
||||
return (ASN1_OBJECT *)&(nid_objs[n]);
|
||||
} else if (added == NULL)
|
||||
return NULL;
|
||||
else {
|
||||
ad.type = ADDED_NID;
|
||||
ad.obj = &ob;
|
||||
ob.nid = n;
|
||||
adp = lh_ADDED_OBJ_retrieve(added, &ad);
|
||||
if (adp != NULL)
|
||||
return adp->obj;
|
||||
else {
|
||||
OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *OBJ_nid2sn(int n)
|
||||
{
|
||||
ADDED_OBJ ad, *adp;
|
||||
ASN1_OBJECT ob;
|
||||
|
||||
if ((n >= 0) && (n < NUM_NID)) {
|
||||
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
|
||||
OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);
|
||||
return NULL;
|
||||
}
|
||||
return nid_objs[n].sn;
|
||||
} else if (added == NULL)
|
||||
return NULL;
|
||||
else {
|
||||
ad.type = ADDED_NID;
|
||||
ad.obj = &ob;
|
||||
ob.nid = n;
|
||||
adp = lh_ADDED_OBJ_retrieve(added, &ad);
|
||||
if (adp != NULL)
|
||||
return adp->obj->sn;
|
||||
else {
|
||||
OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *OBJ_nid2ln(int n)
|
||||
{
|
||||
ADDED_OBJ ad, *adp;
|
||||
ASN1_OBJECT ob;
|
||||
|
||||
if ((n >= 0) && (n < NUM_NID)) {
|
||||
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
|
||||
OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID);
|
||||
return NULL;
|
||||
}
|
||||
return nid_objs[n].ln;
|
||||
} else if (added == NULL)
|
||||
return NULL;
|
||||
else {
|
||||
ad.type = ADDED_NID;
|
||||
ad.obj = &ob;
|
||||
ob.nid = n;
|
||||
adp = lh_ADDED_OBJ_retrieve(added, &ad);
|
||||
if (adp != NULL)
|
||||
return adp->obj->ln;
|
||||
else {
|
||||
OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int obj_cmp(const ASN1_OBJECT *const *ap, const unsigned int *bp)
|
||||
{
|
||||
int j;
|
||||
const ASN1_OBJECT *a = *ap;
|
||||
const ASN1_OBJECT *b = &nid_objs[*bp];
|
||||
|
||||
j = (a->length - b->length);
|
||||
if (j)
|
||||
return j;
|
||||
if (a->length == 0)
|
||||
return 0;
|
||||
return memcmp(a->data, b->data, a->length);
|
||||
}
|
||||
|
||||
IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
|
||||
|
||||
int OBJ_obj2nid(const ASN1_OBJECT *a)
|
||||
{
|
||||
const unsigned int *op;
|
||||
ADDED_OBJ ad, *adp;
|
||||
|
||||
if (a == NULL)
|
||||
return NID_undef;
|
||||
if (a->nid != 0)
|
||||
return a->nid;
|
||||
|
||||
if (a->length == 0)
|
||||
return NID_undef;
|
||||
|
||||
if (added != NULL) {
|
||||
ad.type = ADDED_DATA;
|
||||
ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
|
||||
adp = lh_ADDED_OBJ_retrieve(added, &ad);
|
||||
if (adp != NULL)
|
||||
return adp->obj->nid;
|
||||
}
|
||||
op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);
|
||||
if (op == NULL)
|
||||
return NID_undef;
|
||||
return nid_objs[*op].nid;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
|
||||
{
|
||||
int nid = NID_undef;
|
||||
ASN1_OBJECT *op;
|
||||
unsigned char *buf;
|
||||
unsigned char *p;
|
||||
const unsigned char *cp;
|
||||
int i, j;
|
||||
|
||||
if (!no_name) {
|
||||
if (((nid = OBJ_sn2nid(s)) != NID_undef) ||
|
||||
((nid = OBJ_ln2nid(s)) != NID_undef))
|
||||
return OBJ_nid2obj(nid);
|
||||
}
|
||||
|
||||
/* Work out size of content octets */
|
||||
i = a2d_ASN1_OBJECT(NULL, 0, s, -1);
|
||||
if (i <= 0) {
|
||||
/* Don't clear the error */
|
||||
/*
|
||||
* ERR_clear_error();
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
/* Work out total size */
|
||||
j = ASN1_object_size(0, i, V_ASN1_OBJECT);
|
||||
if (j < 0)
|
||||
return NULL;
|
||||
|
||||
if ((buf = OPENSSL_malloc(j)) == NULL) {
|
||||
OBJerr(OBJ_F_OBJ_TXT2OBJ, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = buf;
|
||||
/* Write out tag+length */
|
||||
ASN1_put_object(&p, 0, i, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);
|
||||
/* Write out contents */
|
||||
a2d_ASN1_OBJECT(p, i, s, -1);
|
||||
|
||||
cp = buf;
|
||||
op = d2i_ASN1_OBJECT(NULL, &cp, j);
|
||||
OPENSSL_free(buf);
|
||||
return op;
|
||||
}
|
||||
|
||||
int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
|
||||
{
|
||||
int i, n = 0, len, nid, first, use_bn;
|
||||
BIGNUM *bl;
|
||||
unsigned long l;
|
||||
const unsigned char *p;
|
||||
char tbuf[DECIMAL_SIZE(i) + DECIMAL_SIZE(l) + 2];
|
||||
|
||||
/* Ensure that, at every state, |buf| is NUL-terminated. */
|
||||
if (buf && buf_len > 0)
|
||||
buf[0] = '\0';
|
||||
|
||||
if ((a == NULL) || (a->data == NULL))
|
||||
return 0;
|
||||
|
||||
if (!no_name && (nid = OBJ_obj2nid(a)) != NID_undef) {
|
||||
const char *s;
|
||||
s = OBJ_nid2ln(nid);
|
||||
if (s == NULL)
|
||||
s = OBJ_nid2sn(nid);
|
||||
if (s) {
|
||||
if (buf)
|
||||
OPENSSL_strlcpy(buf, s, buf_len);
|
||||
n = strlen(s);
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
len = a->length;
|
||||
p = a->data;
|
||||
|
||||
first = 1;
|
||||
bl = NULL;
|
||||
|
||||
while (len > 0) {
|
||||
l = 0;
|
||||
use_bn = 0;
|
||||
for (;;) {
|
||||
unsigned char c = *p++;
|
||||
len--;
|
||||
if ((len == 0) && (c & 0x80))
|
||||
goto err;
|
||||
if (use_bn) {
|
||||
if (!BN_add_word(bl, c & 0x7f))
|
||||
goto err;
|
||||
} else
|
||||
l |= c & 0x7f;
|
||||
if (!(c & 0x80))
|
||||
break;
|
||||
if (!use_bn && (l > (ULONG_MAX >> 7L))) {
|
||||
if (bl == NULL && (bl = BN_new()) == NULL)
|
||||
goto err;
|
||||
if (!BN_set_word(bl, l))
|
||||
goto err;
|
||||
use_bn = 1;
|
||||
}
|
||||
if (use_bn) {
|
||||
if (!BN_lshift(bl, bl, 7))
|
||||
goto err;
|
||||
} else
|
||||
l <<= 7L;
|
||||
}
|
||||
|
||||
if (first) {
|
||||
first = 0;
|
||||
if (l >= 80) {
|
||||
i = 2;
|
||||
if (use_bn) {
|
||||
if (!BN_sub_word(bl, 80))
|
||||
goto err;
|
||||
} else
|
||||
l -= 80;
|
||||
} else {
|
||||
i = (int)(l / 40);
|
||||
l -= (long)(i * 40);
|
||||
}
|
||||
if (buf && (buf_len > 1)) {
|
||||
*buf++ = i + '0';
|
||||
*buf = '\0';
|
||||
buf_len--;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
|
||||
if (use_bn) {
|
||||
char *bndec;
|
||||
bndec = BN_bn2dec(bl);
|
||||
if (!bndec)
|
||||
goto err;
|
||||
i = strlen(bndec);
|
||||
if (buf) {
|
||||
if (buf_len > 1) {
|
||||
*buf++ = '.';
|
||||
*buf = '\0';
|
||||
buf_len--;
|
||||
}
|
||||
OPENSSL_strlcpy(buf, bndec, buf_len);
|
||||
if (i > buf_len) {
|
||||
buf += buf_len;
|
||||
buf_len = 0;
|
||||
} else {
|
||||
buf += i;
|
||||
buf_len -= i;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
n += i;
|
||||
OPENSSL_free(bndec);
|
||||
} else {
|
||||
BIO_snprintf(tbuf, sizeof(tbuf), ".%lu", l);
|
||||
i = strlen(tbuf);
|
||||
if (buf && (buf_len > 0)) {
|
||||
OPENSSL_strlcpy(buf, tbuf, buf_len);
|
||||
if (i > buf_len) {
|
||||
buf += buf_len;
|
||||
buf_len = 0;
|
||||
} else {
|
||||
buf += i;
|
||||
buf_len -= i;
|
||||
}
|
||||
}
|
||||
n += i;
|
||||
l = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BN_free(bl);
|
||||
return n;
|
||||
|
||||
err:
|
||||
BN_free(bl);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int OBJ_txt2nid(const char *s)
|
||||
{
|
||||
ASN1_OBJECT *obj;
|
||||
int nid;
|
||||
obj = OBJ_txt2obj(s, 0);
|
||||
nid = OBJ_obj2nid(obj);
|
||||
ASN1_OBJECT_free(obj);
|
||||
return nid;
|
||||
}
|
||||
|
||||
int OBJ_ln2nid(const char *s)
|
||||
{
|
||||
ASN1_OBJECT o;
|
||||
const ASN1_OBJECT *oo = &o;
|
||||
ADDED_OBJ ad, *adp;
|
||||
const unsigned int *op;
|
||||
|
||||
o.ln = s;
|
||||
if (added != NULL) {
|
||||
ad.type = ADDED_LNAME;
|
||||
ad.obj = &o;
|
||||
adp = lh_ADDED_OBJ_retrieve(added, &ad);
|
||||
if (adp != NULL)
|
||||
return adp->obj->nid;
|
||||
}
|
||||
op = OBJ_bsearch_ln(&oo, ln_objs, NUM_LN);
|
||||
if (op == NULL)
|
||||
return NID_undef;
|
||||
return nid_objs[*op].nid;
|
||||
}
|
||||
|
||||
int OBJ_sn2nid(const char *s)
|
||||
{
|
||||
ASN1_OBJECT o;
|
||||
const ASN1_OBJECT *oo = &o;
|
||||
ADDED_OBJ ad, *adp;
|
||||
const unsigned int *op;
|
||||
|
||||
o.sn = s;
|
||||
if (added != NULL) {
|
||||
ad.type = ADDED_SNAME;
|
||||
ad.obj = &o;
|
||||
adp = lh_ADDED_OBJ_retrieve(added, &ad);
|
||||
if (adp != NULL)
|
||||
return adp->obj->nid;
|
||||
}
|
||||
op = OBJ_bsearch_sn(&oo, sn_objs, NUM_SN);
|
||||
if (op == NULL)
|
||||
return NID_undef;
|
||||
return nid_objs[*op].nid;
|
||||
}
|
||||
|
||||
const void *OBJ_bsearch_(const void *key, const void *base, int num, int size,
|
||||
int (*cmp) (const void *, const void *))
|
||||
{
|
||||
return OBJ_bsearch_ex_(key, base, num, size, cmp, 0);
|
||||
}
|
||||
|
||||
const void *OBJ_bsearch_ex_(const void *key, const void *base_, int num,
|
||||
int size,
|
||||
int (*cmp) (const void *, const void *),
|
||||
int flags)
|
||||
{
|
||||
const char *base = base_;
|
||||
int l, h, i = 0, c = 0;
|
||||
const char *p = NULL;
|
||||
|
||||
if (num == 0)
|
||||
return NULL;
|
||||
l = 0;
|
||||
h = num;
|
||||
while (l < h) {
|
||||
i = (l + h) / 2;
|
||||
p = &(base[i * size]);
|
||||
c = (*cmp) (key, p);
|
||||
if (c < 0)
|
||||
h = i;
|
||||
else if (c > 0)
|
||||
l = i + 1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
#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.
|
||||
*/
|
||||
if (c != 0) {
|
||||
for (i = 0; i < num; ++i) {
|
||||
p = &(base[i * size]);
|
||||
c = (*cmp) (key, p);
|
||||
if (c == 0 || (c < 0 && (flags & OBJ_BSEARCH_VALUE_ON_NOMATCH)))
|
||||
return p;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH))
|
||||
p = NULL;
|
||||
else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH)) {
|
||||
while (i > 0 && (*cmp) (key, &(base[(i - 1) * size])) == 0)
|
||||
i--;
|
||||
p = &(base[i * size]);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a BIO sink to create some extra oid's objects.
|
||||
* Line format:<OID:isdigit or '.']><isspace><SN><isspace><LN>
|
||||
*/
|
||||
int OBJ_create_objects(BIO *in)
|
||||
{
|
||||
char buf[512];
|
||||
int i, num = 0;
|
||||
char *o, *s, *l = NULL;
|
||||
|
||||
for (;;) {
|
||||
s = o = NULL;
|
||||
i = BIO_gets(in, buf, 512);
|
||||
if (i <= 0)
|
||||
return num;
|
||||
buf[i - 1] = '\0';
|
||||
if (!ossl_isalnum(buf[0]))
|
||||
return num;
|
||||
o = s = buf;
|
||||
while (ossl_isdigit(*s) || *s == '.')
|
||||
s++;
|
||||
if (*s != '\0') {
|
||||
*(s++) = '\0';
|
||||
while (ossl_isspace(*s))
|
||||
s++;
|
||||
if (*s == '\0') {
|
||||
s = NULL;
|
||||
} else {
|
||||
l = s;
|
||||
while (*l != '\0' && !ossl_isspace(*l))
|
||||
l++;
|
||||
if (*l != '\0') {
|
||||
*(l++) = '\0';
|
||||
while (ossl_isspace(*l))
|
||||
l++;
|
||||
if (*l == '\0') {
|
||||
l = NULL;
|
||||
}
|
||||
} else {
|
||||
l = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s = NULL;
|
||||
}
|
||||
if (*o == '\0')
|
||||
return num;
|
||||
if (!OBJ_create(o, s, l))
|
||||
return num;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
int OBJ_create(const char *oid, const char *sn, const char *ln)
|
||||
{
|
||||
ASN1_OBJECT *tmpoid = NULL;
|
||||
int ok = 0;
|
||||
|
||||
/* Check to see if short or long name already present */
|
||||
if ((sn != NULL && OBJ_sn2nid(sn) != NID_undef)
|
||||
|| (ln != NULL && OBJ_ln2nid(ln) != NID_undef)) {
|
||||
OBJerr(OBJ_F_OBJ_CREATE, OBJ_R_OID_EXISTS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Convert numerical OID string to an ASN1_OBJECT structure */
|
||||
tmpoid = OBJ_txt2obj(oid, 1);
|
||||
if (tmpoid == NULL)
|
||||
return 0;
|
||||
|
||||
/* If NID is not NID_undef then object already exists */
|
||||
if (OBJ_obj2nid(tmpoid) != NID_undef) {
|
||||
OBJerr(OBJ_F_OBJ_CREATE, OBJ_R_OID_EXISTS);
|
||||
goto err;
|
||||
}
|
||||
|
||||
tmpoid->nid = OBJ_new_nid(1);
|
||||
tmpoid->sn = (char *)sn;
|
||||
tmpoid->ln = (char *)ln;
|
||||
|
||||
ok = OBJ_add_object(tmpoid);
|
||||
|
||||
tmpoid->sn = NULL;
|
||||
tmpoid->ln = NULL;
|
||||
|
||||
err:
|
||||
ASN1_OBJECT_free(tmpoid);
|
||||
return ok;
|
||||
}
|
||||
|
||||
size_t OBJ_length(const ASN1_OBJECT *obj)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return 0;
|
||||
return obj->length;
|
||||
}
|
||||
|
||||
const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return NULL;
|
||||
return obj->data;
|
||||
}
|
5733
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_dat.h
vendored
Normal file
5733
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_dat.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
228
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_dat.pl
vendored
Normal file
228
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_dat.pl
vendored
Normal file
|
@ -0,0 +1,228 @@
|
|||
#! /usr/bin/env perl
|
||||
# Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (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
|
||||
|
||||
use integer;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Generate the DER encoding for the given OID.
|
||||
sub der_it
|
||||
{
|
||||
# Prologue
|
||||
my ($v) = @_;
|
||||
my @a = split(/\s+/, $v);
|
||||
my $ret = pack("C*", $a[0] * 40 + $a[1]);
|
||||
shift @a;
|
||||
shift @a;
|
||||
|
||||
# Loop over rest of bytes; or in 0x80 for multi-byte numbers.
|
||||
my $t;
|
||||
foreach (@a) {
|
||||
my @r = ();
|
||||
$t = 0;
|
||||
while ($_ >= 128) {
|
||||
my $x = $_ % 128;
|
||||
$_ /= 128;
|
||||
push(@r, ($t++ ? 0x80 : 0) | $x);
|
||||
}
|
||||
push(@r, ($t++ ? 0x80 : 0) | $_);
|
||||
$ret .= pack("C*", reverse(@r));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# Output year depends on the year of the script and the input file.
|
||||
my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
|
||||
my $iYEAR = [localtime([stat($ARGV[0])]->[9])]->[5] + 1900;
|
||||
$YEAR = $iYEAR if $iYEAR > $YEAR;
|
||||
|
||||
# Read input, parse all #define's into OID name and value.
|
||||
# Populate %ln and %sn with long and short names (%dupln and %dupsn)
|
||||
# are used to watch for duplicates. Also %nid and %obj get the
|
||||
# NID and OBJ entries.
|
||||
my %ln;
|
||||
my %sn;
|
||||
my %dupln;
|
||||
my %dupsn;
|
||||
my %nid;
|
||||
my %obj;
|
||||
my %objd;
|
||||
open(IN, "$ARGV[0]") || die "Can't open input file $ARGV[0], $!";
|
||||
while (<IN>) {
|
||||
next unless /^\#define\s+(\S+)\s+(.*)$/;
|
||||
my $v = $1;
|
||||
my $d = $2;
|
||||
$d =~ s/^\"//;
|
||||
$d =~ s/\"$//;
|
||||
if ($v =~ /^SN_(.*)$/) {
|
||||
if (defined $dupsn{$d}) {
|
||||
print "WARNING: Duplicate short name \"$d\"\n";
|
||||
} else {
|
||||
$dupsn{$d} = 1;
|
||||
}
|
||||
$sn{$1} = $d;
|
||||
}
|
||||
elsif ($v =~ /^LN_(.*)$/) {
|
||||
if (defined $dupln{$d}) {
|
||||
print "WARNING: Duplicate long name \"$d\"\n";
|
||||
} else {
|
||||
$dupln{$d} = 1;
|
||||
}
|
||||
$ln{$1} = $d;
|
||||
}
|
||||
elsif ($v =~ /^NID_(.*)$/) {
|
||||
$nid{$d} = $1;
|
||||
}
|
||||
elsif ($v =~ /^OBJ_(.*)$/) {
|
||||
$obj{$1} = $v;
|
||||
$objd{$v} = $d;
|
||||
}
|
||||
}
|
||||
close IN;
|
||||
|
||||
# For every value in %obj, recursively expand OBJ_xxx values. That is:
|
||||
# #define OBJ_iso 1L
|
||||
# #define OBJ_identified_organization OBJ_iso,3L
|
||||
# Modify %objd values in-place. Create an %objn array that has
|
||||
my $changed;
|
||||
do {
|
||||
$changed = 0;
|
||||
foreach my $k (keys %objd) {
|
||||
$changed = 1 if $objd{$k} =~ s/(OBJ_[^,]+),/$objd{$1},/;
|
||||
}
|
||||
} while ($changed);
|
||||
|
||||
my @a = sort { $a <=> $b } keys %nid;
|
||||
my $n = $a[$#a] + 1;
|
||||
my @lvalues = ();
|
||||
my $lvalues = 0;
|
||||
|
||||
# Scan all defined objects, building up the @out array.
|
||||
# %obj_der holds the DER encoding as an array of bytes, and %obj_len
|
||||
# holds the length in bytes.
|
||||
my @out;
|
||||
my %obj_der;
|
||||
my %obj_len;
|
||||
for (my $i = 0; $i < $n; $i++) {
|
||||
if (!defined $nid{$i}) {
|
||||
push(@out, " { NULL, NULL, NID_undef },\n");
|
||||
next;
|
||||
}
|
||||
|
||||
my $sn = defined $sn{$nid{$i}} ? "$sn{$nid{$i}}" : "NULL";
|
||||
my $ln = defined $ln{$nid{$i}} ? "$ln{$nid{$i}}" : "NULL";
|
||||
if ($sn eq "NULL") {
|
||||
$sn = $ln;
|
||||
$sn{$nid{$i}} = $ln;
|
||||
}
|
||||
if ($ln eq "NULL") {
|
||||
$ln = $sn;
|
||||
$ln{$nid{$i}} = $sn;
|
||||
}
|
||||
|
||||
my $out = " {\"$sn\", \"$ln\", NID_$nid{$i}";
|
||||
if (defined $obj{$nid{$i}} && $objd{$obj{$nid{$i}}} =~ /,/) {
|
||||
my $v = $objd{$obj{$nid{$i}}};
|
||||
$v =~ s/L//g;
|
||||
$v =~ s/,/ /g;
|
||||
my $r = &der_it($v);
|
||||
my $z = "";
|
||||
my $length = 0;
|
||||
# Format using fixed-with because we use strcmp later.
|
||||
foreach (unpack("C*",$r)) {
|
||||
$z .= sprintf("0x%02X,", $_);
|
||||
$length++;
|
||||
}
|
||||
$obj_der{$obj{$nid{$i}}} = $z;
|
||||
$obj_len{$obj{$nid{$i}}} = $length;
|
||||
|
||||
push(@lvalues,
|
||||
sprintf(" %-45s /* [%5d] %s */\n",
|
||||
$z, $lvalues, $obj{$nid{$i}}));
|
||||
$out .= ", $length, &so[$lvalues]";
|
||||
$lvalues += $length;
|
||||
}
|
||||
$out .= "},\n";
|
||||
push(@out, $out);
|
||||
}
|
||||
|
||||
# Finally ready to generate the output.
|
||||
print <<"EOF";
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by crypto/objects/obj_dat.pl
|
||||
*
|
||||
* Copyright 1995-$YEAR The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
EOF
|
||||
|
||||
print "/* Serialized OID's */\n";
|
||||
printf "static const unsigned char so[%d] = {\n", $lvalues + 1;
|
||||
print @lvalues;
|
||||
print "};\n\n";
|
||||
|
||||
printf "#define NUM_NID %d\n", $n;
|
||||
printf "static const ASN1_OBJECT nid_objs[NUM_NID] = {\n";
|
||||
print @out;
|
||||
print "};\n\n";
|
||||
|
||||
{
|
||||
no warnings "uninitialized";
|
||||
@a = grep(defined $sn{$nid{$_}}, 0 .. $n);
|
||||
}
|
||||
printf "#define NUM_SN %d\n", $#a + 1;
|
||||
printf "static const unsigned int sn_objs[NUM_SN] = {\n";
|
||||
foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a) {
|
||||
printf " %4d, /* \"$sn{$nid{$_}}\" */\n", $_;
|
||||
}
|
||||
print "};\n\n";
|
||||
|
||||
{
|
||||
no warnings "uninitialized";
|
||||
@a = grep(defined $ln{$nid{$_}}, 0 .. $n);
|
||||
}
|
||||
printf "#define NUM_LN %d\n", $#a + 1;
|
||||
printf "static const unsigned int ln_objs[NUM_LN] = {\n";
|
||||
foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a) {
|
||||
printf " %4d, /* \"$ln{$nid{$_}}\" */\n", $_;
|
||||
}
|
||||
print "};\n\n";
|
||||
|
||||
{
|
||||
no warnings "uninitialized";
|
||||
@a = grep(defined $obj{$nid{$_}}, 0 .. $n);
|
||||
}
|
||||
printf "#define NUM_OBJ %d\n", $#a + 1;
|
||||
printf "static const unsigned int obj_objs[NUM_OBJ] = {\n";
|
||||
|
||||
# Compare DER; prefer shorter; if some length, use the "smaller" encoding.
|
||||
sub obj_cmp
|
||||
{
|
||||
no warnings "uninitialized";
|
||||
my $A = $obj_len{$obj{$nid{$a}}};
|
||||
my $B = $obj_len{$obj{$nid{$b}}};
|
||||
my $r = $A - $B;
|
||||
return $r if $r != 0;
|
||||
|
||||
$A = $obj_der{$obj{$nid{$a}}};
|
||||
$B = $obj_der{$obj{$nid{$b}}};
|
||||
return $A cmp $B;
|
||||
}
|
||||
foreach (sort obj_cmp @a) {
|
||||
my $m = $obj{$nid{$_}};
|
||||
my $v = $objd{$m};
|
||||
$v =~ s/L//g;
|
||||
$v =~ s/,/ /g;
|
||||
printf " %4d, /* %-32s %s */\n", $_, $m, $v;
|
||||
}
|
||||
print "};\n";
|
46
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_err.c
vendored
Normal file
46
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_err.c
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/objectserr.h>
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA OBJ_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_ADD_OBJECT, 0), "OBJ_add_object"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_ADD_SIGID, 0), "OBJ_add_sigid"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_CREATE, 0), "OBJ_create"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_DUP, 0), "OBJ_dup"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_NAME_NEW_INDEX, 0), "OBJ_NAME_new_index"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_NID2LN, 0), "OBJ_nid2ln"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_NID2OBJ, 0), "OBJ_nid2obj"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_NID2SN, 0), "OBJ_nid2sn"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, OBJ_F_OBJ_TXT2OBJ, 0), "OBJ_txt2obj"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA OBJ_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_OBJ, 0, OBJ_R_OID_EXISTS), "oid exists"},
|
||||
{ERR_PACK(ERR_LIB_OBJ, 0, OBJ_R_UNKNOWN_NID), "unknown nid"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int ERR_load_OBJ_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(OBJ_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(OBJ_str_functs);
|
||||
ERR_load_strings_const(OBJ_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
14
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_lcl.h
vendored
Normal file
14
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_lcl.h
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
typedef struct name_funcs_st NAME_FUNCS;
|
||||
DEFINE_STACK_OF(NAME_FUNCS)
|
||||
DEFINE_LHASH_OF(OBJ_NAME);
|
||||
typedef struct added_obj_st ADDED_OBJ;
|
||||
DEFINE_LHASH_OF(ADDED_OBJ);
|
65
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_lib.c
vendored
Normal file
65
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_lib.c
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/buffer.h>
|
||||
#include "internal/asn1_int.h"
|
||||
|
||||
ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
|
||||
{
|
||||
ASN1_OBJECT *r;
|
||||
|
||||
if (o == NULL)
|
||||
return NULL;
|
||||
/* If object isn't dynamic it's an internal OID which is never freed */
|
||||
if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC))
|
||||
return (ASN1_OBJECT *)o;
|
||||
|
||||
r = ASN1_OBJECT_new();
|
||||
if (r == NULL) {
|
||||
OBJerr(OBJ_F_OBJ_DUP, ERR_R_ASN1_LIB);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set dynamic flags so everything gets freed up on error */
|
||||
|
||||
r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC |
|
||||
ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |
|
||||
ASN1_OBJECT_FLAG_DYNAMIC_DATA);
|
||||
|
||||
if (o->length > 0 && (r->data = OPENSSL_memdup(o->data, o->length)) == NULL)
|
||||
goto err;
|
||||
|
||||
r->length = o->length;
|
||||
r->nid = o->nid;
|
||||
|
||||
if (o->ln != NULL && (r->ln = OPENSSL_strdup(o->ln)) == NULL)
|
||||
goto err;
|
||||
|
||||
if (o->sn != NULL && (r->sn = OPENSSL_strdup(o->sn)) == NULL)
|
||||
goto err;
|
||||
|
||||
return r;
|
||||
err:
|
||||
ASN1_OBJECT_free(r);
|
||||
OBJerr(OBJ_F_OBJ_DUP, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = (a->length - b->length);
|
||||
if (ret)
|
||||
return ret;
|
||||
return memcmp(a->data, b->data, a->length);
|
||||
}
|
1194
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_mac.num
vendored
Normal file
1194
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_mac.num
vendored
Normal file
File diff suppressed because it is too large
Load diff
139
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_xref.c
vendored
Normal file
139
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_xref.c
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
#include <openssl/objects.h>
|
||||
#include "obj_xref.h"
|
||||
#include "internal/nelem.h"
|
||||
#include <openssl/err.h>
|
||||
|
||||
static STACK_OF(nid_triple) *sig_app, *sigx_app;
|
||||
|
||||
static int sig_cmp(const nid_triple *a, const nid_triple *b)
|
||||
{
|
||||
return a->sign_id - b->sign_id;
|
||||
}
|
||||
|
||||
DECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig);
|
||||
IMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig);
|
||||
|
||||
static int sig_sk_cmp(const nid_triple *const *a, const nid_triple *const *b)
|
||||
{
|
||||
return (*a)->sign_id - (*b)->sign_id;
|
||||
}
|
||||
|
||||
DECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx);
|
||||
|
||||
static int sigx_cmp(const nid_triple *const *a, const nid_triple *const *b)
|
||||
{
|
||||
int ret;
|
||||
ret = (*a)->hash_id - (*b)->hash_id;
|
||||
if (ret)
|
||||
return ret;
|
||||
return (*a)->pkey_id - (*b)->pkey_id;
|
||||
}
|
||||
|
||||
IMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx);
|
||||
|
||||
int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid)
|
||||
{
|
||||
nid_triple tmp;
|
||||
const nid_triple *rv = NULL;
|
||||
tmp.sign_id = signid;
|
||||
|
||||
if (sig_app != NULL) {
|
||||
int idx = sk_nid_triple_find(sig_app, &tmp);
|
||||
rv = sk_nid_triple_value(sig_app, idx);
|
||||
}
|
||||
#ifndef OBJ_XREF_TEST2
|
||||
if (rv == NULL) {
|
||||
rv = OBJ_bsearch_sig(&tmp, sigoid_srt, OSSL_NELEM(sigoid_srt));
|
||||
}
|
||||
#endif
|
||||
if (rv == NULL)
|
||||
return 0;
|
||||
if (pdig_nid)
|
||||
*pdig_nid = rv->hash_id;
|
||||
if (ppkey_nid)
|
||||
*ppkey_nid = rv->pkey_id;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid)
|
||||
{
|
||||
nid_triple tmp;
|
||||
const nid_triple *t = &tmp;
|
||||
const nid_triple **rv = NULL;
|
||||
|
||||
tmp.hash_id = dig_nid;
|
||||
tmp.pkey_id = pkey_nid;
|
||||
|
||||
if (sigx_app) {
|
||||
int idx = sk_nid_triple_find(sigx_app, &tmp);
|
||||
if (idx >= 0) {
|
||||
t = sk_nid_triple_value(sigx_app, idx);
|
||||
rv = &t;
|
||||
}
|
||||
}
|
||||
#ifndef OBJ_XREF_TEST2
|
||||
if (rv == NULL) {
|
||||
rv = OBJ_bsearch_sigx(&t, sigoid_srt_xref, OSSL_NELEM(sigoid_srt_xref));
|
||||
}
|
||||
#endif
|
||||
if (rv == NULL)
|
||||
return 0;
|
||||
if (psignid)
|
||||
*psignid = (*rv)->sign_id;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int OBJ_add_sigid(int signid, int dig_id, int pkey_id)
|
||||
{
|
||||
nid_triple *ntr;
|
||||
if (sig_app == NULL)
|
||||
sig_app = sk_nid_triple_new(sig_sk_cmp);
|
||||
if (sig_app == NULL)
|
||||
return 0;
|
||||
if (sigx_app == NULL)
|
||||
sigx_app = sk_nid_triple_new(sigx_cmp);
|
||||
if (sigx_app == NULL)
|
||||
return 0;
|
||||
if ((ntr = OPENSSL_malloc(sizeof(*ntr))) == NULL) {
|
||||
OBJerr(OBJ_F_OBJ_ADD_SIGID, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
ntr->sign_id = signid;
|
||||
ntr->hash_id = dig_id;
|
||||
ntr->pkey_id = pkey_id;
|
||||
|
||||
if (!sk_nid_triple_push(sig_app, ntr)) {
|
||||
OPENSSL_free(ntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!sk_nid_triple_push(sigx_app, ntr))
|
||||
return 0;
|
||||
|
||||
sk_nid_triple_sort(sig_app);
|
||||
sk_nid_triple_sort(sigx_app);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void sid_free(nid_triple *tt)
|
||||
{
|
||||
OPENSSL_free(tt);
|
||||
}
|
||||
|
||||
void OBJ_sigid_free(void)
|
||||
{
|
||||
sk_nid_triple_pop_free(sig_app, sid_free);
|
||||
sig_app = NULL;
|
||||
sk_nid_triple_free(sigx_app);
|
||||
sigx_app = NULL;
|
||||
}
|
128
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_xref.h
vendored
Normal file
128
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_xref.h
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by objxref.pl
|
||||
*
|
||||
* Copyright 1998-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
int sign_id;
|
||||
int hash_id;
|
||||
int pkey_id;
|
||||
} nid_triple;
|
||||
|
||||
DEFINE_STACK_OF(nid_triple)
|
||||
|
||||
static const nid_triple sigoid_srt[] = {
|
||||
{NID_md2WithRSAEncryption, NID_md2, NID_rsaEncryption},
|
||||
{NID_md5WithRSAEncryption, NID_md5, NID_rsaEncryption},
|
||||
{NID_shaWithRSAEncryption, NID_sha, NID_rsaEncryption},
|
||||
{NID_sha1WithRSAEncryption, NID_sha1, NID_rsaEncryption},
|
||||
{NID_dsaWithSHA, NID_sha, NID_dsa},
|
||||
{NID_dsaWithSHA1_2, NID_sha1, NID_dsa_2},
|
||||
{NID_mdc2WithRSA, NID_mdc2, NID_rsaEncryption},
|
||||
{NID_md5WithRSA, NID_md5, NID_rsa},
|
||||
{NID_dsaWithSHA1, NID_sha1, NID_dsa},
|
||||
{NID_sha1WithRSA, NID_sha1, NID_rsa},
|
||||
{NID_ripemd160WithRSA, NID_ripemd160, NID_rsaEncryption},
|
||||
{NID_md4WithRSAEncryption, NID_md4, NID_rsaEncryption},
|
||||
{NID_ecdsa_with_SHA1, NID_sha1, NID_X9_62_id_ecPublicKey},
|
||||
{NID_sha256WithRSAEncryption, NID_sha256, NID_rsaEncryption},
|
||||
{NID_sha384WithRSAEncryption, NID_sha384, NID_rsaEncryption},
|
||||
{NID_sha512WithRSAEncryption, NID_sha512, NID_rsaEncryption},
|
||||
{NID_sha224WithRSAEncryption, NID_sha224, NID_rsaEncryption},
|
||||
{NID_ecdsa_with_Recommended, NID_undef, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_Specified, NID_undef, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_SHA224, NID_sha224, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_SHA256, NID_sha256, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_SHA384, NID_sha384, NID_X9_62_id_ecPublicKey},
|
||||
{NID_ecdsa_with_SHA512, NID_sha512, NID_X9_62_id_ecPublicKey},
|
||||
{NID_dsa_with_SHA224, NID_sha224, NID_dsa},
|
||||
{NID_dsa_with_SHA256, NID_sha256, NID_dsa},
|
||||
{NID_id_GostR3411_94_with_GostR3410_2001, NID_id_GostR3411_94,
|
||||
NID_id_GostR3410_2001},
|
||||
{NID_id_GostR3411_94_with_GostR3410_94, NID_id_GostR3411_94,
|
||||
NID_id_GostR3410_94},
|
||||
{NID_id_GostR3411_94_with_GostR3410_94_cc, NID_id_GostR3411_94,
|
||||
NID_id_GostR3410_94_cc},
|
||||
{NID_id_GostR3411_94_with_GostR3410_2001_cc, NID_id_GostR3411_94,
|
||||
NID_id_GostR3410_2001_cc},
|
||||
{NID_rsassaPss, NID_undef, NID_rsaEncryption},
|
||||
{NID_dhSinglePass_stdDH_sha1kdf_scheme, NID_sha1, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_stdDH_sha224kdf_scheme, NID_sha224, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_stdDH_sha256kdf_scheme, NID_sha256, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_stdDH_sha384kdf_scheme, NID_sha384, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_stdDH_sha512kdf_scheme, NID_sha512, NID_dh_std_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha1kdf_scheme, NID_sha1,
|
||||
NID_dh_cofactor_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha224kdf_scheme, NID_sha224,
|
||||
NID_dh_cofactor_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha256kdf_scheme, NID_sha256,
|
||||
NID_dh_cofactor_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha384kdf_scheme, NID_sha384,
|
||||
NID_dh_cofactor_kdf},
|
||||
{NID_dhSinglePass_cofactorDH_sha512kdf_scheme, NID_sha512,
|
||||
NID_dh_cofactor_kdf},
|
||||
{NID_id_tc26_signwithdigest_gost3410_2012_256, NID_id_GostR3411_2012_256,
|
||||
NID_id_GostR3410_2012_256},
|
||||
{NID_id_tc26_signwithdigest_gost3410_2012_512, NID_id_GostR3411_2012_512,
|
||||
NID_id_GostR3410_2012_512},
|
||||
{NID_ED25519, NID_undef, NID_ED25519},
|
||||
{NID_ED448, NID_undef, NID_ED448},
|
||||
{NID_RSA_SHA3_224, NID_sha3_224, NID_rsaEncryption},
|
||||
{NID_RSA_SHA3_256, NID_sha3_256, NID_rsaEncryption},
|
||||
{NID_RSA_SHA3_384, NID_sha3_384, NID_rsaEncryption},
|
||||
{NID_RSA_SHA3_512, NID_sha3_512, NID_rsaEncryption},
|
||||
};
|
||||
|
||||
static const nid_triple *const sigoid_srt_xref[] = {
|
||||
&sigoid_srt[0],
|
||||
&sigoid_srt[1],
|
||||
&sigoid_srt[7],
|
||||
&sigoid_srt[2],
|
||||
&sigoid_srt[4],
|
||||
&sigoid_srt[3],
|
||||
&sigoid_srt[9],
|
||||
&sigoid_srt[5],
|
||||
&sigoid_srt[8],
|
||||
&sigoid_srt[12],
|
||||
&sigoid_srt[30],
|
||||
&sigoid_srt[35],
|
||||
&sigoid_srt[6],
|
||||
&sigoid_srt[10],
|
||||
&sigoid_srt[11],
|
||||
&sigoid_srt[13],
|
||||
&sigoid_srt[24],
|
||||
&sigoid_srt[20],
|
||||
&sigoid_srt[32],
|
||||
&sigoid_srt[37],
|
||||
&sigoid_srt[14],
|
||||
&sigoid_srt[21],
|
||||
&sigoid_srt[33],
|
||||
&sigoid_srt[38],
|
||||
&sigoid_srt[15],
|
||||
&sigoid_srt[22],
|
||||
&sigoid_srt[34],
|
||||
&sigoid_srt[39],
|
||||
&sigoid_srt[16],
|
||||
&sigoid_srt[23],
|
||||
&sigoid_srt[19],
|
||||
&sigoid_srt[31],
|
||||
&sigoid_srt[36],
|
||||
&sigoid_srt[25],
|
||||
&sigoid_srt[26],
|
||||
&sigoid_srt[27],
|
||||
&sigoid_srt[28],
|
||||
&sigoid_srt[40],
|
||||
&sigoid_srt[41],
|
||||
&sigoid_srt[44],
|
||||
&sigoid_srt[45],
|
||||
&sigoid_srt[46],
|
||||
&sigoid_srt[47],
|
||||
};
|
66
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_xref.txt
vendored
Normal file
66
trunk/3rdparty/openssl-1.1-fit/crypto/objects/obj_xref.txt
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
# OID cross reference table.
|
||||
# Links signatures OIDs to their corresponding public key algorithms
|
||||
# and digests.
|
||||
|
||||
md2WithRSAEncryption md2 rsaEncryption
|
||||
md5WithRSAEncryption md5 rsaEncryption
|
||||
shaWithRSAEncryption sha rsaEncryption
|
||||
sha1WithRSAEncryption sha1 rsaEncryption
|
||||
md4WithRSAEncryption md4 rsaEncryption
|
||||
sha256WithRSAEncryption sha256 rsaEncryption
|
||||
sha384WithRSAEncryption sha384 rsaEncryption
|
||||
sha512WithRSAEncryption sha512 rsaEncryption
|
||||
sha224WithRSAEncryption sha224 rsaEncryption
|
||||
mdc2WithRSA mdc2 rsaEncryption
|
||||
ripemd160WithRSA ripemd160 rsaEncryption
|
||||
RSA_SHA3_224 sha3_224 rsaEncryption
|
||||
RSA_SHA3_256 sha3_256 rsaEncryption
|
||||
RSA_SHA3_384 sha3_384 rsaEncryption
|
||||
RSA_SHA3_512 sha3_512 rsaEncryption
|
||||
# For PSS the digest algorithm can vary and depends on the included
|
||||
# AlgorithmIdentifier. The digest "undef" indicates the public key
|
||||
# method should handle this explicitly.
|
||||
rsassaPss undef rsaEncryption
|
||||
ED25519 undef ED25519
|
||||
ED448 undef ED448
|
||||
|
||||
# Alternative deprecated OIDs. By using the older "rsa" OID this
|
||||
# type will be recognized by not normally used.
|
||||
|
||||
md5WithRSA md5 rsa
|
||||
sha1WithRSA sha1 rsa
|
||||
|
||||
dsaWithSHA sha dsa
|
||||
dsaWithSHA1 sha1 dsa
|
||||
|
||||
dsaWithSHA1_2 sha1 dsa_2
|
||||
|
||||
ecdsa_with_SHA1 sha1 X9_62_id_ecPublicKey
|
||||
ecdsa_with_SHA224 sha224 X9_62_id_ecPublicKey
|
||||
ecdsa_with_SHA256 sha256 X9_62_id_ecPublicKey
|
||||
ecdsa_with_SHA384 sha384 X9_62_id_ecPublicKey
|
||||
ecdsa_with_SHA512 sha512 X9_62_id_ecPublicKey
|
||||
ecdsa_with_Recommended undef X9_62_id_ecPublicKey
|
||||
ecdsa_with_Specified undef X9_62_id_ecPublicKey
|
||||
|
||||
dsa_with_SHA224 sha224 dsa
|
||||
dsa_with_SHA256 sha256 dsa
|
||||
|
||||
id_GostR3411_94_with_GostR3410_2001 id_GostR3411_94 id_GostR3410_2001
|
||||
id_GostR3411_94_with_GostR3410_94 id_GostR3411_94 id_GostR3410_94
|
||||
id_GostR3411_94_with_GostR3410_94_cc id_GostR3411_94 id_GostR3410_94_cc
|
||||
id_GostR3411_94_with_GostR3410_2001_cc id_GostR3411_94 id_GostR3410_2001_cc
|
||||
id_tc26_signwithdigest_gost3410_2012_256 id_GostR3411_2012_256 id_GostR3410_2012_256
|
||||
id_tc26_signwithdigest_gost3410_2012_512 id_GostR3411_2012_512 id_GostR3410_2012_512
|
||||
# ECDH KDFs and their corresponding message digests and schemes
|
||||
dhSinglePass_stdDH_sha1kdf_scheme sha1 dh_std_kdf
|
||||
dhSinglePass_stdDH_sha224kdf_scheme sha224 dh_std_kdf
|
||||
dhSinglePass_stdDH_sha256kdf_scheme sha256 dh_std_kdf
|
||||
dhSinglePass_stdDH_sha384kdf_scheme sha384 dh_std_kdf
|
||||
dhSinglePass_stdDH_sha512kdf_scheme sha512 dh_std_kdf
|
||||
|
||||
dhSinglePass_cofactorDH_sha1kdf_scheme sha1 dh_cofactor_kdf
|
||||
dhSinglePass_cofactorDH_sha224kdf_scheme sha224 dh_cofactor_kdf
|
||||
dhSinglePass_cofactorDH_sha256kdf_scheme sha256 dh_cofactor_kdf
|
||||
dhSinglePass_cofactorDH_sha384kdf_scheme sha384 dh_cofactor_kdf
|
||||
dhSinglePass_cofactorDH_sha512kdf_scheme sha512 dh_cofactor_kdf
|
203
trunk/3rdparty/openssl-1.1-fit/crypto/objects/objects.pl
vendored
Normal file
203
trunk/3rdparty/openssl-1.1-fit/crypto/objects/objects.pl
vendored
Normal file
|
@ -0,0 +1,203 @@
|
|||
#! /usr/bin/env perl
|
||||
# Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (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
|
||||
|
||||
use Getopt::Std;
|
||||
|
||||
our($opt_n);
|
||||
getopts('n');
|
||||
|
||||
# Output year depends on the year of the script and the input file.
|
||||
my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
|
||||
my $iYEAR = [localtime([stat($ARGV[0])]->[9])]->[5] + 1900;
|
||||
$YEAR = $iYEAR if $iYEAR > $YEAR;
|
||||
$iYEAR = [localtime([stat($ARGV[1])]->[9])]->[5] + 1900;
|
||||
$YEAR = $iYEAR if $iYEAR > $YEAR;
|
||||
|
||||
open (NUMIN,"$ARGV[1]") || die "Can't open number file $ARGV[1]";
|
||||
$max_nid=0;
|
||||
$o=0;
|
||||
while(<NUMIN>)
|
||||
{
|
||||
s|\R$||;
|
||||
$o++;
|
||||
s/#.*$//;
|
||||
next if /^\s*$/;
|
||||
$_ = 'X'.$_;
|
||||
($Cname,$mynum) = split;
|
||||
$Cname =~ s/^X//;
|
||||
if (defined($nidn{$mynum}))
|
||||
{ die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; }
|
||||
if (defined($nid{$Cname}))
|
||||
{ die "$ARGV[1]:$o:There's already an object with name ",$Cname," on line ",$order{$nid{$Cname}},"\n"; }
|
||||
$nid{$Cname} = $mynum;
|
||||
$nidn{$mynum} = $Cname;
|
||||
$order{$mynum} = $o;
|
||||
$max_nid = $mynum if $mynum > $max_nid;
|
||||
}
|
||||
close NUMIN;
|
||||
|
||||
open (IN,"$ARGV[0]") || die "Can't open input file $ARGV[0]";
|
||||
$Cname="";
|
||||
$o=0;
|
||||
while (<IN>)
|
||||
{
|
||||
s|\R$||;
|
||||
$o++;
|
||||
if (/^!module\s+(.*)$/)
|
||||
{
|
||||
$module = $1."-";
|
||||
$module =~ s/\./_/g;
|
||||
$module =~ s/-/_/g;
|
||||
}
|
||||
if (/^!global$/)
|
||||
{ $module = ""; }
|
||||
if (/^!Cname\s+(.*)$/)
|
||||
{ $Cname = $1; }
|
||||
if (/^!Alias\s+(.+?)\s+(.*)$/)
|
||||
{
|
||||
$Cname = $module.$1;
|
||||
$myoid = $2;
|
||||
$myoid = &process_oid($myoid);
|
||||
$Cname =~ s/-/_/g;
|
||||
$ordern{$o} = $Cname;
|
||||
$order{$Cname} = $o;
|
||||
$obj{$Cname} = $myoid;
|
||||
$_ = "";
|
||||
$Cname = "";
|
||||
}
|
||||
s/!.*$//;
|
||||
s/#.*$//;
|
||||
next if /^\s*$/;
|
||||
($myoid,$mysn,$myln) = split ':';
|
||||
$mysn =~ s/^\s*//;
|
||||
$mysn =~ s/\s*$//;
|
||||
$myln =~ s/^\s*//;
|
||||
$myln =~ s/\s*$//;
|
||||
$myoid =~ s/^\s*//;
|
||||
$myoid =~ s/\s*$//;
|
||||
if ($myoid ne "")
|
||||
{
|
||||
$myoid = &process_oid($myoid);
|
||||
}
|
||||
|
||||
if ($Cname eq "" && ($myln =~ /^[_A-Za-z][\w.-]*$/ ))
|
||||
{
|
||||
$Cname = $myln;
|
||||
$Cname =~ s/\./_/g;
|
||||
$Cname =~ s/-/_/g;
|
||||
if ($Cname ne "" && defined($ln{$module.$Cname}))
|
||||
{ die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
|
||||
}
|
||||
if ($Cname eq "")
|
||||
{
|
||||
$Cname = $mysn;
|
||||
$Cname =~ s/-/_/g;
|
||||
if ($Cname ne "" && defined($sn{$module.$Cname}))
|
||||
{ die "objects.txt:$o:There's already an object with short name ",$sn{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
|
||||
}
|
||||
if ($Cname eq "")
|
||||
{
|
||||
$Cname = $myln;
|
||||
$Cname =~ s/-/_/g;
|
||||
$Cname =~ s/\./_/g;
|
||||
$Cname =~ s/ /_/g;
|
||||
if ($Cname ne "" && defined($ln{$module.$Cname}))
|
||||
{ die "objects.txt:$o:There's already an object with long name ",$ln{$module.$Cname}," on line ",$order{$module.$Cname},"\n"; }
|
||||
}
|
||||
$Cname =~ s/\./_/g;
|
||||
$Cname =~ s/-/_/g;
|
||||
$Cname = $module.$Cname;
|
||||
$ordern{$o} = $Cname;
|
||||
$order{$Cname} = $o;
|
||||
$sn{$Cname} = $mysn;
|
||||
$ln{$Cname} = $myln;
|
||||
$obj{$Cname} = $myoid;
|
||||
if (!defined($nid{$Cname}))
|
||||
{
|
||||
$max_nid++;
|
||||
$nid{$Cname} = $max_nid;
|
||||
$nidn{$max_nid} = $Cname;
|
||||
print STDERR "Added OID $Cname\n";
|
||||
}
|
||||
$Cname="";
|
||||
}
|
||||
close IN;
|
||||
|
||||
if ( $opt_n ) {
|
||||
foreach (sort { $a <=> $b } keys %nidn)
|
||||
{
|
||||
print $nidn{$_},"\t\t",$_,"\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
print <<"EOF";
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by crypto/objects/objects.pl
|
||||
*
|
||||
* Copyright 2000-$YEAR The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
#define SN_undef "UNDEF"
|
||||
#define LN_undef "undefined"
|
||||
#define NID_undef 0
|
||||
#define OBJ_undef 0L
|
||||
EOF
|
||||
|
||||
sub expand
|
||||
{
|
||||
my $string = shift;
|
||||
|
||||
1 while $string =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
foreach (sort { $a <=> $b } keys %ordern)
|
||||
{
|
||||
$Cname=$ordern{$_};
|
||||
print "\n";
|
||||
print expand("#define SN_$Cname\t\t\"$sn{$Cname}\"\n") if $sn{$Cname} ne "";
|
||||
print expand("#define LN_$Cname\t\t\"$ln{$Cname}\"\n") if $ln{$Cname} ne "";
|
||||
print expand("#define NID_$Cname\t\t$nid{$Cname}\n") if $nid{$Cname} ne "";
|
||||
print expand("#define OBJ_$Cname\t\t$obj{$Cname}\n") if $obj{$Cname} ne "";
|
||||
}
|
||||
|
||||
sub process_oid
|
||||
{
|
||||
local($oid)=@_;
|
||||
local(@a,$oid_pref);
|
||||
|
||||
@a = split(/\s+/,$myoid);
|
||||
$pref_oid = "";
|
||||
$pref_sep = "";
|
||||
if (!($a[0] =~ /^[0-9]+$/))
|
||||
{
|
||||
$a[0] =~ s/-/_/g;
|
||||
if (!defined($obj{$a[0]}))
|
||||
{ die "$ARGV[0]:$o:Undefined identifier ",$a[0],"\n"; }
|
||||
$pref_oid = "OBJ_" . $a[0];
|
||||
$pref_sep = ",";
|
||||
shift @a;
|
||||
}
|
||||
$oids = join('L,',@a) . "L";
|
||||
if ($oids ne "L")
|
||||
{
|
||||
$oids = $pref_oid . $pref_sep . $oids;
|
||||
}
|
||||
else
|
||||
{
|
||||
$oids = $pref_oid;
|
||||
}
|
||||
return($oids);
|
||||
}
|
1677
trunk/3rdparty/openssl-1.1-fit/crypto/objects/objects.txt
vendored
Normal file
1677
trunk/3rdparty/openssl-1.1-fit/crypto/objects/objects.txt
vendored
Normal file
File diff suppressed because it is too large
Load diff
142
trunk/3rdparty/openssl-1.1-fit/crypto/objects/objxref.pl
vendored
Normal file
142
trunk/3rdparty/openssl-1.1-fit/crypto/objects/objxref.pl
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
#! /usr/bin/env perl
|
||||
# Copyright 1998-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (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
|
||||
|
||||
|
||||
use strict;
|
||||
|
||||
my %xref_tbl;
|
||||
my %oid_tbl;
|
||||
|
||||
my ($mac_file, $xref_file) = @ARGV;
|
||||
|
||||
# Output year depends on the year of the script and the input file.
|
||||
my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
|
||||
my $iYEAR = [localtime([stat($mac_file)]->[9])]->[5] + 1900;
|
||||
$YEAR = $iYEAR if $iYEAR > $YEAR;
|
||||
$iYEAR = [localtime([stat($xref_file)]->[9])]->[5] + 1900;
|
||||
$YEAR = $iYEAR if $iYEAR > $YEAR;
|
||||
|
||||
open(IN, $mac_file) || die "Can't open $mac_file, $!\n";
|
||||
|
||||
# Read in OID nid values for a lookup table.
|
||||
|
||||
while (<IN>)
|
||||
{
|
||||
s|\R$||; # Better chomp
|
||||
my ($name, $num) = /^(\S+)\s+(\S+)$/;
|
||||
$oid_tbl{$name} = $num;
|
||||
}
|
||||
close IN;
|
||||
|
||||
open(IN, $xref_file) || die "Can't open $xref_file, $!\n";
|
||||
|
||||
my $ln = 1;
|
||||
|
||||
while (<IN>)
|
||||
{
|
||||
s|\R$||; # Better chomp
|
||||
s/#.*$//;
|
||||
next if (/^\S*$/);
|
||||
my ($xr, $p1, $p2) = /^(\S+)\s+(\S+)\s+(\S+)/;
|
||||
check_oid($xr);
|
||||
check_oid($p1);
|
||||
check_oid($p2);
|
||||
$xref_tbl{$xr} = [$p1, $p2, $ln];
|
||||
}
|
||||
|
||||
my @xrkeys = keys %xref_tbl;
|
||||
|
||||
my @srt1 = sort { $oid_tbl{$a} <=> $oid_tbl{$b}} @xrkeys;
|
||||
|
||||
my $i;
|
||||
for($i = 0; $i <= $#srt1; $i++)
|
||||
{
|
||||
$xref_tbl{$srt1[$i]}[2] = $i;
|
||||
}
|
||||
|
||||
my @srt2 = sort
|
||||
{
|
||||
my$ap1 = $oid_tbl{$xref_tbl{$a}[0]};
|
||||
my$bp1 = $oid_tbl{$xref_tbl{$b}[0]};
|
||||
return $ap1 - $bp1 if ($ap1 != $bp1);
|
||||
my$ap2 = $oid_tbl{$xref_tbl{$a}[1]};
|
||||
my$bp2 = $oid_tbl{$xref_tbl{$b}[1]};
|
||||
|
||||
return $ap2 - $bp2;
|
||||
} @xrkeys;
|
||||
|
||||
my $pname = $0;
|
||||
$pname =~ s|.*/||;
|
||||
|
||||
print <<EOF;
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by $pname
|
||||
*
|
||||
* Copyright 1998-$YEAR The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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
|
||||
*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
int sign_id;
|
||||
int hash_id;
|
||||
int pkey_id;
|
||||
} nid_triple;
|
||||
|
||||
DEFINE_STACK_OF(nid_triple)
|
||||
|
||||
static const nid_triple sigoid_srt[] = {
|
||||
EOF
|
||||
|
||||
foreach (@srt1)
|
||||
{
|
||||
my $xr = $_;
|
||||
my ($p1, $p2) = @{$xref_tbl{$_}};
|
||||
my $o1 = " {NID_$xr, NID_$p1,";
|
||||
my $o2 = "NID_$p2},";
|
||||
if (length("$o1 $o2") < 78)
|
||||
{
|
||||
print "$o1 $o2\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "$o1\n $o2\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "};";
|
||||
print <<EOF;
|
||||
|
||||
|
||||
static const nid_triple *const sigoid_srt_xref[] = {
|
||||
EOF
|
||||
|
||||
foreach (@srt2)
|
||||
{
|
||||
my ($p1, $p2, $x) = @{$xref_tbl{$_}};
|
||||
# If digest or signature algorithm is "undef" then the algorithm
|
||||
# needs special handling and is excluded from the cross reference table.
|
||||
next if $p1 eq "undef" || $p2 eq "undef";
|
||||
print " \&sigoid_srt\[$x\],\n";
|
||||
}
|
||||
|
||||
print "};\n";
|
||||
|
||||
sub check_oid
|
||||
{
|
||||
my ($chk) = @_;
|
||||
if (!exists $oid_tbl{$chk})
|
||||
{
|
||||
die "Can't find \"$chk\"\n";
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue