/*
- * Copyright (c) 2016-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016-2021 Samsung Electronics Co., Ltd All Rights Reserved
*
* Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
*
max_len = ret;
+ if (input_len > max_len)
+ return YACA_ERROR_INVALID_PARAMETER;
+
ret = yaca_zalloc(max_len, (void**)&loutput);
if (ret != YACA_ERROR_NONE)
return ret;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2020-2021 Samsung Electronics Co., Ltd All Rights Reserved
*
* Contact: Lukasz Pawelczyk <l.pawelczyk@samsung.com>
*
#include <boost/test/unit_test.hpp>
#include <vector>
+#include <limits>
#include <yaca_crypto.h>
#include <yaca_rsa.h>
BOOST_REQUIRE(ret == YACA_ERROR_INVALID_PARAMETER);
ret = yaca_rsa_public_encrypt(YACA_PADDING_NONE, key_pub,
+ INPUT_DATA, UINT_MAX,
+ &encrypted, &encrypted_len);
+ BOOST_REQUIRE(ret == YACA_ERROR_INVALID_PARAMETER);
+
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_NONE, key_pub,
INPUT_DATA, input_len,
NULL, &encrypted_len);
BOOST_REQUIRE(ret == YACA_ERROR_INVALID_PARAMETER);
&encrypted_pkcs1, &encrypted_pkcs1_len);
BOOST_REQUIRE(ret == YACA_ERROR_INVALID_PARAMETER);
+ ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, key_pub,
+ INPUT_DATA, UINT_MAX,
+ &encrypted_pkcs1, &encrypted_pkcs1_len);
+ BOOST_REQUIRE(ret == YACA_ERROR_INVALID_PARAMETER);
+
ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1_OAEP, key_pub,
INPUT_DATA, input_len_pkcs1_oaep + 1,
&encrypted_pkcs1_oaep, &encrypted_pkcs1_oaep_len);