Coverage Report

Created: 2026-08-31 06:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/ssl/d1_transcript.c
Line
Count
Source
1
/*
2
 * Copyright 2026 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (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 "ssl_local.h"
11
12
/*
13
 * RFC 9147 ยง5.2: strip msg_seq, fragment_offset, and fragment_length from
14
 * each DTLS handshake message header before feeding into the transcript hash.
15
 * Used by both ssl3_finish_mac and tls13_change_cipher_state.
16
 */
17
int dtls13_transcript_hash_update(EVP_MD_CTX *mdctx,
18
    const unsigned char *buf, size_t len)
19
0
{
20
0
    while (len > 0) {
21
0
        PACKET hmhdr;
22
0
        unsigned long hmbodylen;
23
0
        unsigned int msgtype;
24
0
        size_t hmhdrlen;
25
26
0
        if (!ossl_assert(len >= SSL3_HM_HEADER_LENGTH)
27
0
            || !PACKET_buf_init(&hmhdr, buf, SSL3_HM_HEADER_LENGTH)
28
0
            || !PACKET_get_1(&hmhdr, &msgtype)
29
0
            || !PACKET_get_net_3(&hmhdr, &hmbodylen))
30
0
            return 0;
31
32
0
        hmhdrlen = (msgtype == SSL3_MT_MESSAGE_HASH)
33
0
            ? SSL3_HM_HEADER_LENGTH
34
0
            : DTLS1_HM_HEADER_LENGTH;
35
36
0
        if (!ossl_assert(hmhdrlen + hmbodylen <= len)
37
0
            || !EVP_DigestUpdate(mdctx, buf, SSL3_HM_HEADER_LENGTH)
38
0
            || !EVP_DigestUpdate(mdctx, buf + hmhdrlen, hmbodylen))
39
0
            return 0;
40
41
0
        buf += hmhdrlen + hmbodylen;
42
0
        len -= hmhdrlen + hmbodylen;
43
0
    }
44
0
    return 1;
45
0
}