Files
wolfssl/tests/api/test_camellia.h
T
Tobias Frauenschläger 5cf136d15a F-6426 - Reject Camellia cipher ops when no key is set
The Camellia encrypt and decrypt operations used the key schedule
without checking that a key had ever been configured. A zeroed or
otherwise unkeyed context has a keySz that does not match 128, 192,
or 256, so the underlying block transform hit the default no-op case
and CBC emitted an easily reversible XOR chain while still returning
success. A caller who forgot wc_CamelliaSetKey received a success
code with effectively unencrypted output.

Add a key-state check that accepts only valid Camellia key sizes and
have wc_CamelliaEncryptDirect, wc_CamelliaDecryptDirect,
wc_CamelliaCbcEncrypt, and wc_CamelliaCbcDecrypt return MISSING_KEY
when no key has been set. Mirrors the existing 3DES keySet guard.

Add a regression test covering the unkeyed and garbage key-size paths.
2026-07-02 11:36:01 +02:00

45 lines
1.8 KiB
C

/* test_camellia.h
*
* Copyright (C) 2006-2026 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef WOLFCRYPT_TEST_CAMELLIA_H
#define WOLFCRYPT_TEST_CAMELLIA_H
#include <tests/api/api_decl.h>
int test_wc_CamelliaSetKey(void);
int test_wc_CamelliaSetIV(void);
int test_wc_CamelliaFree(void);
int test_wc_CamelliaEncryptDecryptDirect(void);
int test_wc_CamelliaCbcEncryptDecrypt(void);
int test_wc_Camellia_MissingKey(void);
int test_wc_CamelliaCbc_MonteCarlo(void);
#define TEST_CAMELLIA_DECLS \
TEST_DECL_GROUP("camellia", test_wc_CamelliaSetKey), \
TEST_DECL_GROUP("camellia", test_wc_CamelliaSetIV), \
TEST_DECL_GROUP("camellia", test_wc_CamelliaFree), \
TEST_DECL_GROUP("camellia", test_wc_CamelliaEncryptDecryptDirect), \
TEST_DECL_GROUP("camellia", test_wc_CamelliaCbcEncryptDecrypt), \
TEST_DECL_GROUP("camellia", test_wc_Camellia_MissingKey), \
TEST_DECL_GROUP("camellia", test_wc_CamelliaCbc_MonteCarlo)
#endif /* WOLFCRYPT_TEST_CAMELLIA_H */