aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/openssl/crypto/ut/rsa_ut.cpp
diff options
context:
space:
mode:
authoralexvru <alexvru@ydb.tech>2023-08-15 21:09:36 +0300
committeralexvru <alexvru@ydb.tech>2023-08-15 21:42:49 +0300
commitd6f67906ea5b369b47bce8e0a7125d66114fdbde (patch)
treec9c44a3a1a396a6cab33e1260c67f2e5b8b76ea4 /library/cpp/openssl/crypto/ut/rsa_ut.cpp
parentf096c967c8a4b645763f901c889ca0335a0e5412 (diff)
downloadydb-d6f67906ea5b369b47bce8e0a7125d66114fdbde.tar.gz
Support BS autoconfig KIKIMR-19031
Diffstat (limited to 'library/cpp/openssl/crypto/ut/rsa_ut.cpp')
-rw-r--r--library/cpp/openssl/crypto/ut/rsa_ut.cpp28
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..c11814f8fe
--- /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));
+ }
+}