aboutsummaryrefslogtreecommitdiffstats
path: root/include/salmon.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-08-09 18:55:46 -0700
committerFriendika <info@friendika.com>2011-08-09 18:55:46 -0700
commit1bfe1283aa38454369f29883411a6c012c88df59 (patch)
treeb85f93b9d4c6b40bf4678ccd32fea7b9531f27bb /include/salmon.php
parent49be3941828668e762141972afa1324045805f20 (diff)
downloadvolse-hubzilla-1bfe1283aa38454369f29883411a6c012c88df59.tar.gz
volse-hubzilla-1bfe1283aa38454369f29883411a6c012c88df59.tar.bz2
volse-hubzilla-1bfe1283aa38454369f29883411a6c012c88df59.zip
crypto stuff
Diffstat (limited to 'include/salmon.php')
-rw-r--r--include/salmon.php31
1 files changed, 4 insertions, 27 deletions
diff --git a/include/salmon.php b/include/salmon.php
index 3ccae2756..4043b4f1d 100644
--- a/include/salmon.php
+++ b/include/salmon.php
@@ -1,21 +1,7 @@
<?php
-require_once('library/asn1.php');
+require_once('include/crypto.php');
-function salmon_key($pubkey) {
- $lines = explode("\n",$pubkey);
- unset($lines[0]);
- unset($lines[count($lines)]);
- $x = base64_decode(implode('',$lines));
-
- $r = ASN_BASE::parseASNString($x);
-
- $m = $r[0]->asnData[1]->asnData[0]->asnData[0]->asnData;
- $e = $r[0]->asnData[1]->asnData[0]->asnData[1]->asnData;
-
-
- return 'RSA' . '.' . $m . '.' . $e ;
-}
function get_salmon_key($uri,$keyhash) {
@@ -112,24 +98,15 @@ EOT;
$algorithm = 'RSA-SHA256';
$keyhash = base64url_encode(hash('sha256',salmon_key($owner['spubkey'])),true);
- // Setup RSA stuff to PKCS#1 sign the data
-
- require_once('library/phpsec/Crypt/RSA.php');
-
- $rsa = new CRYPT_RSA();
- $rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1;
- $rsa->setHash('sha256');
- $rsa->loadKey($owner['sprvkey']);
-
// precomputed base64url encoding of data_type, encoding, algorithm concatenated with periods
$precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng==';
- $signature = base64url_encode($rsa->sign(str_replace('=','',$data . $precomputed),true));
+ $signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),true),$owner['sprvkey']);
- $signature2 = base64url_encode($rsa->sign($data . $precomputed));
+ $signature2 = base64url_encode(rsa_sign($data . $precomputed),$owner['sprvkey']);
- $signature3 = base64url_encode($rsa->sign($data));
+ $signature3 = base64url_encode(rsa_sign($data),$owner['sprvkey']);
$salmon_tpl = get_markup_template('magicsig.tpl');