#include "dsdb/samdb/samdb.h"
#include "dsdb/samdb/ldb_modules/util.h"
-#ifdef TEST_ENCRYPTED_SECRETS
+/* Build either with GnuTLS crypto or Samba crypto. */
+#ifdef HAVE_GNUTLS_AEAD
+ #define BUILD_WITH_GNUTLS_AEAD
+#else /* !HAVE_GNUTLS_AEAD */
#define BUILD_WITH_SAMBA_AES_GCM
- #ifdef HAVE_GNUTLS_AEAD
- #define BUILD_WITH_GNUTLS_AEAD
- #endif
-#else
- #ifdef HAVE_GNUTLS_AEAD
- #define BUILD_WITH_GNUTLS_AEAD
- #else
- #define BUILD_WITH_SAMBA_AES_GCM
- #endif
-#endif
+#endif /* HAVE_GNUTLS_AEAD */
#ifdef BUILD_WITH_GNUTLS_AEAD
#include <gnutls/gnutls.h>
&decrypted->cleartext,
&plain_text));
}
-
- {
- struct PlaintextSecret *decrypted =
- talloc_zero(test_ctx, struct PlaintextSecret);
- samba_decrypt_aead(
- &err,
- test_ctx,
- test_ctx->ldb,
- &es,
- decrypted,
- data);
- assert_int_equal(LDB_SUCCESS, err);
- assert_int_equal(
- plain_text.length,
- decrypted->cleartext.length);
- assert_int_equal(0,
- data_blob_cmp(
- &decrypted->cleartext,
- &plain_text));
- }
}
#endif /* HAVE_GNUTLS_AEAD */
}
}
#endif /* HAVE_GNUTLS_AEAD */
+
/*
* Test samba encryption and decryption and decryption.
*/
+#ifndef HAVE_GNUTLS_AEAD
static void test_samba_value_encryption(void **state)
{
struct ldbtest_ctx *test_ctx =
assert_true(NDR_ERR_CODE_IS_SUCCESS(rc));
assert_true(check_header(&es));
-#ifdef HAVE_GNUTLS_AEAD
- {
- struct PlaintextSecret *decrypted =
- talloc_zero(test_ctx, struct PlaintextSecret);
- gnutls_decrypt_aead(
- &err,
- test_ctx,
- test_ctx->ldb,
- &es,
- decrypted,
- data);
- assert_int_equal(LDB_SUCCESS, err);
- assert_int_equal(
- plain_text.length,
- decrypted->cleartext.length);
- assert_int_equal(0,
- data_blob_cmp(
- &decrypted->cleartext,
- &plain_text));
- }
-#endif /* HAVE_GNUTLS_AEAD */
-
-
{
struct PlaintextSecret *decrypted =
talloc_zero(test_ctx, struct PlaintextSecret);
assert_int_equal(LDB_ERR_OPERATIONS_ERROR, err);
}
}
+#endif
/*
* Test message encryption.
test_gnutls_altered_iv,
setup_with_key,
teardown),
-#endif /* HAVE_GNUTLS_AEAD */
+#else
cmocka_unit_test_setup_teardown(
test_samba_value_encryption,
setup_with_key,
test_samba_altered_iv,
setup_with_key,
teardown),
+#endif /* HAVE_GNUTLS_AEAD */
cmocka_unit_test_setup_teardown(
test_message_encryption_decryption,
setup_with_key,