Coverage Report

Created: 2026-02-22 06:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/evp/e_chacha20_poly1305.c
Line
Count
Source
1
/*
2
 * Copyright 2015-2025 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 <openssl/macros.h>
11
12
#ifndef OPENSSL_NO_CHACHA
13
14
#include "crypto/evp.h"
15
#include "crypto/chacha.h"
16
17
static const EVP_CIPHER chacha20 = {
18
    NID_chacha20,
19
    1, /* block_size */
20
    CHACHA_KEY_SIZE, /* key_len */
21
    CHACHA_CTR_SIZE, /* iv_len, 128-bit counter in the context */
22
    EVP_CIPH_CUSTOM_IV | EVP_CIPH_ALWAYS_CALL_INIT,
23
    EVP_ORIG_GLOBAL
24
};
25
26
const EVP_CIPHER *EVP_chacha20(void)
27
3
{
28
3
    return &chacha20;
29
3
}
30
31
#ifndef OPENSSL_NO_POLY1305
32
33
static const EVP_CIPHER chacha20_poly1305 = {
34
    NID_chacha20_poly1305,
35
    1, /* block_size */
36
    CHACHA_KEY_SIZE, /* key_len */
37
    12, /* iv_len, 96-bit nonce in the context */
38
    EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_CUSTOM_IV | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT | EVP_CIPH_CUSTOM_COPY | EVP_CIPH_FLAG_CUSTOM_CIPHER | EVP_CIPH_CUSTOM_IV_LENGTH,
39
    EVP_ORIG_GLOBAL
40
};
41
42
const EVP_CIPHER *EVP_chacha20_poly1305(void)
43
3
{
44
3
    return (&chacha20_poly1305);
45
3
}
46
#endif
47
#else
48
NON_EMPTY_TRANSLATION_UNIT
49
#endif