OpenCoverage

t_pkey.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/t_pkey.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/objects.h>-
13#include <openssl/buffer.h>-
14#include "internal/bn_int.h"-
15-
16/* Number of octets per line */-
17#define ASN1_BUF_PRINT_WIDTH 15-
18/* Maximum indent */-
19#define ASN1_PRINT_MAX_INDENT 128-
20-
21int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int indent)-
22{-
23 size_t i;-
24-
25 for (i = 0; i < buflen; i++) {
i < buflenDescription
TRUEevaluated 233530 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1361 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1361-233530
26 if ((i % ASN1_BUF_PRINT_WIDTH) == 0) {
(i % 15) == 0Description
TRUEevaluated 16257 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 217273 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16257-217273
27 if (i > 0 && BIO_puts(bp, "\n") <= 0)
i > 0Description
TRUEevaluated 14896 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1361 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
BIO_puts(bp, "\n") <= 0Description
TRUEnever evaluated
FALSEevaluated 14896 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14896
28 return 0;
never executed: return 0;
0
29 if (!BIO_indent(bp, indent, ASN1_PRINT_MAX_INDENT))
!BIO_indent(bp, indent, 128)Description
TRUEnever evaluated
FALSEevaluated 16257 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-16257
30 return 0;
never executed: return 0;
0
31 }
executed 16257 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
16257
32 /*-
33 * Use colon separators for each octet for compatibility as-
34 * this function is used to print out key components.-
35 */-
36 if (BIO_printf(bp, "%02x%s", buf[i],
BIO_printf(bp,..."" : ":") <= 0Description
TRUEnever evaluated
FALSEevaluated 233530 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-233530
37 (i == buflen - 1) ? "" : ":") <= 0)
BIO_printf(bp,..."" : ":") <= 0Description
TRUEnever evaluated
FALSEevaluated 233530 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-233530
38 return 0;
never executed: return 0;
0
39 }
executed 233530 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
233530
40 if (BIO_write(bp, "\n", 1) <= 0)
BIO_write(bp, "\n", 1) <= 0Description
TRUEnever evaluated
FALSEevaluated 1361 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1361
41 return 0;
never executed: return 0;
0
42 return 1;
executed 1361 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1361
43}-
44-
45int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,-
46 unsigned char *ign, int indent)-
47{-
48 int n, rv = 0;-
49 const char *neg;-
50 unsigned char *buf = NULL, *tmp = NULL;-
51 int buflen;-
52-
53 if (num == NULL)
num == ((void *)0)Description
TRUEevaluated 216 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12101 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
216-12101
54 return 1;
executed 216 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
216
55 neg = BN_is_negative(num) ? "-" : "";
BN_is_negative(num)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12079 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
22-12079
56 if (!BIO_indent(bp, indent, ASN1_PRINT_MAX_INDENT))
!BIO_indent(bp, indent, 128)Description
TRUEnever evaluated
FALSEevaluated 12101 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-12101
57 return 0;
never executed: return 0;
0
58 if (BN_is_zero(num)) {
BN_is_zero(num)Description
TRUEevaluated 491 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11610 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
491-11610
59 if (BIO_printf(bp, "%s 0\n", number) <= 0)
BIO_printf(bp,..., number) <= 0Description
TRUEnever evaluated
FALSEevaluated 491 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-491
60 return 0;
never executed: return 0;
0
61 return 1;
executed 491 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
491
62 }-
63-
64 if (BN_num_bytes(num) <= BN_BYTES) {
((BN_num_bits(num)+7)/8) <= 8Description
TRUEevaluated 10683 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 927 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
927-10683
65 if (BIO_printf(bp, "%s %s%lu (%s0x%lx)\n", number, neg,
BIO_printf(bp,...(num)[0]) <= 0Description
TRUEnever evaluated
FALSEevaluated 10683 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10683
66 (unsigned long)bn_get_words(num)[0], neg,
BIO_printf(bp,...(num)[0]) <= 0Description
TRUEnever evaluated
FALSEevaluated 10683 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10683
67 (unsigned long)bn_get_words(num)[0]) <= 0)
BIO_printf(bp,...(num)[0]) <= 0Description
TRUEnever evaluated
FALSEevaluated 10683 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10683
68 return 0;
never executed: return 0;
0
69 return 1;
executed 10683 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
10683
70 }-
71-
72 buflen = BN_num_bytes(num) + 1;-
73 buf = tmp = OPENSSL_malloc(buflen);-
74 if (buf == NULL)
buf == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 927 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-927
75 goto err;
never executed: goto err;
0
76 buf[0] = 0;-
77 if (BIO_printf(bp, "%s%s\n", number,
BIO_printf(bp,...e)" : "") <= 0Description
TRUEnever evaluated
FALSEevaluated 927 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-927
78 (neg[0] == '-') ? " (Negative)" : "") <= 0)
BIO_printf(bp,...e)" : "") <= 0Description
TRUEnever evaluated
FALSEevaluated 927 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-927
79 goto err;
never executed: goto err;
0
80 n = BN_bn2bin(num, buf + 1);-
81-
82 if (buf[1] & 0x80)
buf[1] & 0x80Description
TRUEevaluated 565 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 362 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
362-565
83 n++;
executed 565 times by 1 test: n++;
Executed by:
  • libcrypto.so.1.1
565
84 else-
85 tmp++;
executed 362 times by 1 test: tmp++;
Executed by:
  • libcrypto.so.1.1
362
86-
87 if (ASN1_buf_print(bp, tmp, n, indent + 4) == 0)
ASN1_buf_print...dent + 4) == 0Description
TRUEnever evaluated
FALSEevaluated 927 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-927
88 goto err;
never executed: goto err;
0
89 rv = 1;-
90 err:
code before this statement executed 927 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
927
91 OPENSSL_clear_free(buf, buflen);-
92 return rv;
executed 927 times by 1 test: return rv;
Executed by:
  • libcrypto.so.1.1
927
93}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2