diff options
author | Michael <icarus@dabo.de> | 2012-05-26 11:59:19 +0200 |
---|---|---|
committer | Michael <icarus@dabo.de> | 2012-05-26 11:59:19 +0200 |
commit | 7b3c02057db47a627b56bdd79f1055ea7f876617 (patch) | |
tree | 8c9b11fa72e544aea721f385b40bff7254e42ed2 /include/crypto.php | |
parent | 6342b3e0bdd5774857a8fca809994f05e0208d25 (diff) | |
parent | f5290a5a107ef2d6c309c4a3205319c9b0d13994 (diff) | |
download | volse-hubzilla-7b3c02057db47a627b56bdd79f1055ea7f876617.tar.gz volse-hubzilla-7b3c02057db47a627b56bdd79f1055ea7f876617.tar.bz2 volse-hubzilla-7b3c02057db47a627b56bdd79f1055ea7f876617.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; + +} + |