diff options
author | friendica <info@friendica.com> | 2012-10-04 03:13:57 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-10-04 03:13:57 -0700 |
commit | ff43d62e445422a40271855dcd9933499da501fa (patch) | |
tree | 2a44942f74e86f1a0f1ad240dc040689a3a776d6 /include | |
parent | e124c9fa5ca046d48eb927fe80706cf6d42f6bff (diff) | |
download | volse-hubzilla-ff43d62e445422a40271855dcd9933499da501fa.tar.gz volse-hubzilla-ff43d62e445422a40271855dcd9933499da501fa.tar.bz2 volse-hubzilla-ff43d62e445422a40271855dcd9933499da501fa.zip |
add hash to channel structure for consistency/redundancy
Diffstat (limited to 'include')
-rw-r--r-- | include/Contact.php | 4 | ||||
-rw-r--r-- | include/identity.php | 20 | ||||
-rw-r--r-- | include/zot.php | 2 |
3 files changed, 15 insertions, 11 deletions
diff --git a/include/Contact.php b/include/Contact.php index 38c3c3203..9a6d6a973 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -25,12 +25,12 @@ function map_perms($channel,$zguid,$zsig) { $is_contact = true; $contact = $r[0]; } - $r = q("select * from channel where channel_global_id = '%s'", + $r = q("select * from channel where channel_guid = '%s'", dbesc($zguid) ); if($r && count($r)) { foreach($r as $rr) { - if(base64url_encode(rsa_sign($rr['channel_global_id'],$rr['channel_prvkey'])) === $zsig) { + if(base64url_encode(rsa_sign($rr['channel_guid'],$rr['channel_prvkey'])) === $zsig) { $is_site = true; break; } diff --git a/include/identity.php b/include/identity.php index 1c552a21a..23ceb74ae 100644 --- a/include/identity.php +++ b/include/identity.php @@ -51,25 +51,31 @@ function create_identity($arr) { $guid = zot_new_uid($nick); $key = new_keypair(4096); + + $sig = base64url_encode(rsa_sign($guid,$key['prvkey'])); + $hash = base64url_encode(hash('whirlpool',$guid . $sig,true)); + $primary = true; $r = q("insert into channel ( channel_account_id, channel_primary, - channel_name, channel_address, channel_global_id, channel_prvkey, - channel_pubkey, channel_pageflags ) - values ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d ) ", + channel_name, channel_address, channel_guid, channel_guid_sig, + channel_hash, channel_prvkey, channel_pubkey, channel_pageflags ) + values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d ) ", intval($arr['account_id']), intval($primary), dbesc($name), dbesc($nick), dbesc($guid), + dbesc($sig), + dbesc($hash), dbesc($key['prvkey']), dbesc($key['pubkey']), intval(PAGE_NORMAL) ); $r = q("select * from channel where channel_account_id = %d - and channel_global_id = '%s' limit 1", + and channel_guid = '%s' limit 1", intval($arr['account_id']), dbesc($guid) ); @@ -83,15 +89,13 @@ function create_identity($arr) { set_default_login_identity($arr['account_id'],$ret['channel']['channel_id'],false); - $sig = base64url_encode(rsa_sign($ret['channel']['channel_global_id'],$ret['channel']['channel_prvkey'])); - $hash = base64url_encode(hash('whirlpool',$ret['channel']['channel_global_id'] . $sig,true)); // Create a verified hub location pointing to this site. $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_callback, hubloc_sitekey ) values ( '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' )", - dbesc($ret['channel']['channel_global_id']), + dbesc($guid), dbesc($sig), dbesc($hash), intval(($primary) ? HUBLOC_FLAGS_PRIMARY : 0), @@ -108,7 +112,7 @@ function create_identity($arr) { $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_photo, xchan_addr, xchan_profile, xchan_name ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", dbesc($hash), - dbesc($ret['channel']['channel_global_id']), + dbesc($ret['channel']['channel_guid']), dbesc($sig), dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"), dbesc($ret['channel']['channel_address'] . '@' . $a->get_hostname()), diff --git a/include/zot.php b/include/zot.php index 8f76e78b1..e041e273e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -62,7 +62,7 @@ function zot_verify(&$item,$identity) { function zot_notify($channel,$url) { $x = z_post_url($url, array( 'type' => 'notify', - 'guid' => $channel['channel_global_id'], + 'guid' => $channel['channel_guid'], 'guid_sig' => base64url_encode($guid,$channel['prvkey']), 'hub' => z_root(), 'hub_sig' => base64url_encode(z_root,$channel['prvkey']), |