OpenCoverage

tls_peer.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/tls/tls_peer.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: tls_peer.c,v 1.8 2017/04/10 17:11:13 jsing Exp $ */-
2/*-
3 * Copyright (c) 2015 Joel Sing <jsing@openbsd.org>-
4 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>-
5 *-
6 * Permission to use, copy, modify, and distribute this software for any-
7 * purpose with or without fee is hereby granted, provided that the above-
8 * copyright notice and this permission notice appear in all copies.-
9 *-
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES-
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF-
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR-
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES-
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN-
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF-
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.-
17 */-
18-
19#include <stdio.h>-
20-
21#include <openssl/x509.h>-
22-
23#include <tls.h>-
24#include "tls_internal.h"-
25-
26const char *-
27tls_peer_cert_hash(struct tls *ctx)-
28{-
29 if (ctx->conninfo == NULL)
ctx->conninfo == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
30 return (NULL);
never executed: return ( ((void *)0) );
0
31 return (ctx->conninfo->hash);
never executed: return (ctx->conninfo->hash);
0
32}-
33const char *-
34tls_peer_cert_issuer(struct tls *ctx)-
35{-
36 if (ctx->conninfo == NULL)
ctx->conninfo == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
37 return (NULL);
never executed: return ( ((void *)0) );
0
38 return (ctx->conninfo->issuer);
never executed: return (ctx->conninfo->issuer);
0
39}-
40-
41const char *-
42tls_peer_cert_subject(struct tls *ctx)-
43{-
44 if (ctx->conninfo == NULL)
ctx->conninfo == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
45 return (NULL);
never executed: return ( ((void *)0) );
0
46 return (ctx->conninfo->subject);
never executed: return (ctx->conninfo->subject);
0
47}-
48-
49int-
50tls_peer_cert_provided(struct tls *ctx)-
51{-
52 return (ctx->ssl_peer_cert != NULL);
never executed: return (ctx->ssl_peer_cert != ((void *)0) );
0
53}-
54-
55int-
56tls_peer_cert_contains_name(struct tls *ctx, const char *name)-
57{-
58 int match;-
59-
60 if (ctx->ssl_peer_cert == NULL)
ctx->ssl_peer_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
61 return (0);
never executed: return (0);
0
62-
63 if (tls_check_name(ctx, ctx->ssl_peer_cert, name, &match) == -1)
tls_check_name... &match) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
64 return (0);
never executed: return (0);
0
65-
66 return (match);
never executed: return (match);
0
67}-
68-
69time_t-
70tls_peer_cert_notbefore(struct tls *ctx)-
71{-
72 if (ctx->ssl_peer_cert == NULL)
ctx->ssl_peer_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
73 return (-1);
never executed: return (-1);
0
74 if (ctx->conninfo == NULL)
ctx->conninfo == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
75 return (-1);
never executed: return (-1);
0
76 return (ctx->conninfo->notbefore);
never executed: return (ctx->conninfo->notbefore);
0
77}-
78-
79time_t-
80tls_peer_cert_notafter(struct tls *ctx)-
81{-
82 if (ctx->ssl_peer_cert == NULL)
ctx->ssl_peer_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
83 return (-1);
never executed: return (-1);
0
84 if (ctx->conninfo == NULL)
ctx->conninfo == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
85 return (-1);
never executed: return (-1);
0
86 return (ctx->conninfo->notafter);
never executed: return (ctx->conninfo->notafter);
0
87}-
88-
89const uint8_t *-
90tls_peer_cert_chain_pem(struct tls *ctx, size_t *size)-
91{-
92 if (ctx->ssl_peer_cert == NULL)
ctx->ssl_peer_...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
93 return (NULL);
never executed: return ( ((void *)0) );
0
94 if (ctx->conninfo == NULL)
ctx->conninfo == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
95 return (NULL);
never executed: return ( ((void *)0) );
0
96 *size = ctx->conninfo->peer_cert_len;-
97 return (ctx->conninfo->peer_cert);
never executed: return (ctx->conninfo->peer_cert);
0
98}-
99-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2