OpenCoverage

a_type.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_type.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2016 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/cryptlib.h"-
12#include <openssl/asn1t.h>-
13#include <openssl/objects.h>-
14#include "asn1_locl.h"-
15-
16int ASN1_TYPE_get(const ASN1_TYPE *a)-
17{-
18 if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL))
(a->value.ptr != ((void *)0) )Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(a->type == 5)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-61
19 return a->type;
executed 65 times by 1 test: return a->type;
Executed by:
  • libcrypto.so.1.1
65
20 else-
21 return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
3
22}-
23-
24void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)-
25{-
26 if (a->value.ptr != NULL) {
a->value.ptr != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 232438 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-232438
27 ASN1_TYPE **tmp_a = &a;-
28 asn1_primitive_free((ASN1_VALUE **)tmp_a, NULL, 0);-
29 }
never executed: end of block
0
30 a->type = type;-
31 if (type == V_ASN1_BOOLEAN)
type == 1Description
TRUEevaluated 1086 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 231352 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1086-231352
32 a->value.boolean = value ? 0xff : 0;
executed 1086 times by 1 test: a->value.boolean = value ? 0xff : 0;
Executed by:
  • libcrypto.so.1.1
valueDescription
TRUEnever evaluated
FALSEevaluated 1086 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1086
33 else-
34 a->value.ptr = value;
executed 231352 times by 1 test: a->value.ptr = value;
Executed by:
  • libcrypto.so.1.1
231352
35}-
36-
37int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value)-
38{-
39 if (!value || (type == V_ASN1_BOOLEAN)) {
!valueDescription
TRUEnever evaluated
FALSEevaluated 104 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(type == 1)Description
TRUEnever evaluated
FALSEevaluated 104 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-104
40 void *p = (void *)value;-
41 ASN1_TYPE_set(a, type, p);-
42 } else if (type == V_ASN1_OBJECT) {
never executed: end of block
type == 6Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 54 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-54
43 ASN1_OBJECT *odup;-
44 odup = OBJ_dup(value);-
45 if (!odup)
!odupDescription
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-50
46 return 0;
never executed: return 0;
0
47 ASN1_TYPE_set(a, type, odup);-
48 } else {
executed 50 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
50
49 ASN1_STRING *sdup;-
50 sdup = ASN1_STRING_dup(value);-
51 if (!sdup)
!sdupDescription
TRUEnever evaluated
FALSEevaluated 54 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-54
52 return 0;
never executed: return 0;
0
53 ASN1_TYPE_set(a, type, sdup);-
54 }
executed 54 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
54
55 return 1;
executed 104 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
104
56}-
57-
58/* Returns 0 if they are equal, != 0 otherwise. */-
59int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)-
60{-
61 int result = -1;-
62-
63 if (!a || !b || a->type != b->type)
!aDescription
TRUEnever evaluated
FALSEevaluated 1258 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!bDescription
TRUEnever evaluated
FALSEevaluated 1258 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a->type != b->typeDescription
TRUEnever evaluated
FALSEevaluated 1258 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1258
64 return -1;
never executed: return -1;
0
65-
66 switch (a->type) {-
67 case V_ASN1_OBJECT:
never executed: case 6:
0
68 result = OBJ_cmp(a->value.object, b->value.object);-
69 break;
never executed: break;
0
70 case V_ASN1_BOOLEAN:
never executed: case 1:
0
71 result = a->value.boolean - b->value.boolean;-
72 break;
never executed: break;
0
73 case V_ASN1_NULL:
executed 1255 times by 1 test: case 5:
Executed by:
  • libcrypto.so.1.1
1255
74 result = 0; /* They do not have content. */-
75 break;
executed 1255 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
1255
76 case V_ASN1_INTEGER:
never executed: case 2:
0
77 case V_ASN1_ENUMERATED:
never executed: case 10:
0
78 case V_ASN1_BIT_STRING:
never executed: case 3:
0
79 case V_ASN1_OCTET_STRING:
never executed: case 4:
0
80 case V_ASN1_SEQUENCE:
executed 3 times by 1 test: case 16:
Executed by:
  • libcrypto.so.1.1
3
81 case V_ASN1_SET:
never executed: case 17:
0
82 case V_ASN1_NUMERICSTRING:
never executed: case 18:
0
83 case V_ASN1_PRINTABLESTRING:
never executed: case 19:
0
84 case V_ASN1_T61STRING:
never executed: case 20:
0
85 case V_ASN1_VIDEOTEXSTRING:
never executed: case 21:
0
86 case V_ASN1_IA5STRING:
never executed: case 22:
0
87 case V_ASN1_UTCTIME:
never executed: case 23:
0
88 case V_ASN1_GENERALIZEDTIME:
never executed: case 24:
0
89 case V_ASN1_GRAPHICSTRING:
never executed: case 25:
0
90 case V_ASN1_VISIBLESTRING:
never executed: case 26:
0
91 case V_ASN1_GENERALSTRING:
never executed: case 27:
0
92 case V_ASN1_UNIVERSALSTRING:
never executed: case 28:
0
93 case V_ASN1_BMPSTRING:
never executed: case 30:
0
94 case V_ASN1_UTF8STRING:
never executed: case 12:
0
95 case V_ASN1_OTHER:
never executed: case -3:
0
96 default:
never executed: default:
0
97 result = ASN1_STRING_cmp((ASN1_STRING *)a->value.ptr,-
98 (ASN1_STRING *)b->value.ptr);-
99 break;
executed 3 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
3
100 }-
101-
102 return result;
executed 1258 times by 1 test: return result;
Executed by:
  • libcrypto.so.1.1
1258
103}-
104-
105ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t)-
106{-
107 ASN1_OCTET_STRING *oct;-
108 ASN1_TYPE *rt;-
109-
110 oct = ASN1_item_pack(s, it, NULL);-
111 if (oct == NULL)
oct == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
112 return NULL;
never executed: return ((void *)0) ;
0
113-
114 if (t && *t) {
tDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
*tDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2
115 rt = *t;-
116 } else {
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
117 rt = ASN1_TYPE_new();-
118 if (rt == NULL) {
rt == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
119 ASN1_OCTET_STRING_free(oct);-
120 return NULL;
never executed: return ((void *)0) ;
0
121 }-
122 if (t)
tDescription
TRUEnever evaluated
FALSEnever evaluated
0
123 *t = rt;
never executed: *t = rt;
0
124 }
never executed: end of block
0
125 ASN1_TYPE_set(rt, V_ASN1_SEQUENCE, oct);-
126 return rt;
executed 2 times by 1 test: return rt;
Executed by:
  • libcrypto.so.1.1
2
127}-
128-
129void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t)-
130{-
131 if (t == NULL || t->type != V_ASN1_SEQUENCE || t->value.sequence == NULL)
t == ((void *)0)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 306 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
t->type != 16Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 250 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
t->value.seque...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 250 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-306
132 return NULL;
executed 63 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
63
133 return ASN1_item_unpack(t->value.sequence, it);
executed 250 times by 1 test: return ASN1_item_unpack(t->value.sequence, it);
Executed by:
  • libcrypto.so.1.1
250
134}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2