OpenCoverage

t1_hash.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/ssl/t1_hash.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: t1_hash.c,v 1.3 2018/09/05 16:58:59 jsing Exp $ */-
2/*-
3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org>-
4 *-
5 * Permission to use, copy, modify, and distribute this software for any-
6 * purpose with or without fee is hereby granted, provided that the above-
7 * copyright notice and this permission notice appear in all copies.-
8 *-
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES-
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF-
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR-
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES-
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN-
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF-
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.-
16 */-
17-
18#include "ssl_locl.h"-
19-
20#include <openssl/ssl.h>-
21-
22int-
23tls1_handshake_hash_init(SSL *s)-
24{-
25 const EVP_MD *md;-
26 long dlen;-
27 void *data;-
28-
29 tls1_handshake_hash_free(s);-
30-
31 if (!ssl_get_handshake_evp_md(s, &md)) {
!ssl_get_hands...evp_md(s, &md)Description
TRUEnever evaluated
FALSEevaluated 128 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-128
32 SSLerrorx(ERR_R_INTERNAL_ERROR);-
33 goto err;
never executed: goto err;
0
34 }-
35-
36 if ((S3I(s)->handshake_hash = EVP_MD_CTX_new()) == NULL) {
((s->s3->inter...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 128 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-128
37 SSLerror(s, ERR_R_MALLOC_FAILURE);-
38 goto err;
never executed: goto err;
0
39 }-
40 if (!EVP_DigestInit_ex(S3I(s)->handshake_hash, md, NULL)) {
!EVP_DigestIni... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 128 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-128
41 SSLerror(s, ERR_R_EVP_LIB);-
42 goto err;
never executed: goto err;
0
43 }-
44-
45 dlen = BIO_get_mem_data(S3I(s)->handshake_buffer, &data);-
46 if (dlen <= 0) {
dlen <= 0Description
TRUEnever evaluated
FALSEevaluated 128 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-128
47 SSLerror(s, SSL_R_BAD_HANDSHAKE_LENGTH);-
48 goto err;
never executed: goto err;
0
49 }-
50 if (!tls1_handshake_hash_update(s, data, dlen)) {
!tls1_handshak...s, data, dlen)Description
TRUEnever evaluated
FALSEevaluated 128 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-128
51 SSLerror(s, ERR_R_EVP_LIB);-
52 goto err;
never executed: goto err;
0
53 }-
54 -
55 return 1;
executed 128 times by 3 tests: return 1;
Executed by:
  • servertest
  • ssltest
  • tlstest
128
56-
57 err:-
58 tls1_handshake_hash_free(s);-
59-
60 return 0;
never executed: return 0;
0
61}-
62-
63int-
64tls1_handshake_hash_update(SSL *s, const unsigned char *buf, size_t len)-
65{-
66 if (S3I(s)->handshake_hash == NULL)
(s->s3->intern...== ((void *)0)Description
TRUEevaluated 202 times by 4 tests
Evaluated by:
  • clienttest
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 1078 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
202-1078
67 return 1;
executed 202 times by 4 tests: return 1;
Executed by:
  • clienttest
  • servertest
  • ssltest
  • tlstest
202
68-
69 return EVP_DigestUpdate(S3I(s)->handshake_hash, buf, len);
executed 1078 times by 3 tests: return EVP_DigestUpdate((s->s3->internal)->handshake_hash, buf, len);
Executed by:
  • servertest
  • ssltest
  • tlstest
1078
70}-
71-
72int-
73tls1_handshake_hash_value(SSL *s, const unsigned char *out, size_t len,-
74 size_t *outlen)-
75{-
76 EVP_MD_CTX *mdctx = NULL;-
77 unsigned int mdlen;-
78 int ret = 0;-
79-
80 if (EVP_MD_CTX_size(S3I(s)->handshake_hash) > len)
EVP_MD_size(EV...e_hash)) > lenDescription
TRUEnever evaluated
FALSEevaluated 387 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
0-387
81 goto err;
never executed: goto err;
0
82-
83 if ((mdctx = EVP_MD_CTX_new()) == NULL) {
(mdctx = EVP_M...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 387 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
0-387
84 SSLerror(s, ERR_R_MALLOC_FAILURE);-
85 goto err;
never executed: goto err;
0
86 }-
87 if (!EVP_MD_CTX_copy_ex(mdctx, S3I(s)->handshake_hash)) {
!EVP_MD_CTX_co...andshake_hash)Description
TRUEnever evaluated
FALSEevaluated 387 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
0-387
88 SSLerror(s, ERR_R_EVP_LIB);-
89 goto err;
never executed: goto err;
0
90 }-
91 if (!EVP_DigestFinal_ex(mdctx, (unsigned char *)out, &mdlen)) {
!EVP_DigestFin...*)out, &mdlen)Description
TRUEnever evaluated
FALSEevaluated 387 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
0-387
92 SSLerror(s, ERR_R_EVP_LIB);-
93 goto err;
never executed: goto err;
0
94 }-
95 if (outlen != NULL)
outlen != ((void *)0)Description
TRUEevaluated 356 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
FALSEevaluated 31 times by 1 test
Evaluated by:
  • ssltest
31-356
96 *outlen = mdlen;
executed 356 times by 2 tests: *outlen = mdlen;
Executed by:
  • ssltest
  • tlstest
356
97-
98 ret = 1;-
99-
100 err:
code before this statement executed 387 times by 2 tests: err:
Executed by:
  • ssltest
  • tlstest
387
101 EVP_MD_CTX_free(mdctx);-
102-
103 return (ret);
executed 387 times by 2 tests: return (ret);
Executed by:
  • ssltest
  • tlstest
387
104}-
105-
106void-
107tls1_handshake_hash_free(SSL *s)-
108{-
109 EVP_MD_CTX_free(S3I(s)->handshake_hash);-
110 S3I(s)->handshake_hash = NULL;-
111}
executed 1068 times by 11 tests: end of block
Executed by:
  • cipher_list
  • cipherstest
  • clienttest
  • libssl.so.46.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
1068
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2