diff options
| author | levlam <levlam@telegram.org> | 2020-12-22 22:28:04 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2020-12-22 22:28:04 +0300 |
| commit | 03bb56ae96f231edddefff50154c94de8f5efa23 (patch) | |
| tree | a56889749788a7001fe2263cf32b85eea6bef774 /test/mtproto.cpp | |
| parent | 7d1e5bca553fda802bd2455a80a21f32a49d97d1 (diff) | |
Add RSA test.
Diffstat (limited to 'test/mtproto.cpp')
| -rw-r--r-- | test/mtproto.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/mtproto.cpp b/test/mtproto.cpp index 873933291..8aca9dccd 100644 --- a/test/mtproto.cpp +++ b/test/mtproto.cpp @@ -711,3 +711,22 @@ TEST(Mtproto, TlsTransport) { } sched.finish(); } + +TEST(Mtproto, RSA) { + auto pem = td::Slice( + "-----BEGIN RSA PUBLIC KEY-----\n" + "MIIBCgKCAQEAr4v4wxMDXIaMOh8bayF/NyoYdpcysn5EbjTIOZC0RkgzsRj3SGlu\n" + "52QSz+ysO41dQAjpFLgxPVJoOlxXokaOq827IfW0bGCm0doT5hxtedu9UCQKbE8j\n" + "lDOk+kWMXHPZFJKWRgKgTu9hcB3y3Vk+JFfLpq3d5ZB48B4bcwrRQnzkx5GhWOFX\n" + "x73ZgjO93eoQ2b/lDyXxK4B4IS+hZhjzezPZTI5upTRbs5ljlApsddsHrKk6jJNj\n" + "8Ygs/ps8e6ct82jLXbnndC9s8HjEvDvBPH9IPjv5JUlmHMBFZ5vFQIfbpo0u0+1P\n" + "n6bkEi5o7/ifoyVv2pAZTRwppTz0EuXD8QIDAQAB\n" + "-----END RSA PUBLIC KEY-----"); + auto rsa = RSA::from_pem_public_key(pem).move_as_ok(); + ASSERT_EQ(-7596991558377038078, rsa.get_fingerprint()); + ASSERT_EQ(256u, rsa.size()); + + string s(255, '\0'); + string to(256, '\0'); + ASSERT_EQ(256u, rsa.encrypt(MutableSlice(s).ubegin(), 10, 255, MutableSlice(to).ubegin(), 256)); +} |
