[Asterisk-code-review] test: Add coverage for res_crypto (asterisk[master])

Philip Prindeville asteriskteam at digium.com
Fri May 6 11:34:15 CDT 2022


Philip Prindeville has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18532 )


Change subject: test: Add coverage for res_crypto
......................................................................

test: Add coverage for res_crypto

ASTERISK-30045 #close

Signed-off-by: Philip Prindeville <philipp at redfish-solutions.com>
Change-Id: I0d10e7b41009c5290a4356c6480e636712d5c96d
---
M include/asterisk/crypto.h
M res/res_crypto.c
M tests/Makefile
A tests/keys/rsa_key1.key
A tests/keys/rsa_key1.pub
A tests/test_crypto.c
6 files changed, 529 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/18532/1

diff --git a/include/asterisk/crypto.h b/include/asterisk/crypto.h
index 38c413f..ff294ee 100644
--- a/include/asterisk/crypto.h
+++ b/include/asterisk/crypto.h
@@ -39,6 +39,9 @@
 typedef char ast_aes_decrypt_key;
 #endif /* HAVE_CRYPTO */
 
+#define AST_CRYPTO_RSA_KEY_BITS		1024
+#define AST_CRYPTO_AES_BLOCKSIZE	128
+
 #define AST_KEY_PUBLIC	(1 << 0)
 #define AST_KEY_PRIVATE	(1 << 1)
 
@@ -180,6 +183,8 @@
 
 AST_OPTIONAL_API(int, ast_crypto_loaded, (void), { return 0; });
 
+AST_OPTIONAL_API(int, ast_crypto_reload, (void), { return 0; });
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
diff --git a/res/res_crypto.c b/res/res_crypto.c
index a11182b..462a71a 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -95,6 +95,8 @@
 
 static AST_RWLIST_HEAD_STATIC(keys, ast_key);
 
+static void crypto_load(int ifd, int ofd);
+
 /*!
  * \brief setting of priv key
  * \param buf
@@ -318,7 +320,7 @@
 	SHA1((unsigned char *)msg, msglen, digest);
 
 	/* Verify signature */
-	if (!(res = RSA_sign(NID_sha1, digest, sizeof(digest), dsig, &siglen, key->rsa))) {
+	if ((res = RSA_sign(NID_sha1, digest, sizeof(digest), dsig, &siglen, key->rsa)) != 1) {
 		ast_log(LOG_WARNING, "RSA Signature (key %s) failed\n", key->name);
 		return -1;
 	}
@@ -431,7 +433,7 @@
 	SHA1((unsigned char *)msg, msglen, digest);
 
 	/* Verify signature */
-	if (!(res = RSA_verify(NID_sha1, digest, sizeof(digest), (unsigned char *)dsig, 128, key->rsa))) {
+	if ((res = RSA_verify(NID_sha1, digest, sizeof(digest), (unsigned char *)dsig, 128, key->rsa)) != 1) {
 		ast_debug(1, "Key failed verification: %s\n", key->name);
 		return -1;
 	}
@@ -465,6 +467,12 @@
 	return 1;
 }
 
+int AST_OPTIONAL_API_NAME(ast_crypto_reload)(void)
+{
+	crypto_load(-1, -1);
+	return 1;
+}
+
 int AST_OPTIONAL_API_NAME(ast_aes_set_encrypt_key)(const unsigned char *key, ast_aes_encrypt_key *ctx)
 {
 	return AES_set_encrypt_key(key, 128, ctx);
diff --git a/tests/Makefile b/tests/Makefile
index 04acd69..745be29 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -21,5 +21,6 @@
 
 test_astobj2.o: _ASTCFLAGS+=$(call get_menuselect_cflags,AO2_DEBUG)
 test_capture.o: _ASTCFLAGS+=-Wno-format-y2k
+test_crypto.o: _ASTCFLAGS+=-Wno-format-truncation
 test_strings.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION) $(AST_NO_STRINGOP_TRUNCATION)
 test_voicemail_api.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)
diff --git a/tests/keys/rsa_key1.key b/tests/keys/rsa_key1.key
new file mode 100644
index 0000000..117a4e9
--- /dev/null
+++ b/tests/keys/rsa_key1.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQC206PN7hvmoc0p1urAeKozmUha/h3KIAIO4DG5Muz6x3Zribdx
+cKfgmw28FwamAGT1n0y1+qGkL1vyHY4YMDjHVVSLB8h5Je89UxgXxl/PUpSx4kFN
+gZofk28Mx1lG2aLEBHXFNhrjZbdfZzeljZHYfrsLf9nxQvYeA0W2YJ3g1wIDAQAB
+AoGBAJ2V9OYmrAPySS4cIoI+P650G+raiIDVcBC0bAeO/rb2QHtW3Di6euldnMwY
+KNHjGyKf6XYeDz++1ojtsrHktrqcaXfh9J1qpxXXGxMZww00so+VOrhCbs0uf6Yh
+FdZ1Dc3UsBLhrA/fBaaw3xRwFvsgnxmJPX6R/gmC+A6uc/QxAkEA5z9TBbdW6bsA
+SPCmUOmSalX9WyGrbaZwkvCBtuKCfHzKUcxdbXw8e68GralzGITwU3XcYn/mVqk0
+ztfBWNt+fwJBAMplfFU7uPDZwfjC3eXXljxaSzoA7EzLcByslYLuAJMYKITQOiv0
+KBb+zJxvTntArF5TOkCeVYUMZKcL8HEXIakCQFaOwnHKTZMRdyrWQTraIv8AjuQU
+t0lE2rB1q+gb4wHb6BM0Luhzb2RQgGxyl+1enWJwJH0OKNbZYTXnVqz/A9sCQFME
+4cUMZEXW7GufcumOTr+ewfCe5E5zvB7m48T63x128VfZGaNh2PfluAQK3AROeOWP
++fr7d1TFypuCmDOrK1ECQH1CeBWxVRx695uYmsAYwX8FNIn0agFasdk7wGUyP7ow
+idIaA92AHJ1gQXbEyh4iDrZZdh5fopg8sxRXdFfouFo=
+-----END RSA PRIVATE KEY-----
diff --git a/tests/keys/rsa_key1.pub b/tests/keys/rsa_key1.pub
new file mode 100644
index 0000000..d25a2e4
--- /dev/null
+++ b/tests/keys/rsa_key1.pub
@@ -0,0 +1,6 @@
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC206PN7hvmoc0p1urAeKozmUha
+/h3KIAIO4DG5Muz6x3ZribdxcKfgmw28FwamAGT1n0y1+qGkL1vyHY4YMDjHVVSL
+B8h5Je89UxgXxl/PUpSx4kFNgZofk28Mx1lG2aLEBHXFNhrjZbdfZzeljZHYfrsL
+f9nxQvYeA0W2YJ3g1wIDAQAB
+-----END PUBLIC KEY-----
diff --git a/tests/test_crypto.c b/tests/test_crypto.c
new file mode 100644
index 0000000..1238895
--- /dev/null
+++ b/tests/test_crypto.c
@@ -0,0 +1,492 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2022, Digium, Inc.
+ *
+ * Philip Prindeville <philipp at redfish-solutions.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Unit Tests for crypto API
+ *
+ * \author Philip Prindeville <philipp at redfish-solutions.com>
+ */
+
+/*** MODULEINFO
+        <depend>TEST_FRAMEWORK</depend>
+        <depend>res_crypto</depend>
+        <depend>crypto</depend>
+        <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+#include "asterisk/utils.h"
+#include "asterisk/test.h"
+#include "asterisk/crypto.h"
+#include "asterisk/paths.h"
+#include "asterisk/module.h"
+
+#include <assert.h>
+#include <linux/limits.h>
+#include <openssl/evp.h>
+
+static const char *keypair1 = "rsa_key1";
+
+static const char *old_key_dir = NULL;
+
+__attribute__ ((__unused__)) static char *hexstring(const unsigned char *data, unsigned datalen)
+{
+	char *buf = alloca(datalen * 4 + 1);
+
+	for (unsigned n = 0; n < datalen; ++n)
+		snprintf(&buf[n * 4], 5, "\\x%02x", data[n]);
+	buf[datalen * 4] = '\0';
+	return buf;
+}
+
+static void push_key_dir(const char *dir)
+{
+	assert(old_key_dir == NULL);
+
+	old_key_dir = ast_config_AST_KEY_DIR;
+
+	ast_config_AST_KEY_DIR = ast_strdup(dir);
+}
+
+static void pop_key_dir(void)
+{
+	assert(old_key_dir != NULL);
+
+	ast_free((char *)ast_config_AST_KEY_DIR);
+
+	ast_config_AST_KEY_DIR = old_key_dir;
+
+	old_key_dir = NULL;
+}
+
+AST_TEST_DEFINE(crypto_encrypt_pub_key)
+{
+	int res = AST_TEST_FAIL;
+	struct ast_key *key = NULL;
+	const unsigned char plaintext[23] = "Mary had a little lamb.";
+	char key_dir[PATH_MAX], priv[PATH_MAX];
+	unsigned char buf[AST_CRYPTO_RSA_KEY_BITS / 8];
+	const char *path = "openssl";
+	char *args[] = { "openssl", "rsautl", "-decrypt", "-inkey", "PRIVATE", "-oaep", NULL };
+	struct ast_test_capture cap;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "crypto_encrypt_pub_key";
+		info->category = "/res/res_crypto/";
+		info->summary = "Encrypt w/ RSA public key";
+		info->description = "Encrypt string with RSA public key";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	getcwd(key_dir, sizeof(key_dir));
+	strcat(key_dir, "/tests/keys");
+	push_key_dir((const char *)key_dir);
+	snprintf(priv, sizeof(priv), "%s/%s.key", key_dir, keypair1);
+
+	if (ast_crypto_reload() != 1) {
+		ast_test_status_update(test, "Couldn't force crypto reload\n");
+		goto cleanup;
+	}
+
+	key = ast_key_get(keypair1, AST_KEY_PUBLIC);
+
+	if (key == NULL) {
+		ast_test_status_update(test, "Couldn't read key: %s\n", keypair1);
+		goto cleanup;
+	}
+
+	memset(buf, 0, sizeof(buf));
+	ast_encrypt_bin(buf, plaintext, sizeof(plaintext), key);
+
+	args[4] = priv;
+	if (ast_test_capture_command(&cap, path, args, (const char *)buf, sizeof(buf)) != 1) {
+		ast_test_status_update(test, "ast_test_capture_command() failed\n");
+		goto cleanup;
+	}
+
+	if (cap.outlen != sizeof(plaintext) || memcmp(cap.outbuf, plaintext, cap.outlen)) {
+		ast_test_status_update(test, "Unexpected value/length for stdout\n");
+		goto cleanup;
+	}
+
+	if (cap.errlen != 0) {
+		ast_test_status_update(test, "Unexpected length for stderr: '%.*s'\n", (int) cap.errlen, cap.errbuf);
+		goto cleanup;
+	}
+
+	if (cap.pid == -1) {
+		ast_test_status_update(test, "Invalid process id\n");
+		goto cleanup;
+	}
+
+	if (cap.exitcode != 0) {
+		ast_test_status_update(test, "Child exited %d\n", cap.exitcode);
+		goto cleanup;
+	}
+
+	res = AST_TEST_PASS;
+
+cleanup:
+	pop_key_dir();
+	return res;
+}
+
+AST_TEST_DEFINE(crypto_decrypt_priv_key)
+{
+	int res = AST_TEST_FAIL;
+	struct ast_key *key = NULL;
+	const unsigned char plaintext[23] = "Mary had a little lamb.";
+	char key_dir[PATH_MAX], pub[PATH_MAX];
+	unsigned char buf[AST_CRYPTO_RSA_KEY_BITS / 8];
+	const char *path = "openssl";
+	char *args[] = { "openssl", "rsautl", "-encrypt", "-pubin", "-inkey", "PUBLIC", "-oaep", NULL };
+	struct ast_test_capture cap;
+	int len;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "crypto_decrypt_pub_key";
+		info->category = "/res/res_crypto/";
+		info->summary = "Decrypt w/ RSA public key";
+		info->description = "Decrypt string with RSA private key";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	getcwd(key_dir, sizeof(key_dir));
+	strcat(key_dir, "/tests/keys");
+	push_key_dir((const char *)key_dir);
+	snprintf(pub, sizeof(pub), "%s/%s.pub", key_dir, keypair1);
+
+	if (ast_crypto_reload() != 1) {
+		ast_test_status_update(test, "Couldn't force crypto reload\n");
+		goto cleanup;
+	}
+
+	key = ast_key_get(keypair1, AST_KEY_PRIVATE);
+
+	if (key == NULL) {
+		ast_test_status_update(test, "Couldn't read key: %s\n", keypair1);
+		goto cleanup;
+	}
+
+	args[5] = pub;
+	if (ast_test_capture_command(&cap, path, args, (const char *)plaintext, sizeof(plaintext)) != 1) {
+		ast_test_status_update(test, "ast_test_capture_command() failed\n");
+		goto cleanup;
+	}
+
+	if (cap.outlen != sizeof(buf)) {
+		ast_test_status_update(test, "Unexpected length for stdout\n");
+		goto cleanup;
+	}
+
+	if (cap.errlen != 0) {
+		ast_test_status_update(test, "Unexpected value for stderr: '%.*s'\n", (int) cap.errlen, cap.errbuf);
+		goto cleanup;
+	}
+
+	if (cap.pid == -1) {
+		ast_test_status_update(test, "Invalid process id\n");
+		goto cleanup;
+	}
+
+	if (cap.exitcode != 0) {
+		ast_test_status_update(test, "Child exited %d\n", cap.exitcode);
+		goto cleanup;
+	}
+
+	memset(buf, 0, sizeof(buf));
+	len = ast_decrypt_bin(buf, (unsigned char *)cap.outbuf, cap.outlen, key);
+
+	if (len != sizeof(plaintext) || memcmp(buf, plaintext, len)) {
+		ast_test_status_update(test, "Unexpected value for decrypted text\n");
+		goto cleanup;
+	}
+
+	res = AST_TEST_PASS;
+
+cleanup:
+	pop_key_dir();
+	return res;
+}
+
+AST_TEST_DEFINE(crypto_sign)
+{
+	int res = AST_TEST_FAIL;
+	struct ast_key *key = NULL;
+	const char plaintext[23] = "Mary had a little lamb.";
+	char key_dir[PATH_MAX], priv[PATH_MAX];
+	unsigned char buf[AST_CRYPTO_RSA_KEY_BITS / 8];
+	const char *path = "openssl";
+	char *args[] = { "openssl", "dgst", "-sha1", "-sign", "PRIVATE", NULL };
+	struct ast_test_capture cap;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "crypto_sign";
+		info->category = "/res/res_crypto/";
+		info->summary = "Sign w/ RSA private key";
+		info->description = "Sign string with RSA private key";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	getcwd(key_dir, sizeof(key_dir));
+	strcat(key_dir, "/tests/keys");
+	push_key_dir((const char *)key_dir);
+	snprintf(priv, sizeof(priv), "%s/%s.key", key_dir, keypair1);
+
+	if (ast_crypto_reload() != 1) {
+		ast_test_status_update(test, "Couldn't force crypto reload\n");
+		goto cleanup;
+	}
+
+	key = ast_key_get(keypair1, AST_KEY_PRIVATE);
+
+	if (key == NULL) {
+		ast_test_status_update(test, "Couldn't read key: %s\n", keypair1);
+		goto cleanup;
+	}
+
+	memset(buf, 0, sizeof(buf));
+	if (ast_sign_bin(key, plaintext, sizeof(plaintext), buf) != 0) {
+		ast_test_status_update(test, "ast_sign_bin() failed\n");
+		goto cleanup;
+	}
+
+	args[4] = priv;
+	if (ast_test_capture_command(&cap, path, args, (const char *)plaintext, sizeof(plaintext)) != 1) {
+		ast_test_status_update(test, "ast_test_capture_command() failed\n");
+		goto cleanup;
+	}
+
+	if (cap.outlen != sizeof(buf) || memcmp(cap.outbuf, buf, cap.outlen)) {
+		ast_test_status_update(test, "Unexpected value/length for stdout\n");
+		goto cleanup;
+	}
+
+	if (cap.errlen != 0) {
+		ast_test_status_update(test, "Unexpected value for stderr: '%.*s'\n", (int) cap.errlen, cap.errbuf);
+		goto cleanup;
+	}
+
+	if (cap.pid == -1) {
+		ast_test_status_update(test, "Invalid process id\n");
+		goto cleanup;
+	}
+
+	if (cap.exitcode != 0) {
+		ast_test_status_update(test, "Child exited %d\n", cap.exitcode);
+		goto cleanup;
+	}
+
+	res = AST_TEST_PASS;
+
+cleanup:
+	pop_key_dir();
+	return res;
+}
+
+AST_TEST_DEFINE(crypto_verify)
+{
+	int res = AST_TEST_FAIL;
+	struct ast_key *key = NULL;
+	const char plaintext[23] = "Mary had a little lamb.";
+	char key_dir[PATH_MAX], priv[PATH_MAX];
+	const char *path = "openssl";
+	char *args[] = { "openssl", "dgst", "-sha1", "-sign", "PRIVATE", NULL };
+	struct ast_test_capture cap;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "crypto_verify";
+		info->category = "/res/res_crypto/";
+		info->summary = "Verify w/ RSA public key";
+		info->description = "Verify signature with RSA public key";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	getcwd(key_dir, sizeof(key_dir));
+	strcat(key_dir, "/tests/keys");
+	push_key_dir((const char *)key_dir);
+	snprintf(priv, sizeof(priv), "%s/%s.key", key_dir, keypair1);
+
+	if (ast_crypto_reload() != 1) {
+		ast_test_status_update(test, "Couldn't force crypto reload\n");
+		goto cleanup;
+	}
+
+	key = ast_key_get(keypair1, AST_KEY_PUBLIC);
+
+	if (key == NULL) {
+		ast_test_status_update(test, "Couldn't read key: %s\n", keypair1);
+		goto cleanup;
+	}
+
+	args[4] = priv;
+	if (ast_test_capture_command(&cap, path, args, (const char *)plaintext, sizeof(plaintext)) != 1) {
+		ast_test_status_update(test, "ast_test_capture_command() failed\n");
+		goto cleanup;
+	}
+
+	if (cap.outlen != (AST_CRYPTO_RSA_KEY_BITS / 8)) {
+		ast_test_status_update(test, "Unexpected length for stdout\n");
+		goto cleanup;
+	}
+
+	if (cap.errlen != 0) {
+		ast_test_status_update(test, "Unexpected value for stderr: '%.*s'\n", (int) cap.errlen, cap.errbuf);
+		goto cleanup;
+	}
+
+	if (cap.pid == -1) {
+		ast_test_status_update(test, "Invalid process id\n");
+		goto cleanup;
+	}
+
+	if (cap.exitcode != 0) {
+		ast_test_status_update(test, "Child exited %d\n", cap.exitcode);
+		goto cleanup;
+	}
+
+	if (ast_check_signature_bin(key, plaintext, sizeof(plaintext), (const unsigned char *)cap.outbuf) != 0) {
+		ast_test_status_update(test, "ast_check_signature_bin() failed\n");
+		goto cleanup;
+	}
+
+	res = AST_TEST_PASS;
+
+cleanup:
+	pop_key_dir();
+	return res;
+}
+
+AST_TEST_DEFINE(crypto_aes_encrypt)
+{
+	int res = AST_TEST_FAIL;
+	const unsigned char key[16] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01 };
+	const unsigned char plaintext[16] = "Mary had a littl";
+	const unsigned char crypttext[16] = {
+		0xad, 0xc2, 0xcd, 0x9e, 0x6e, 0x8a, 0xda, 0x0c,
+		0xe7, 0x71, 0xc8, 0x75, 0x52, 0xf9, 0x7d, 0xd5
+	};
+	unsigned char buf[16];
+	ast_aes_encrypt_key aes_key;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "crypto_aes_encrypt";
+		info->category = "/res/res_crypto/";
+		info->summary = "Encrypt test AES-128-ECB";
+		info->description = "Encrypt a test string using AES-128 and ECB";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	memset(buf, 0, sizeof(buf));
+	ast_aes_set_encrypt_key(key, &aes_key);
+	ast_aes_encrypt(plaintext, buf, &aes_key);
+
+	if (memcmp(crypttext, buf, sizeof(crypttext))) {
+		ast_test_status_update(test, "AES encryption mismatch\n");
+		goto cleanup;
+	}
+
+	res = AST_TEST_PASS;
+
+cleanup:
+	return res;
+}
+
+AST_TEST_DEFINE(crypto_aes_decrypt)
+{
+	int res = AST_TEST_FAIL;
+	const unsigned char key[16] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45, 0x67, 0x89, 0x01 };
+	const unsigned char plaintext[16] = "Mary had a littl";
+	const unsigned char crypttext[16] = {
+		0xad, 0xc2, 0xcd, 0x9e, 0x6e, 0x8a, 0xda, 0x0c,
+		0xe7, 0x71, 0xc8, 0x75, 0x52, 0xf9, 0x7d, 0xd5
+	};
+	unsigned char buf[16];
+	ast_aes_encrypt_key aes_key;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "crypto_aes_decrypt";
+		info->category = "/res/res_crypto/";
+		info->summary = "Decrypt test AES-128-ECB";
+		info->description = "Decrypt a test string using AES-128 and ECB";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	memset(buf, 0, sizeof(buf));
+	ast_aes_set_decrypt_key(key, &aes_key);
+	ast_aes_decrypt(crypttext, buf, &aes_key);
+
+	if (memcmp(plaintext, buf, sizeof(plaintext))) {
+		ast_test_status_update(test, "AES decryption mismatch\n");
+		goto cleanup;
+	}
+
+	res = AST_TEST_PASS;
+
+cleanup:
+	return res;
+}
+
+static int unload_module(void)
+{
+	AST_TEST_UNREGISTER(crypto_encrypt_pub_key);
+	AST_TEST_UNREGISTER(crypto_decrypt_priv_key);
+	AST_TEST_UNREGISTER(crypto_sign);
+	AST_TEST_UNREGISTER(crypto_verify);
+	AST_TEST_UNREGISTER(crypto_aes_encrypt);
+	AST_TEST_UNREGISTER(crypto_aes_decrypt);
+	return 0;
+}
+
+static int load_module(void)
+{
+	AST_TEST_REGISTER(crypto_encrypt_pub_key);
+	AST_TEST_REGISTER(crypto_decrypt_priv_key);
+	AST_TEST_REGISTER(crypto_sign);
+	AST_TEST_REGISTER(crypto_verify);
+	AST_TEST_REGISTER(crypto_aes_encrypt);
+	AST_TEST_REGISTER(crypto_aes_decrypt);
+	return AST_MODULE_LOAD_SUCCESS;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Crypto test module",
+	.support_level = AST_MODULE_SUPPORT_CORE,
+	.load = load_module,
+	.unload = unload_module,
+	.requires = "res_crypto",
+);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18532
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I0d10e7b41009c5290a4356c6480e636712d5c96d
Gerrit-Change-Number: 18532
Gerrit-PatchSet: 1
Gerrit-Owner: Philip Prindeville <philipp at redfish-solutions.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220506/b1ce9e19/attachment-0001.html>


More information about the asterisk-code-review mailing list