diff options
author | zottel <github@zottel.net> | 2012-05-22 08:46:02 +0200 |
---|---|---|
committer | zottel <github@zottel.net> | 2012-05-22 08:46:02 +0200 |
commit | e9c86c0fd0fb87b49e60669e6d4be810ca426ec4 (patch) | |
tree | cfee80cc9122974a4304591aa7d54ca5fc8a71ea /include/crypto.php | |
parent | 2cd3ec7b983327f8c162845d0f4b8d9753f30e27 (diff) | |
parent | 02502c3a7460a1af3414b65232fd7c672a76d941 (diff) | |
download | volse-hubzilla-e9c86c0fd0fb87b49e60669e6d4be810ca426ec4.tar.gz volse-hubzilla-e9c86c0fd0fb87b49e60669e6d4be810ca426ec4.tar.bz2 volse-hubzilla-e9c86c0fd0fb87b49e60669e6d4be810ca426ec4.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'include/crypto.php')
-rw-r--r-- | include/crypto.php | 36 |
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; + +} + |