OpenCoverage

obj_xref.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/objects/obj_xref.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2006-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 <openssl/objects.h>-
11#include "obj_xref.h"-
12#include "internal/nelem.h"-
13#include <openssl/err.h>-
14-
15static STACK_OF(nid_triple) *sig_app, *sigx_app;-
16-
17static int sig_cmp(const nid_triple *a, const nid_triple *b)-
18{-
19 return a->sign_id - b->sign_id;
executed 75759 times by 1 test: return a->sign_id - b->sign_id;
Executed by:
  • libcrypto.so.1.1
75759
20}-
21-
22DECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig);-
23IMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig);
executed 75759 times by 1 test: return sig_cmp(a,b);
Executed by:
  • libcrypto.so.1.1
executed 15550 times by 1 test: return (nid_triple *)OBJ_bsearch_(key, base, num, sizeof(nid_triple), sig_cmp_BSEARCH_CMP_FN);
Executed by:
  • libcrypto.so.1.1
15550-75759
24-
25static int sig_sk_cmp(const nid_triple *const *a, const nid_triple *const *b)-
26{-
27 return (*a)->sign_id - (*b)->sign_id;
never executed: return (*a)->sign_id - (*b)->sign_id;
0
28}-
29-
30DECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx);-
31-
32static int sigx_cmp(const nid_triple *const *a, const nid_triple *const *b)-
33{-
34 int ret;-
35 ret = (*a)->hash_id - (*b)->hash_id;-
36 if (ret)
retDescription
TRUEevaluated 124 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 91 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
91-124
37 return ret;
executed 124 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
124
38 return (*a)->pkey_id - (*b)->pkey_id;
executed 91 times by 1 test: return (*a)->pkey_id - (*b)->pkey_id;
Executed by:
  • libcrypto.so.1.1
91
39}-
40-
41IMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx);
executed 215 times by 1 test: return sigx_cmp(a,b);
Executed by:
  • libcrypto.so.1.1
executed 65 times by 1 test: return (const nid_triple * *)OBJ_bsearch_(key, base, num, sizeof(const nid_triple *), sigx_cmp_BSEARCH_CMP_FN);
Executed by:
  • libcrypto.so.1.1
65-215
42-
43int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid)-
44{-
45 nid_triple tmp;-
46 const nid_triple *rv = NULL;-
47 tmp.sign_id = signid;-
48-
49 if (sig_app != NULL) {
sig_app != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 15550 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-15550
50 int idx = sk_nid_triple_find(sig_app, &tmp);-
51 rv = sk_nid_triple_value(sig_app, idx);-
52 }
never executed: end of block
0
53#ifndef OBJ_XREF_TEST2-
54 if (rv == NULL) {
rv == ((void *)0)Description
TRUEevaluated 15550 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-15550
55 rv = OBJ_bsearch_sig(&tmp, sigoid_srt, OSSL_NELEM(sigoid_srt));-
56 }
executed 15550 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
15550
57#endif-
58 if (rv == NULL)
rv == ((void *)0)Description
TRUEevaluated 828 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14722 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
828-14722
59 return 0;
executed 828 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
828
60 if (pdig_nid)
pdig_nidDescription
TRUEevaluated 14722 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-14722
61 *pdig_nid = rv->hash_id;
executed 14722 times by 1 test: *pdig_nid = rv->hash_id;
Executed by:
  • libcrypto.so.1.1
14722
62 if (ppkey_nid)
ppkey_nidDescription
TRUEevaluated 14722 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-14722
63 *ppkey_nid = rv->pkey_id;
executed 14722 times by 1 test: *ppkey_nid = rv->pkey_id;
Executed by:
  • libcrypto.so.1.1
14722
64 return 1;
executed 14722 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
14722
65}-
66-
67int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid)-
68{-
69 nid_triple tmp;-
70 const nid_triple *t = &tmp;-
71 const nid_triple **rv = NULL;-
72-
73 tmp.hash_id = dig_nid;-
74 tmp.pkey_id = pkey_nid;-
75-
76 if (sigx_app) {
sigx_appDescription
TRUEnever evaluated
FALSEevaluated 65 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-65
77 int idx = sk_nid_triple_find(sigx_app, &tmp);-
78 if (idx >= 0) {
idx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
79 t = sk_nid_triple_value(sigx_app, idx);-
80 rv = &t;-
81 }
never executed: end of block
0
82 }
never executed: end of block
0
83#ifndef OBJ_XREF_TEST2-
84 if (rv == NULL) {
rv == ((void *)0)Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-65
85 rv = OBJ_bsearch_sigx(&t, sigoid_srt_xref, OSSL_NELEM(sigoid_srt_xref));-
86 }
executed 65 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
65
87#endif-
88 if (rv == NULL)
rv == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 65 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-65
89 return 0;
never executed: return 0;
0
90 if (psignid)
psignidDescription
TRUEevaluated 65 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-65
91 *psignid = (*rv)->sign_id;
executed 65 times by 1 test: *psignid = (*rv)->sign_id;
Executed by:
  • libcrypto.so.1.1
65
92 return 1;
executed 65 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
65
93}-
94-
95int OBJ_add_sigid(int signid, int dig_id, int pkey_id)-
96{-
97 nid_triple *ntr;-
98 if (sig_app == NULL)
sig_app == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
99 sig_app = sk_nid_triple_new(sig_sk_cmp);
never executed: sig_app = sk_nid_triple_new(sig_sk_cmp);
0
100 if (sig_app == NULL)
sig_app == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
101 return 0;
never executed: return 0;
0
102 if (sigx_app == NULL)
sigx_app == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
103 sigx_app = sk_nid_triple_new(sigx_cmp);
never executed: sigx_app = sk_nid_triple_new(sigx_cmp);
0
104 if (sigx_app == NULL)
sigx_app == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
105 return 0;
never executed: return 0;
0
106 if ((ntr = OPENSSL_malloc(sizeof(*ntr))) == NULL) {
(ntr = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
107 OBJerr(OBJ_F_OBJ_ADD_SIGID, ERR_R_MALLOC_FAILURE);-
108 return 0;
never executed: return 0;
0
109 }-
110 ntr->sign_id = signid;-
111 ntr->hash_id = dig_id;-
112 ntr->pkey_id = pkey_id;-
113-
114 if (!sk_nid_triple_push(sig_app, ntr)) {
!sk_nid_triple...(sig_app, ntr)Description
TRUEnever evaluated
FALSEnever evaluated
0
115 OPENSSL_free(ntr);-
116 return 0;
never executed: return 0;
0
117 }-
118-
119 if (!sk_nid_triple_push(sigx_app, ntr))
!sk_nid_triple...sigx_app, ntr)Description
TRUEnever evaluated
FALSEnever evaluated
0
120 return 0;
never executed: return 0;
0
121-
122 sk_nid_triple_sort(sig_app);-
123 sk_nid_triple_sort(sigx_app);-
124-
125 return 1;
never executed: return 1;
0
126}-
127-
128static void sid_free(nid_triple *tt)-
129{-
130 OPENSSL_free(tt);-
131}
never executed: end of block
0
132-
133void OBJ_sigid_free(void)-
134{-
135 sk_nid_triple_pop_free(sig_app, sid_free);-
136 sig_app = NULL;-
137 sk_nid_triple_free(sigx_app);-
138 sigx_app = NULL;-
139}
executed 2076 times by 12 tests: end of block
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
2076
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2