]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_crypto: make keys reloadable on demand for testing
authorPhilip Prindeville <philipp@redfish-solutions.com>
Tue, 26 Jul 2022 17:38:32 +0000 (11:38 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 12 Sep 2022 18:08:49 +0000 (13:08 -0500)
ASTERISK-30045

Change-Id: If59bbb50c1771084bfe2fef307a6077c90d35ce8

include/asterisk/crypto.h
res/res_crypto.c

index 38c413f4db028710549aa2a1ce40be98e47052af..7b889e117c37198253df27dfae7aab0f02aba8ae 100644 (file)
@@ -180,6 +180,8 @@ AST_OPTIONAL_API(void, ast_aes_decrypt,
 
 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
index 71cc9798d150820617e7310fb12a4a695f280871..19b011db92f86029738feb7d160a5c194b7375ff 100644 (file)
@@ -95,6 +95,8 @@ struct ast_key {
 
 static AST_RWLIST_HEAD_STATIC(keys, ast_key);
 
+static void crypto_load(int ifd, int ofd);
+
 /*!
  * \brief setting of priv key
  * \param buf
@@ -465,6 +467,12 @@ int AST_OPTIONAL_API_NAME(ast_crypto_loaded)(void)
        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);