aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-05-20 18:30:02 -0700
committerfriendica <info@friendica.com>2012-05-20 18:30:02 -0700
commitafaf9ec74fe0662de76deabd11d630f871802579 (patch)
tree58e41106d72d5b76e00de9cf82a00ef82b6edd77 /include/crypto.php
parentf16a1199408d167bbc7c52dc408ef02b36808317 (diff)
downloadvolse-hubzilla-afaf9ec74fe0662de76deabd11d630f871802579.tar.gz
volse-hubzilla-afaf9ec74fe0662de76deabd11d630f871802579.tar.bz2
volse-hubzilla-afaf9ec74fe0662de76deabd11d630f871802579.zip
rev update
Diffstat (limited to 'include/crypto.php')
-rw-r--r--include/crypto.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/include/crypto.php b/include/crypto.php
index 0feb45c24..6fc9a287e 100644
--- a/include/crypto.php
+++ b/include/crypto.php
@@ -292,4 +292,38 @@ function zot_unencapsulate($data,$prvkey) {
$ret['sender'] = $s;
$ret['data'] = aes_unencapsulate($x,$prvkey);
return $ret;
-} \ No newline at end of file
+}
+
+function new_keypair($bits) {
+
+ $openssl_options = array(
+ 'digest_alg' => 'sha1',
+ 'private_key_bits' => $bits,
+ 'encrypt_key' => false
+ );
+
+ $conf = get_config('system','openssl_conf_file');
+ if($conf)
+ $openssl_options['config'] = $conf;
+
+ $result = openssl_pkey_new($openssl_options);
+
+ if(empty($result)) {
+ logger('new_keypair: failed');
+ return false;
+ }
+
+ // Get private key
+
+ $response = array('prvkey' => '', 'pubkey' => '');
+
+ openssl_pkey_export($result, $response['prvkey']);
+
+ // Get public key
+ $pkey = openssl_pkey_get_details($result);
+ $response['pubkey'] = $pkey["key"];
+
+ return $response;
+
+}
+