diff options
author | komels <komels@yandex-team.ru> | 2022-04-14 13:10:53 +0300 |
---|---|---|
committer | komels <komels@yandex-team.ru> | 2022-04-14 13:10:53 +0300 |
commit | 21c9b0e6b039e9765eb414c406c2b86e8cea6850 (patch) | |
tree | f40ebc18ff8958dfbd189954ad024043ca983ea5 /library/cpp/openssl/crypto/ut/rsa_ut.cpp | |
parent | 9a4effa852abe489707139c2b260dccc6f4f9aa9 (diff) | |
download | ydb-21c9b0e6b039e9765eb414c406c2b86e8cea6850.tar.gz |
Final part on compatibility layer: LOGBROKER-7215
ref:777c67aadbf705d19034a09a792b2df61ba53697
Diffstat (limited to 'library/cpp/openssl/crypto/ut/rsa_ut.cpp')
-rw-r--r-- | library/cpp/openssl/crypto/ut/rsa_ut.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/library/cpp/openssl/crypto/ut/rsa_ut.cpp b/library/cpp/openssl/crypto/ut/rsa_ut.cpp new file mode 100644 index 0000000000..99f0377432 --- /dev/null +++ b/library/cpp/openssl/crypto/ut/rsa_ut.cpp @@ -0,0 +1,28 @@ +#include "rsa.h" + +#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/openssl/big_integer/big_integer.h> + +#include <util/system/byteorder.h> + +using namespace NOpenSsl; +using namespace NOpenSsl::NRsa; + +Y_UNIT_TEST_SUITE(Rsa) { + Y_UNIT_TEST(Encrypt) { + // example from Ru.Wikipedia + const auto originData = TBigInteger::FromULong(111111); + + const auto n = TBigInteger::FromULong(3); + const auto e = TBigInteger::FromULong(9173503); + + // check key reuse + for (size_t i = 0; i < 10; ++i) { + UNIT_ASSERT_VALUES_EQUAL(TBigInteger::FromULong(4051753), TPublicKey(n, e).EncryptNoPad(originData)); + } + + UNIT_ASSERT_VALUES_EQUAL(originData, TBigInteger::FromULong(111111)); + UNIT_ASSERT_VALUES_EQUAL(n, TBigInteger::FromULong(3)); + UNIT_ASSERT_VALUES_EQUAL(e, TBigInteger::FromULong(9173503)); + } +}; |