1 /* $OpenBSD: obj_dat.c,v 1.54 2023/07/08 12:27:51 beck Exp $ */ 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * 9 * This library is free for commercial and non-commercial use as long as 10 * the following conditions are aheared to. The following conditions 11 * apply to all code found in this distribution, be it the RC4, RSA, 12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 * included with this distribution is covered by the same copyright terms 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 * 16 * Copyright remains Eric Young's, and as such any Copyright notices in 17 * the code are not to be removed. 18 * If this package is used in a product, Eric Young should be given attribution 19 * as the author of the parts of the library used. 20 * This can be in the form of a textual message at program startup or 21 * in documentation (online or textual) provided with the package. 22 * 23 * Redistribution and use in source and binary forms, with or without 24 * modification, are permitted provided that the following conditions 25 * are met: 26 * 1. Redistributions of source code must retain the copyright 27 * notice, this list of conditions and the following disclaimer. 28 * 2. Redistributions in binary form must reproduce the above copyright 29 * notice, this list of conditions and the following disclaimer in the 30 * documentation and/or other materials provided with the distribution. 31 * 3. All advertising materials mentioning features or use of this software 32 * must display the following acknowledgement: 33 * "This product includes cryptographic software written by 34 * Eric Young (eay@cryptsoft.com)" 35 * The word 'cryptographic' can be left out if the rouines from the library 36 * being used are not cryptographic related :-). 37 * 4. If you include any Windows specific code (or a derivative thereof) from 38 * the apps directory (application code) you must include an acknowledgement: 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 * 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 * SUCH DAMAGE. 52 * 53 * The licence and distribution terms for any publically available version or 54 * derivative of this code cannot be changed. i.e. this code cannot simply be 55 * copied and put under another distribution licence 56 * [including the GNU Public Licence.] 57 */ 58 59 #include <ctype.h> 60 #include <limits.h> 61 #include <stdio.h> 62 #include <string.h> 63 64 #include <openssl/opensslconf.h> 65 66 #include <openssl/asn1.h> 67 #include <openssl/bn.h> 68 #include <openssl/err.h> 69 #include <openssl/lhash.h> 70 #include <openssl/objects.h> 71 72 #include "asn1_local.h" 73 74 /* obj_dat.h is generated from objects.h by obj_dat.pl */ 75 #include "obj_dat.h" 76 77 static int sn_cmp_BSEARCH_CMP_FN(const void *, const void *); 78 static int sn_cmp(const ASN1_OBJECT * const *, unsigned int const *); 79 static unsigned int *OBJ_bsearch_sn(const ASN1_OBJECT * *key, unsigned int const *base, int num); 80 static int ln_cmp_BSEARCH_CMP_FN(const void *, const void *); 81 static int ln_cmp(const ASN1_OBJECT * const *, unsigned int const *); 82 static unsigned int *OBJ_bsearch_ln(const ASN1_OBJECT * *key, unsigned int const *base, int num); 83 static int obj_cmp_BSEARCH_CMP_FN(const void *, const void *); 84 static int obj_cmp(const ASN1_OBJECT * const *, unsigned int const *); 85 static unsigned int *OBJ_bsearch_obj(const ASN1_OBJECT * *key, unsigned int const *base, int num); 86 87 #define ADDED_DATA 0 88 #define ADDED_SNAME 1 89 #define ADDED_LNAME 2 90 #define ADDED_NID 3 91 92 typedef struct added_obj_st { 93 int type; 94 ASN1_OBJECT *obj; 95 } ADDED_OBJ; 96 DECLARE_LHASH_OF(ADDED_OBJ); 97 98 static int new_nid = NUM_NID; 99 static LHASH_OF(ADDED_OBJ) *added = NULL; 100 101 static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) 102 { 103 return (strcmp((*a)->sn, nid_objs[*b].sn)); 104 } 105 106 107 static int 108 sn_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) 109 { 110 const ASN1_OBJECT * const *a = a_; 111 unsigned int const *b = b_; 112 return sn_cmp(a, b); 113 } 114 115 static unsigned int * 116 OBJ_bsearch_sn(const ASN1_OBJECT * *key, unsigned int const *base, int num) 117 { 118 return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), 119 sn_cmp_BSEARCH_CMP_FN); 120 } 121 122 static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) 123 { 124 return (strcmp((*a)->ln, nid_objs[*b].ln)); 125 } 126 127 128 static int 129 ln_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) 130 { 131 const ASN1_OBJECT * const *a = a_; 132 unsigned int const *b = b_; 133 return ln_cmp(a, b); 134 } 135 136 static unsigned int * 137 OBJ_bsearch_ln(const ASN1_OBJECT * *key, unsigned int const *base, int num) 138 { 139 return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), 140 ln_cmp_BSEARCH_CMP_FN); 141 } 142 143 static unsigned long 144 added_obj_hash(const ADDED_OBJ *ca) 145 { 146 const ASN1_OBJECT *a; 147 int i; 148 unsigned long ret = 0; 149 unsigned char *p; 150 151 a = ca->obj; 152 switch (ca->type) { 153 case ADDED_DATA: 154 ret = a->length << 20L; 155 p = (unsigned char *)a->data; 156 for (i = 0; i < a->length; i++) 157 ret ^= p[i] << ((i * 3) % 24); 158 break; 159 case ADDED_SNAME: 160 ret = lh_strhash(a->sn); 161 break; 162 case ADDED_LNAME: 163 ret = lh_strhash(a->ln); 164 break; 165 case ADDED_NID: 166 ret = a->nid; 167 break; 168 default: 169 /* abort(); */ 170 return 0; 171 } 172 ret &= 0x3fffffffL; 173 ret |= ca->type << 30L; 174 return (ret); 175 } 176 static IMPLEMENT_LHASH_HASH_FN(added_obj, ADDED_OBJ) 177 178 static int 179 added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb) 180 { 181 ASN1_OBJECT *a, *b; 182 int i; 183 184 i = ca->type - cb->type; 185 if (i) 186 return (i); 187 a = ca->obj; 188 b = cb->obj; 189 switch (ca->type) { 190 case ADDED_DATA: 191 i = (a->length - b->length); 192 if (i) 193 return (i); 194 return (memcmp(a->data, b->data, (size_t)a->length)); 195 case ADDED_SNAME: 196 if (a->sn == NULL) 197 return (-1); 198 else if (b->sn == NULL) 199 return (1); 200 else 201 return (strcmp(a->sn, b->sn)); 202 case ADDED_LNAME: 203 if (a->ln == NULL) 204 return (-1); 205 else if (b->ln == NULL) 206 return (1); 207 else 208 return (strcmp(a->ln, b->ln)); 209 case ADDED_NID: 210 return (a->nid - b->nid); 211 default: 212 /* abort(); */ 213 return 0; 214 } 215 } 216 static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ) 217 218 static int 219 init_added(void) 220 { 221 if (added != NULL) 222 return (1); 223 added = lh_ADDED_OBJ_new(); 224 return (added != NULL); 225 } 226 227 static void 228 cleanup1_doall(ADDED_OBJ *a) 229 { 230 a->obj->nid = 0; 231 a->obj->flags |= ASN1_OBJECT_FLAG_DYNAMIC | 232 ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | 233 ASN1_OBJECT_FLAG_DYNAMIC_DATA; 234 } 235 236 static void cleanup2_doall(ADDED_OBJ *a) 237 { 238 a->obj->nid++; 239 } 240 241 static void 242 cleanup3_doall(ADDED_OBJ *a) 243 { 244 if (--a->obj->nid == 0) 245 ASN1_OBJECT_free(a->obj); 246 free(a); 247 } 248 249 static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ) 250 static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ) 251 static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ) 252 253 /* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting 254 * to use freed up OIDs. If necessary the actual freeing up of OIDs is 255 * delayed. 256 */ 257 258 int obj_cleanup_defer = 0; 259 260 void 261 check_defer(int nid) 262 { 263 if (!obj_cleanup_defer && nid >= NUM_NID) 264 obj_cleanup_defer = 1; 265 } 266 267 void 268 OBJ_cleanup(void) 269 { 270 if (obj_cleanup_defer) { 271 obj_cleanup_defer = 2; 272 return; 273 } 274 if (added == NULL) 275 return; 276 lh_ADDED_OBJ_down_load(added) = 0; 277 lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup1)); /* zero counters */ 278 lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup2)); /* set counters */ 279 lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup3)); /* free objects */ 280 lh_ADDED_OBJ_free(added); 281 added = NULL; 282 } 283 LCRYPTO_ALIAS(OBJ_cleanup); 284 285 int 286 OBJ_new_nid(int num) 287 { 288 int i; 289 290 i = new_nid; 291 new_nid += num; 292 return (i); 293 } 294 LCRYPTO_ALIAS(OBJ_new_nid); 295 296 int 297 OBJ_add_object(const ASN1_OBJECT *obj) 298 { 299 ASN1_OBJECT *o; 300 ADDED_OBJ *ao[4] = {NULL, NULL, NULL, NULL}, *aop; 301 int i; 302 303 if (added == NULL) 304 if (!init_added()) 305 return (0); 306 if ((o = OBJ_dup(obj)) == NULL) 307 goto err; 308 if (!(ao[ADDED_NID] = malloc(sizeof(ADDED_OBJ)))) 309 goto err2; 310 if ((o->length != 0) && (obj->data != NULL)) 311 if (!(ao[ADDED_DATA] = malloc(sizeof(ADDED_OBJ)))) 312 goto err2; 313 if (o->sn != NULL) 314 if (!(ao[ADDED_SNAME] = malloc(sizeof(ADDED_OBJ)))) 315 goto err2; 316 if (o->ln != NULL) 317 if (!(ao[ADDED_LNAME] = malloc(sizeof(ADDED_OBJ)))) 318 goto err2; 319 320 for (i = ADDED_DATA; i <= ADDED_NID; i++) { 321 if (ao[i] != NULL) { 322 ao[i]->type = i; 323 ao[i]->obj = o; 324 aop = lh_ADDED_OBJ_insert(added, ao[i]); 325 /* memory leak, but should not normally matter */ 326 free(aop); 327 } 328 } 329 o->flags &= ~(ASN1_OBJECT_FLAG_DYNAMIC | 330 ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | 331 ASN1_OBJECT_FLAG_DYNAMIC_DATA); 332 333 return (o->nid); 334 335 err2: 336 OBJerror(ERR_R_MALLOC_FAILURE); 337 err: 338 for (i = ADDED_DATA; i <= ADDED_NID; i++) 339 free(ao[i]); 340 ASN1_OBJECT_free(o); 341 return (NID_undef); 342 } 343 LCRYPTO_ALIAS(OBJ_add_object); 344 345 ASN1_OBJECT * 346 OBJ_nid2obj(int n) 347 { 348 ADDED_OBJ ad, *adp; 349 ASN1_OBJECT ob; 350 351 if ((n >= 0) && (n < NUM_NID)) { 352 if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) { 353 OBJerror(OBJ_R_UNKNOWN_NID); 354 return (NULL); 355 } 356 return ((ASN1_OBJECT *)&(nid_objs[n])); 357 } else if (added == NULL) 358 return (NULL); 359 else { 360 ad.type = ADDED_NID; 361 ad.obj = &ob; 362 ob.nid = n; 363 adp = lh_ADDED_OBJ_retrieve(added, &ad); 364 if (adp != NULL) 365 return (adp->obj); 366 else { 367 OBJerror(OBJ_R_UNKNOWN_NID); 368 return (NULL); 369 } 370 } 371 } 372 LCRYPTO_ALIAS(OBJ_nid2obj); 373 374 const char * 375 OBJ_nid2sn(int n) 376 { 377 ADDED_OBJ ad, *adp; 378 ASN1_OBJECT ob; 379 380 if ((n >= 0) && (n < NUM_NID)) { 381 if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) { 382 OBJerror(OBJ_R_UNKNOWN_NID); 383 return (NULL); 384 } 385 return (nid_objs[n].sn); 386 } else if (added == NULL) 387 return (NULL); 388 else { 389 ad.type = ADDED_NID; 390 ad.obj = &ob; 391 ob.nid = n; 392 adp = lh_ADDED_OBJ_retrieve(added, &ad); 393 if (adp != NULL) 394 return (adp->obj->sn); 395 else { 396 OBJerror(OBJ_R_UNKNOWN_NID); 397 return (NULL); 398 } 399 } 400 } 401 LCRYPTO_ALIAS(OBJ_nid2sn); 402 403 const char * 404 OBJ_nid2ln(int n) 405 { 406 ADDED_OBJ ad, *adp; 407 ASN1_OBJECT ob; 408 409 if ((n >= 0) && (n < NUM_NID)) { 410 if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) { 411 OBJerror(OBJ_R_UNKNOWN_NID); 412 return (NULL); 413 } 414 return (nid_objs[n].ln); 415 } else if (added == NULL) 416 return (NULL); 417 else { 418 ad.type = ADDED_NID; 419 ad.obj = &ob; 420 ob.nid = n; 421 adp = lh_ADDED_OBJ_retrieve(added, &ad); 422 if (adp != NULL) 423 return (adp->obj->ln); 424 else { 425 OBJerror(OBJ_R_UNKNOWN_NID); 426 return (NULL); 427 } 428 } 429 } 430 LCRYPTO_ALIAS(OBJ_nid2ln); 431 432 static int 433 obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp) 434 { 435 int j; 436 const ASN1_OBJECT *a= *ap; 437 const ASN1_OBJECT *b = &nid_objs[*bp]; 438 439 j = (a->length - b->length); 440 if (j) 441 return (j); 442 return (memcmp(a->data, b->data, a->length)); 443 } 444 445 446 static int 447 obj_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) 448 { 449 const ASN1_OBJECT * const *a = a_; 450 unsigned int const *b = b_; 451 return obj_cmp(a, b); 452 } 453 454 static unsigned int * 455 OBJ_bsearch_obj(const ASN1_OBJECT * *key, unsigned int const *base, int num) 456 { 457 return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), 458 obj_cmp_BSEARCH_CMP_FN); 459 } 460 461 int 462 OBJ_obj2nid(const ASN1_OBJECT *a) 463 { 464 const unsigned int *op; 465 ADDED_OBJ ad, *adp; 466 467 if (a == NULL || a->length == 0) 468 return (NID_undef); 469 if (a->nid != NID_undef) 470 return (a->nid); 471 472 if (added != NULL) { 473 ad.type = ADDED_DATA; 474 ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */ 475 adp = lh_ADDED_OBJ_retrieve(added, &ad); 476 if (adp != NULL) 477 return (adp->obj->nid); 478 } 479 op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ); 480 if (op == NULL) 481 return (NID_undef); 482 return (nid_objs[*op].nid); 483 } 484 LCRYPTO_ALIAS(OBJ_obj2nid); 485 486 /* Convert an object name into an ASN1_OBJECT 487 * if "noname" is not set then search for short and long names first. 488 * This will convert the "dotted" form into an object: unlike OBJ_txt2nid 489 * it can be used with any objects, not just registered ones. 490 */ 491 492 ASN1_OBJECT * 493 OBJ_txt2obj(const char *s, int no_name) 494 { 495 int nid; 496 497 if (!no_name) { 498 if (((nid = OBJ_sn2nid(s)) != NID_undef) || 499 ((nid = OBJ_ln2nid(s)) != NID_undef) ) 500 return OBJ_nid2obj(nid); 501 } 502 503 return t2i_ASN1_OBJECT_internal(s); 504 } 505 LCRYPTO_ALIAS(OBJ_txt2obj); 506 507 int 508 OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *aobj, int no_name) 509 { 510 return i2t_ASN1_OBJECT_internal(aobj, buf, buf_len, no_name); 511 } 512 LCRYPTO_ALIAS(OBJ_obj2txt); 513 514 int 515 OBJ_txt2nid(const char *s) 516 { 517 ASN1_OBJECT *obj; 518 int nid; 519 520 obj = OBJ_txt2obj(s, 0); 521 nid = OBJ_obj2nid(obj); 522 ASN1_OBJECT_free(obj); 523 return nid; 524 } 525 LCRYPTO_ALIAS(OBJ_txt2nid); 526 527 int 528 OBJ_ln2nid(const char *s) 529 { 530 ASN1_OBJECT o; 531 const ASN1_OBJECT *oo = &o; 532 ADDED_OBJ ad, *adp; 533 const unsigned int *op; 534 535 o.ln = s; 536 if (added != NULL) { 537 ad.type = ADDED_LNAME; 538 ad.obj = &o; 539 adp = lh_ADDED_OBJ_retrieve(added, &ad); 540 if (adp != NULL) 541 return (adp->obj->nid); 542 } 543 op = OBJ_bsearch_ln(&oo, ln_objs, NUM_LN); 544 if (op == NULL) 545 return (NID_undef); 546 return (nid_objs[*op].nid); 547 } 548 LCRYPTO_ALIAS(OBJ_ln2nid); 549 550 int 551 OBJ_sn2nid(const char *s) 552 { 553 ASN1_OBJECT o; 554 const ASN1_OBJECT *oo = &o; 555 ADDED_OBJ ad, *adp; 556 const unsigned int *op; 557 558 o.sn = s; 559 if (added != NULL) { 560 ad.type = ADDED_SNAME; 561 ad.obj = &o; 562 adp = lh_ADDED_OBJ_retrieve(added, &ad); 563 if (adp != NULL) 564 return (adp->obj->nid); 565 } 566 op = OBJ_bsearch_sn(&oo, sn_objs, NUM_SN); 567 if (op == NULL) 568 return (NID_undef); 569 return (nid_objs[*op].nid); 570 } 571 LCRYPTO_ALIAS(OBJ_sn2nid); 572 573 const void * 574 OBJ_bsearch_(const void *key, const void *base, int num, int size, 575 int (*cmp)(const void *, const void *)) 576 { 577 return OBJ_bsearch_ex_(key, base, num, size, cmp, 0); 578 } 579 LCRYPTO_ALIAS(OBJ_bsearch_); 580 581 const void * 582 OBJ_bsearch_ex_(const void *key, const void *base_, int num, int size, 583 int (*cmp)(const void *, const void *), int flags) 584 { 585 const char *base = base_; 586 int l, h, i = 0, c = 0; 587 const char *p = NULL; 588 589 if (num == 0) 590 return (NULL); 591 l = 0; 592 h = num; 593 while (l < h) { 594 i = (l + h) / 2; 595 p = &(base[i * size]); 596 c = (*cmp)(key, p); 597 if (c < 0) 598 h = i; 599 else if (c > 0) 600 l = i + 1; 601 else 602 break; 603 } 604 if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH)) 605 p = NULL; 606 else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH)) { 607 while (i > 0 && (*cmp)(key, &(base[(i - 1) * size])) == 0) 608 i--; 609 p = &(base[i * size]); 610 } 611 return (p); 612 } 613 614 int 615 OBJ_create_objects(BIO *in) 616 { 617 char buf[512]; 618 int i, num = 0; 619 char *o, *s, *l = NULL; 620 621 for (;;) { 622 s = o = NULL; 623 i = BIO_gets(in, buf, 512); 624 if (i <= 0) 625 return (num); 626 buf[i - 1] = '\0'; 627 if (!isalnum((unsigned char)buf[0])) 628 return (num); 629 o = s=buf; 630 while (isdigit((unsigned char)*s) || (*s == '.')) 631 s++; 632 if (*s != '\0') { 633 *(s++) = '\0'; 634 while (isspace((unsigned char)*s)) 635 s++; 636 if (*s == '\0') 637 s = NULL; 638 else { 639 l = s; 640 while ((*l != '\0') && 641 !isspace((unsigned char)*l)) 642 l++; 643 if (*l != '\0') { 644 *(l++) = '\0'; 645 while (isspace((unsigned char)*l)) 646 l++; 647 if (*l == '\0') 648 l = NULL; 649 } else 650 l = NULL; 651 } 652 } else 653 s = NULL; 654 if ((o == NULL) || (*o == '\0')) 655 return (num); 656 if (!OBJ_create(o, s, l)) 657 return (num); 658 num++; 659 } 660 /* return(num); */ 661 } 662 LCRYPTO_ALIAS(OBJ_create_objects); 663 664 int 665 OBJ_create(const char *oid, const char *sn, const char *ln) 666 { 667 int ok = 0; 668 ASN1_OBJECT *op = NULL; 669 unsigned char *buf; 670 int i; 671 672 i = a2d_ASN1_OBJECT(NULL, 0, oid, -1); 673 if (i <= 0) 674 return (0); 675 676 if ((buf = malloc(i)) == NULL) { 677 OBJerror(ERR_R_MALLOC_FAILURE); 678 return (0); 679 } 680 i = a2d_ASN1_OBJECT(buf, i, oid, -1); 681 if (i == 0) 682 goto err; 683 op = (ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1), buf, i, sn, ln); 684 if (op == NULL) 685 goto err; 686 ok = OBJ_add_object(op); 687 688 err: 689 ASN1_OBJECT_free(op); 690 free(buf); 691 return (ok); 692 } 693 LCRYPTO_ALIAS(OBJ_create); 694 695 size_t 696 OBJ_length(const ASN1_OBJECT *obj) 697 { 698 if (obj == NULL) 699 return 0; 700 701 if (obj->length < 0) 702 return 0; 703 704 return obj->length; 705 } 706 LCRYPTO_ALIAS(OBJ_length); 707 708 const unsigned char * 709 OBJ_get0_data(const ASN1_OBJECT *obj) 710 { 711 if (obj == NULL) 712 return NULL; 713 714 return obj->data; 715 } 716 LCRYPTO_ALIAS(OBJ_get0_data); 717