Files
wolfssl/tests/api/test_rc2.h
T
Tobias Frauenschläger 7562ae5e37 F-6427 - Reject RC2 cipher ops when no key is set
The RC2 encrypt and decrypt operations used the expanded key schedule
without checking that a key had ever been configured. On a zeroed or
otherwise unkeyed context the ECB ops ran over an all-zero schedule and
returned success, and the CBC wrappers inherited the same behavior, so
a caller who skipped wc_Rc2SetKey received ciphertext under an
unintended key with no error signalled.

Guard wc_Rc2EcbEncrypt and wc_Rc2EcbDecrypt on a zero keylen and return
MISSING_KEY when no key has been set. The CBC wrappers call these and
propagate the error. Mirrors the existing 3DES keySet guard.

Add a regression test covering the unkeyed path for all four ops.
2026-07-02 11:36:01 +02:00

45 lines
1.6 KiB
C

/* test_rc2.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_RC2_H
#define WOLFCRYPT_TEST_RC2_H
#include <tests/api/api_decl.h>
int test_wc_Rc2SetKey(void);
int test_wc_Rc2SetIV(void);
int test_wc_Rc2EcbEncryptDecrypt(void);
int test_wc_Rc2CbcEncryptDecrypt(void);
int test_wc_Rc2_MissingKey(void);
int test_wc_Rc2Cbc_MonteCarlo(void);
int test_wc_Rc2Free(void);
#define TEST_RC2_DECLS \
TEST_DECL_GROUP("rc2", test_wc_Rc2SetKey), \
TEST_DECL_GROUP("rc2", test_wc_Rc2SetIV), \
TEST_DECL_GROUP("rc2", test_wc_Rc2EcbEncryptDecrypt), \
TEST_DECL_GROUP("rc2", test_wc_Rc2CbcEncryptDecrypt), \
TEST_DECL_GROUP("rc2", test_wc_Rc2_MissingKey), \
TEST_DECL_GROUP("rc2", test_wc_Rc2Cbc_MonteCarlo), \
TEST_DECL_GROUP("rc2", test_wc_Rc2Free)
#endif /* WOLFCRYPT_TEST_RC2_H */