aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--database.sql10
-rw-r--r--include/Contact.php4
-rw-r--r--include/identity.php20
-rw-r--r--include/zot.php2
-rw-r--r--mod/zfinger.php8
-rw-r--r--mod/zperms.php8
6 files changed, 30 insertions, 22 deletions
diff --git a/database.sql b/database.sql
index 67a789aff..0488a9243 100644
--- a/database.sql
+++ b/database.sql
@@ -100,7 +100,9 @@ CREATE TABLE IF NOT EXISTS `channel` (
`channel_primary` tinyint(1) unsigned NOT NULL DEFAULT '0',
`channel_name` char(255) NOT NULL DEFAULT '',
`channel_address` char(255) NOT NULL DEFAULT '',
- `channel_global_id` char(255) NOT NULL DEFAULT '',
+ `channel_guid` char(255) NOT NULL DEFAULT '',
+ `channel_guid_sig` char(255) NOT NULL DEFAULT '',
+ `channel_hash` char(255) NOT NULL DEFAULT '',
`channel_timezone` char(128) NOT NULL DEFAULT 'UTC',
`channel_location` char(255) NOT NULL DEFAULT '',
`channel_theme` char(255) NOT NULL DEFAULT '',
@@ -133,7 +135,6 @@ CREATE TABLE IF NOT EXISTS `channel` (
KEY `channel_primary` (`channel_primary`),
KEY `channel_name` (`channel_name`),
KEY `channel_address` (`channel_address`),
- KEY `channel_global_id` (`channel_global_id`),
KEY `channel_timezone` (`channel_timezone`),
KEY `channel_location` (`channel_location`),
KEY `channel_theme` (`channel_theme`),
@@ -152,7 +153,10 @@ CREATE TABLE IF NOT EXISTS `channel` (
KEY `channel_w_comment` (`channel_w_comment`),
KEY `channel_w_mail` (`channel_w_mail`),
KEY `channel_w_photos` (`channel_w_photos`),
- KEY `channel_w_chat` (`channel_w_chat`)
+ KEY `channel_w_chat` (`channel_w_chat`),
+ KEY `channel_guid` (`channel_guid`),
+ KEY `channel_guid_sig` (`channel_guid_sig`),
+ KEY `channel_hash` (`channel_hash`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `clients` (
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']),
diff --git a/mod/zfinger.php b/mod/zfinger.php
index 95c17ecd8..e76255032 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -13,7 +13,7 @@ function zfinger_init(&$a) {
$r = null;
if(strlen($zguid)) {
- $r = q("select * from channel where channel_global_id = '%s' limit 1",
+ $r = q("select * from channel where channel_guid = '%s' limit 1",
dbesc($zguid)
);
}
@@ -49,8 +49,8 @@ function zfinger_init(&$a) {
// Communication details
- $ret['guid'] = $e['channel_global_id'];
- $ret['guid_sig'] = base64url_encode(rsa_sign($e['channel_global_id'],$e['channel_prvkey']));
+ $ret['guid'] = $e['channel_guid'];
+ $ret['guid_sig'] = base64url_encode(rsa_sign($e['channel_guid'],$e['channel_prvkey']));
$ret['key'] = $e['channel_pubkey'];
$ret['name'] = $e['channel_name'];
$ret['address'] = $e['channel_address'];
@@ -60,7 +60,7 @@ function zfinger_init(&$a) {
// array of (verified) hubs this channel uses
$ret['hubs'] = array();
- $x = zot_get_hubloc(array($e['channel_global_id']));
+ $x = zot_get_hubloc(array($e['channel_guid']));
if($x && count($x)) {
foreach($x as $hub) {
if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_UNVERIFIED)) {
diff --git a/mod/zperms.php b/mod/zperms.php
index de1d4dd6d..6a7097cd6 100644
--- a/mod/zperms.php
+++ b/mod/zperms.php
@@ -16,7 +16,7 @@ function zperms_init(&$a) {
$r = null;
if(strlen($zguid)) {
- $r = q("select * from channel where channel_global_id = '%s' limit 1",
+ $r = q("select * from channel where channel_guid = '%s' limit 1",
dbesc($zguid)
);
}
@@ -49,8 +49,8 @@ function zperms_init(&$a) {
$ret['success'] = true;
- $ret['guid'] = $e['channel_global_id'];
- $ret['guid_sig'] = base64url_encode(rsa_sign($e['channel_global_id'],$e['channel_prvkey']));
+ $ret['guid'] = $e['channel_guid'];
+ $ret['guid_sig'] = base64url_encode(rsa_sign($e['channel_guid'],$e['channel_prvkey']));
$ret['key'] = $e['channel_pubkey'];
$ret['name'] = $e['channel_name'];
$ret['address'] = $e['channel_address'];
@@ -63,7 +63,7 @@ function zperms_init(&$a) {
// array of (verified) hubs this channel uses
$ret['hubs'] = array();
- $x = zot_get_hubloc(array($e['channel_global_id']));
+ $x = zot_get_hubloc(array($e['channel_guid']));
if($x && count($x)) {
foreach($x as $hub) {
if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_UNVERIFIED)) {