OpenCoverage

p8_pkey.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/p8_pkey.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1999-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/x509.h>-
14#include "internal/x509_int.h"-
15-
16/* Minor tweak to operation: zero private key data */-
17static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,-
18 void *exarg)-
19{-
20 /* Since the structure must still be valid use ASN1_OP_FREE_PRE */-
21 if (operation == ASN1_OP_FREE_PRE) {
operation == 2Description
TRUEevaluated 8688 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 37741 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8688-37741
22 PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval;-
23 if (key->pkey)
key->pkeyDescription
TRUEevaluated 8688 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-8688
24 OPENSSL_cleanse(key->pkey->data, key->pkey->length);
executed 8688 times by 1 test: OPENSSL_cleanse(key->pkey->data, key->pkey->length);
Executed by:
  • libcrypto.so.1.1
8688
25 }
executed 8688 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
8688
26 return 1;
executed 46429 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
46429
27}-
28-
29ASN1_SEQUENCE_cb(PKCS8_PRIV_KEY_INFO, pkey_cb) = {-
30 ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, version, ASN1_INTEGER),-
31 ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, pkeyalg, X509_ALGOR),-
32 ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, pkey, ASN1_OCTET_STRING),-
33 ASN1_IMP_SET_OF_OPT(PKCS8_PRIV_KEY_INFO, attributes, X509_ATTRIBUTE, 0)-
34} ASN1_SEQUENCE_END_cb(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)-
35-
36IMPLEMENT_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
executed 2870 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
executed 6058 times by 1 test: return (PKCS8_PRIV_KEY_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(PKCS8_PRIV_KEY_INFO_it)));
Executed by:
  • libcrypto.so.1.1
executed 54 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(PKCS8_PRIV_KEY_INFO_it)));
Executed by:
  • libcrypto.so.1.1
executed 29 times by 1 test: return (PKCS8_PRIV_KEY_INFO *)ASN1_item_new((&(PKCS8_PRIV_KEY_INFO_it)));
Executed by:
  • libcrypto.so.1.1
29-6058
37-
38int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,-
39 int version,-
40 int ptype, void *pval, unsigned char *penc, int penclen)-
41{-
42 if (version >= 0) {
version >= 0Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-29
43 if (!ASN1_INTEGER_set(priv->version, version))
!ASN1_INTEGER_...sion, version)Description
TRUEnever evaluated
FALSEevaluated 29 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-29
44 return 0;
never executed: return 0;
0
45 }
executed 29 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
29
46 if (!X509_ALGOR_set0(priv->pkeyalg, aobj, ptype, pval))
!X509_ALGOR_se..., ptype, pval)Description
TRUEnever evaluated
FALSEevaluated 29 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-29
47 return 0;
never executed: return 0;
0
48 if (penc)
pencDescription
TRUEevaluated 29 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-29
49 ASN1_STRING_set0(priv->pkey, penc, penclen);
executed 29 times by 1 test: ASN1_STRING_set0(priv->pkey, penc, penclen);
Executed by:
  • libcrypto.so.1.1
29
50 return 1;
executed 29 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
29
51}-
52-
53int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg,-
54 const unsigned char **pk, int *ppklen,-
55 const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8)-
56{-
57 if (ppkalg)
ppkalgDescription
TRUEevaluated 2841 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2840 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2840-2841
58 *ppkalg = p8->pkeyalg->algorithm;
executed 2841 times by 1 test: *ppkalg = p8->pkeyalg->algorithm;
Executed by:
  • libcrypto.so.1.1
2841
59 if (pk) {
pkDescription
TRUEevaluated 2840 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2841 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2840-2841
60 *pk = ASN1_STRING_get0_data(p8->pkey);-
61 *ppklen = ASN1_STRING_length(p8->pkey);-
62 }
executed 2840 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2840
63 if (pa)
paDescription
TRUEevaluated 2840 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2841 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2840-2841
64 *pa = p8->pkeyalg;
executed 2840 times by 1 test: *pa = p8->pkeyalg;
Executed by:
  • libcrypto.so.1.1
2840
65 return 1;
executed 5681 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
5681
66}-
67-
68const STACK_OF(X509_ATTRIBUTE) *-
69PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8)-
70{-
71 return p8->attributes;
never executed: return p8->attributes;
0
72}-
73-
74int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type,-
75 const unsigned char *bytes, int len)-
76{-
77 if (X509at_add1_attr_by_NID(&p8->attributes, nid, type, bytes, len) != NULL)
X509at_add1_at...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
78 return 1;
never executed: return 1;
0
79 return 0;
never executed: return 0;
0
80}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2