]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/crypto: more aes256krb5 tests
authorYehuda Sadeh <ysadehwe@ibm.com>
Mon, 17 Mar 2025 07:57:42 +0000 (03:57 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Mon, 26 Jan 2026 15:26:32 +0000 (10:26 -0500)
Signed-off-by: Yehuda Sadeh <ysadehwe@ibm.com>
src/test/crypto.cc

index a814b5e106cfbce845f9d3c2a3b2e0a4c36aaff4..8ae35ec7c703b3fdfa543f0a9b58df3dd1b81480 100644 (file)
@@ -246,10 +246,10 @@ TEST(AES, LoopCephxV2) {
   aes_loop_cephx<32>();
 }
 
-static void aes_loop(const std::size_t text_size) {
+static void cipher_loop(const std::size_t text_size, int type, int cipher_len) {
   CryptoRandom random;
 
-  bufferptr secret(16);
+  bufferptr secret(cipher_len);
   random.get_bytes(secret.c_str(), secret.length());
 
   bufferptr orig_plaintext(text_size);
@@ -261,7 +261,7 @@ static void aes_loop(const std::size_t text_size) {
   for (int i=0; i<10000; i++) {
     bufferlist cipher;
     {
-      auto h = g_ceph_context->get_crypto_manager()->get_handler(CEPH_CRYPTO_AES);
+      auto h = g_ceph_context->get_crypto_manager()->get_handler(type);
 
       std::string error;
       CryptoKeyHandler *kh = h->get_key_handler(secret, error);
@@ -274,7 +274,7 @@ static void aes_loop(const std::size_t text_size) {
     plaintext.clear();
 
     {
-      auto h = g_ceph_context->get_crypto_manager()->get_handler(CEPH_CRYPTO_AES);
+      auto h = g_ceph_context->get_crypto_manager()->get_handler(type);
       std::string error;
       CryptoKeyHandler *ckh = h->get_key_handler(secret, error);
       int r = ckh->decrypt(g_ceph_context, cipher, plaintext, &error);
@@ -290,6 +290,10 @@ static void aes_loop(const std::size_t text_size) {
   ASSERT_EQ(orig, plaintext);
 }
 
+static void aes_loop(const std::size_t text_size) {
+  cipher_loop(text_size, CEPH_CRYPTO_AES, 16);
+}
+
 TEST(AES, Loop) {
   aes_loop(256);
 }
@@ -439,3 +443,19 @@ TEST(AES256KRB5, Decrypt) {
   delete kh;
 }
 
+static void aes256krb5_loop(const std::size_t text_size) {
+  cipher_loop(text_size, CEPH_CRYPTO_AES256KRB5, 32);
+}
+
+TEST(AES256KRB5, Loop) {
+  aes256krb5_loop(256);
+}
+
+TEST(AES256KRB5, Loop_29) {
+  aes256krb5_loop(29);
+}
+
+TEST(AES256KRB5, Loop_32) {
+  aes256krb5_loop(32);
+}
+