OpenCoverage

asn_moid.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/asn_moid.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#include <stdio.h>-
11#include "internal/ctype.h"-
12#include <openssl/crypto.h>-
13#include "internal/cryptlib.h"-
14#include <openssl/conf.h>-
15#include <openssl/x509.h>-
16#include "internal/asn1_int.h"-
17#include "internal/objects.h"-
18-
19/* Simple ASN1 OID module: add all objects in a given section */-
20-
21static int do_create(const char *value, const char *name);-
22-
23static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)-
24{-
25 int i;-
26 const char *oid_section;-
27 STACK_OF(CONF_VALUE) *sktmp;-
28 CONF_VALUE *oval;-
29-
30 oid_section = CONF_imodule_get_value(md);-
31 if ((sktmp = NCONF_get_section(cnf, oid_section)) == NULL) {
(sktmp = NCONF...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
32 ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION);-
33 return 0;
never executed: return 0;
0
34 }-
35 for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) {
i < sk_CONF_VALUE_num(sktmp)Description
TRUEnever evaluated
FALSEnever evaluated
0
36 oval = sk_CONF_VALUE_value(sktmp, i);-
37 if (!do_create(oval->value, oval->name)) {
!do_create(ova...e, oval->name)Description
TRUEnever evaluated
FALSEnever evaluated
0
38 ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT);-
39 return 0;
never executed: return 0;
0
40 }-
41 }
never executed: end of block
0
42 return 1;
never executed: return 1;
0
43}-
44-
45static void oid_module_finish(CONF_IMODULE *md)-
46{-
47}-
48-
49void ASN1_add_oid_module(void)-
50{-
51 CONF_module_add("oid_section", oid_module_init, oid_module_finish);-
52}
executed 1958 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1958
53-
54/*--
55 * Create an OID based on a name value pair. Accept two formats.-
56 * shortname = 1.2.3.4-
57 * shortname = some long name, 1.2.3.4-
58 */-
59-
60static int do_create(const char *value, const char *name)-
61{-
62 int nid;-
63 const char *ln, *ostr, *p;-
64 char *lntmp = NULL;-
65-
66 p = strrchr(value, ',');-
67 if (p == NULL) {
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
68 ln = name;-
69 ostr = value;-
70 } else {
never executed: end of block
0
71 ln = value;-
72 ostr = p + 1;-
73 if (*ostr == '\0')
*ostr == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
74 return 0;
never executed: return 0;
0
75 while (ossl_isspace(*ostr))
(ossl_ctype_ch...(*ostr), 0x8))Description
TRUEnever evaluated
FALSEnever evaluated
0
76 ostr++;
never executed: ostr++;
0
77 while (ossl_isspace(*ln))
(ossl_ctype_check((*ln), 0x8))Description
TRUEnever evaluated
FALSEnever evaluated
0
78 ln++;
never executed: ln++;
0
79 p--;-
80 while (ossl_isspace(*p)) {
(ossl_ctype_check((*p), 0x8))Description
TRUEnever evaluated
FALSEnever evaluated
0
81 if (p == ln)
p == lnDescription
TRUEnever evaluated
FALSEnever evaluated
0
82 return 0;
never executed: return 0;
0
83 p--;-
84 }
never executed: end of block
0
85 p++;-
86 if ((lntmp = OPENSSL_malloc((p - ln) + 1)) == NULL) {
(lntmp = CRYPT...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
87 ASN1err(ASN1_F_DO_CREATE, ERR_R_MALLOC_FAILURE);-
88 return 0;
never executed: return 0;
0
89 }-
90 memcpy(lntmp, ln, p - ln);-
91 lntmp[p - ln] = '\0';-
92 ln = lntmp;-
93 }
never executed: end of block
0
94-
95 nid = OBJ_create(ostr, name, ln);-
96-
97 OPENSSL_free(lntmp);-
98-
99 return nid != NID_undef;
never executed: return nid != 0;
0
100}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2