From 599bd71e7b49c67a81e950cd3631d378dcefa76a Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 15 Feb 2023 17:02:46 +0900 Subject: [PATCH] Update activitypub.extend.php --- extend/activitypub.extend.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/extend/activitypub.extend.php b/extend/activitypub.extend.php index 1ef31f5..9791e19 100644 --- a/extend/activitypub.extend.php +++ b/extend/activitypub.extend.php @@ -63,6 +63,26 @@ function activitypub_load_library($name, $callback) { )); } +function activitypub_create_keypair() { + $keypair = array('', ''); + + $privateKeyResource = openssl_pkey_new(array( + 'private_key_bits' => 2048, + 'private_key_type' => OPENSSL_KEYTYPE_RSA + )); + + // Generate the public key for the private key + $privateKeyDetailsArray = openssl_pkey_get_details($privateKeyResource); + + // Export keys to variable + $keypair = array($privateKeyResource, $privateKeyDetailsArray['key']); + + // Free the key from memory. + openssl_free_key($privateKeyResource); + + return $keypair; +} + function activitypub_get_library_data($name) { global $activitypub_loaded_libraries;