Coverage Report

Created: 2026-04-01 06:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl33/providers/implementations/digests/blake2_impl.h
Line
Count
Source
1
/*
2
 * Copyright 2016-2020 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
/*
11
 * Derived from the BLAKE2 reference implementation written by Samuel Neves.
12
 * Copyright 2012, Samuel Neves <sneves@dei.uc.pt>
13
 * More information about the BLAKE2 hash function and its implementations
14
 * can be found at https://blake2.net.
15
 */
16
17
#include <string.h>
18
#include "internal/endian.h"
19
20
static ossl_inline uint32_t load32(const uint8_t *src)
21
6.61M
{
22
6.61M
    DECLARE_IS_ENDIAN;
23
24
6.61M
    if (IS_LITTLE_ENDIAN) {
25
6.61M
        uint32_t w;
26
6.61M
        memcpy(&w, src, sizeof(w));
27
6.61M
        return w;
28
6.61M
    } else {
29
0
        uint32_t w = ((uint32_t)src[0])
30
0
            | ((uint32_t)src[1] << 8)
31
0
            | ((uint32_t)src[2] << 16)
32
0
            | ((uint32_t)src[3] << 24);
33
0
        return w;
34
0
    }
35
6.61M
}
Unexecuted instantiation: blake2b_prov.c:load32
blake2s_prov.c:load32
Line
Count
Source
21
6.61M
{
22
6.61M
    DECLARE_IS_ENDIAN;
23
24
6.61M
    if (IS_LITTLE_ENDIAN) {
25
6.61M
        uint32_t w;
26
6.61M
        memcpy(&w, src, sizeof(w));
27
6.61M
        return w;
28
6.61M
    } else {
29
0
        uint32_t w = ((uint32_t)src[0])
30
0
            | ((uint32_t)src[1] << 8)
31
0
            | ((uint32_t)src[2] << 16)
32
0
            | ((uint32_t)src[3] << 24);
33
0
        return w;
34
0
    }
35
6.61M
}
36
37
static ossl_inline uint64_t load64(const uint8_t *src)
38
8.05M
{
39
8.05M
    DECLARE_IS_ENDIAN;
40
41
8.05M
    if (IS_LITTLE_ENDIAN) {
42
8.05M
        uint64_t w;
43
8.05M
        memcpy(&w, src, sizeof(w));
44
8.05M
        return w;
45
8.05M
    } else {
46
0
        uint64_t w = ((uint64_t)src[0])
47
0
            | ((uint64_t)src[1] << 8)
48
0
            | ((uint64_t)src[2] << 16)
49
0
            | ((uint64_t)src[3] << 24)
50
0
            | ((uint64_t)src[4] << 32)
51
0
            | ((uint64_t)src[5] << 40)
52
0
            | ((uint64_t)src[6] << 48)
53
0
            | ((uint64_t)src[7] << 56);
54
0
        return w;
55
0
    }
56
8.05M
}
blake2b_prov.c:load64
Line
Count
Source
38
8.05M
{
39
8.05M
    DECLARE_IS_ENDIAN;
40
41
8.05M
    if (IS_LITTLE_ENDIAN) {
42
8.05M
        uint64_t w;
43
8.05M
        memcpy(&w, src, sizeof(w));
44
8.05M
        return w;
45
8.05M
    } else {
46
0
        uint64_t w = ((uint64_t)src[0])
47
0
            | ((uint64_t)src[1] << 8)
48
0
            | ((uint64_t)src[2] << 16)
49
0
            | ((uint64_t)src[3] << 24)
50
0
            | ((uint64_t)src[4] << 32)
51
0
            | ((uint64_t)src[5] << 40)
52
0
            | ((uint64_t)src[6] << 48)
53
0
            | ((uint64_t)src[7] << 56);
54
0
        return w;
55
0
    }
56
8.05M
}
Unexecuted instantiation: blake2s_prov.c:load64
57
58
static ossl_inline void store32(uint8_t *dst, uint32_t w)
59
574k
{
60
574k
    DECLARE_IS_ENDIAN;
61
62
574k
    if (IS_LITTLE_ENDIAN) {
63
574k
        memcpy(dst, &w, sizeof(w));
64
574k
    } else {
65
0
        uint8_t *p = (uint8_t *)dst;
66
0
        int i;
67
68
0
        for (i = 0; i < 4; i++)
69
0
            p[i] = (uint8_t)(w >> (8 * i));
70
0
    }
71
574k
}
blake2b_prov.c:store32
Line
Count
Source
59
166k
{
60
166k
    DECLARE_IS_ENDIAN;
61
62
166k
    if (IS_LITTLE_ENDIAN) {
63
166k
        memcpy(dst, &w, sizeof(w));
64
166k
    } else {
65
0
        uint8_t *p = (uint8_t *)dst;
66
0
        int i;
67
68
0
        for (i = 0; i < 4; i++)
69
0
            p[i] = (uint8_t)(w >> (8 * i));
70
0
    }
71
166k
}
blake2s_prov.c:store32
Line
Count
Source
59
407k
{
60
407k
    DECLARE_IS_ENDIAN;
61
62
407k
    if (IS_LITTLE_ENDIAN) {
63
407k
        memcpy(dst, &w, sizeof(w));
64
407k
    } else {
65
0
        uint8_t *p = (uint8_t *)dst;
66
0
        int i;
67
68
0
        for (i = 0; i < 4; i++)
69
0
            p[i] = (uint8_t)(w >> (8 * i));
70
0
    }
71
407k
}
72
73
static ossl_inline void store64(uint8_t *dst, uint64_t w)
74
1.52M
{
75
1.52M
    DECLARE_IS_ENDIAN;
76
77
1.52M
    if (IS_LITTLE_ENDIAN) {
78
1.52M
        memcpy(dst, &w, sizeof(w));
79
1.52M
    } else {
80
0
        uint8_t *p = (uint8_t *)dst;
81
0
        int i;
82
83
0
        for (i = 0; i < 8; i++)
84
0
            p[i] = (uint8_t)(w >> (8 * i));
85
0
    }
86
1.52M
}
blake2b_prov.c:store64
Line
Count
Source
74
1.52M
{
75
1.52M
    DECLARE_IS_ENDIAN;
76
77
1.52M
    if (IS_LITTLE_ENDIAN) {
78
1.52M
        memcpy(dst, &w, sizeof(w));
79
1.52M
    } else {
80
0
        uint8_t *p = (uint8_t *)dst;
81
0
        int i;
82
83
0
        for (i = 0; i < 8; i++)
84
0
            p[i] = (uint8_t)(w >> (8 * i));
85
0
    }
86
1.52M
}
Unexecuted instantiation: blake2s_prov.c:store64
87
88
static ossl_inline uint64_t load48(const uint8_t *src)
89
0
{
90
0
    uint64_t w = ((uint64_t)src[0])
91
0
        | ((uint64_t)src[1] << 8)
92
0
        | ((uint64_t)src[2] << 16)
93
0
        | ((uint64_t)src[3] << 24)
94
0
        | ((uint64_t)src[4] << 32)
95
0
        | ((uint64_t)src[5] << 40);
96
0
    return w;
97
0
}
Unexecuted instantiation: blake2b_prov.c:load48
Unexecuted instantiation: blake2s_prov.c:load48
98
99
static ossl_inline void store48(uint8_t *dst, uint64_t w)
100
42.5k
{
101
42.5k
    uint8_t *p = (uint8_t *)dst;
102
42.5k
    p[0] = (uint8_t)w;
103
42.5k
    p[1] = (uint8_t)(w >> 8);
104
42.5k
    p[2] = (uint8_t)(w >> 16);
105
42.5k
    p[3] = (uint8_t)(w >> 24);
106
42.5k
    p[4] = (uint8_t)(w >> 32);
107
42.5k
    p[5] = (uint8_t)(w >> 40);
108
42.5k
}
Unexecuted instantiation: blake2b_prov.c:store48
blake2s_prov.c:store48
Line
Count
Source
100
42.5k
{
101
42.5k
    uint8_t *p = (uint8_t *)dst;
102
42.5k
    p[0] = (uint8_t)w;
103
42.5k
    p[1] = (uint8_t)(w >> 8);
104
42.5k
    p[2] = (uint8_t)(w >> 16);
105
42.5k
    p[3] = (uint8_t)(w >> 24);
106
42.5k
    p[4] = (uint8_t)(w >> 32);
107
42.5k
    p[5] = (uint8_t)(w >> 40);
108
42.5k
}
109
110
static ossl_inline uint32_t rotr32(const uint32_t w, const unsigned int c)
111
125M
{
112
125M
    return (w >> c) | (w << (32 - c));
113
125M
}
Unexecuted instantiation: blake2b_prov.c:rotr32
blake2s_prov.c:rotr32
Line
Count
Source
111
125M
{
112
125M
    return (w >> c) | (w << (32 - c));
113
125M
}
114
115
static ossl_inline uint64_t rotr64(const uint64_t w, const unsigned int c)
116
160M
{
117
160M
    return (w >> c) | (w << (64 - c));
118
160M
}
blake2b_prov.c:rotr64
Line
Count
Source
116
160M
{
117
160M
    return (w >> c) | (w << (64 - c));
118
160M
}
Unexecuted instantiation: blake2s_prov.c:rotr64