]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/cipher_overhead_test.c
2 * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
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
10 #include "internal/nelem.h"
12 #include "../ssl/ssl_local.h"
14 static int cipher_enabled(const SSL_CIPHER
*ciph
)
17 * ssl_cipher_get_overhead() actually works with AEAD ciphers even if the
18 * underlying implementation is not present.
20 if ((ciph
->algorithm_mac
& SSL_AEAD
) != 0)
23 if (ciph
->algorithm_enc
!= SSL_eNULL
24 && EVP_get_cipherbynid(SSL_CIPHER_get_cipher_nid(ciph
)) == NULL
)
27 if (EVP_get_digestbynid(SSL_CIPHER_get_digest_nid(ciph
)) == NULL
)
33 static int cipher_overhead(void)
35 int ret
= 1, i
, n
= ssl3_num_ciphers();
36 const SSL_CIPHER
*ciph
;
37 size_t mac
, in
, blk
, ex
;
39 for (i
= 0; i
< n
; i
++) {
40 ciph
= ssl3_get_cipher(i
);
43 if (!cipher_enabled(ciph
)) {
44 TEST_skip("Skipping disabled cipher %s", ciph
->name
);
47 if (!TEST_true(ssl_cipher_get_overhead(ciph
, &mac
, &in
, &blk
, &ex
))) {
48 TEST_info("Failed getting %s", ciph
->name
);
51 TEST_info("Cipher %s: %zu %zu %zu %zu",
52 ciph
->name
, mac
, in
, blk
, ex
);
60 ADD_TEST(cipher_overhead
);