summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/DeWeave/Collection.pm1
-rw-r--r--lib/DeWeave/Crypto.pm21
-rw-r--r--lib/DeWeave/Crypto/KeyBundle.pm15
-rw-r--r--lib/DeWeave/Storage.pm2
-rw-r--r--lib/DeWeave/WBO.pm3
5 files changed, 9 insertions, 33 deletions
diff --git a/lib/DeWeave/Collection.pm b/lib/DeWeave/Collection.pm
index 803a8cc..42669ba 100644
--- a/lib/DeWeave/Collection.pm
+++ b/lib/DeWeave/Collection.pm
@@ -17,7 +17,6 @@ sub from_json {
my $j = JSON::Any->new;
my $args = $j->decode($json);
- use Data::Dump 'pp';warn pp $args;
my @items = map {
DeWeave::EDO->new({%$_,__crypt=>$crypt})
diff --git a/lib/DeWeave/Crypto.pm b/lib/DeWeave/Crypto.pm
index e21e141..dc657b6 100644
--- a/lib/DeWeave/Crypto.pm
+++ b/lib/DeWeave/Crypto.pm
@@ -29,8 +29,8 @@ sub _byte_sync_key {
my $key = $self->sync_key;
$key =~ y{89}{LO};
$key =~ s{-}{}g;
- $key = MIME::Base32::decode($key);
- return substr($key,0,16);
+ my $byte_key = MIME::Base32::decode(uc($key));
+ return substr($byte_key,0,16);
}
has _hmac_input => (
@@ -51,8 +51,6 @@ sub _build__encryption_key {
my $secret = $self->_hmac_input
. $self->storage->username . "\x01";
-warn "enc key: ",pp($secret,$self->_byte_sync_key,length($self->_byte_sync_key));
-
return Digest::SHA::hmac_sha256($secret, $self->_byte_sync_key);
}
@@ -93,16 +91,11 @@ sub _build__keys {
my $payload = $j->decode($keys_struct->{payload});
-warn "payload: ", pp $payload;
-warn "key: ",pp $self->_encryption_key, length($self->_encryption_key);
-
my $struct = $j->decode($self->decrypt({
%$payload,
key => $self->_encryption_key,
}));
-warn "keys: ",pp $struct;
-
my $keys = {
default => $struct->{default},
%{$struct->{collections}},
@@ -114,12 +107,14 @@ warn "keys: ",pp $struct;
sub keys_for_collection {
my ($self,$collection) = @_;
+ my $key;
if ($self->_has_collection_keys($collection)) {
- return $self->_get_collection_keys($collection);
+ $key = $self->_get_collection_keys($collection);
}
else {
- return $self->_get_collection_keys('default');
+ $key = $self->_get_collection_keys('default');
}
+ return [ map { MIME::Base64::decode($_) } @$key ];
}
sub decrypt {
@@ -128,9 +123,7 @@ sub decrypt {
my $iv = MIME::Base64::decode($args->{IV});
my $hmac = $args->{hmac};
my $ct = MIME::Base64::decode($args->{ciphertext});
- my $key = $args->{key} || $self->keys_for_collection('default');
-
-warn "Crypto ", pp($iv,$ct, length($ct), $key);
+ my $key = $args->{key} || $self->keys_for_collection('default')->[0];
my $cipher = Crypt::CBC->new(
-key => $key,
diff --git a/lib/DeWeave/Crypto/KeyBundle.pm b/lib/DeWeave/Crypto/KeyBundle.pm
deleted file mode 100644
index aea89ec..0000000
--- a/lib/DeWeave/Crypto/KeyBundle.pm
+++ /dev/null
@@ -1,15 +0,0 @@
-package DeWeave::Crypto::KeyBundle;
-use Moose;
-use namespace::autoclean;
-use MooseX::Types::Moose qw(HashRef Str);
-use MooseX::Types::Structured qw(Tuple);
-
-has _keys => (
- isa => Str,
- init_arg => undef,
- lazy_build => 1,
-);
-
-
-
-1;
diff --git a/lib/DeWeave/Storage.pm b/lib/DeWeave/Storage.pm
index d8e62c9..70a9368 100644
--- a/lib/DeWeave/Storage.pm
+++ b/lib/DeWeave/Storage.pm
@@ -54,7 +54,7 @@ sub get_item {
$self->username,$path;
my $uri = URI->new_abs($relative,$self->server_uri);
$uri->query_param(full => 1);
-warn $uri;
+
my $response = $self->_useragent->get($uri);
if ($response->is_success) {
diff --git a/lib/DeWeave/WBO.pm b/lib/DeWeave/WBO.pm
index bdfb027..8d8a1ba 100644
--- a/lib/DeWeave/WBO.pm
+++ b/lib/DeWeave/WBO.pm
@@ -4,7 +4,6 @@ use namespace::autoclean;
use MooseX::Types::Moose qw(Int Str Num);
use JSON::Any;
use Try::Tiny;
-use Data::Dump 'pp';
has id => (
isa => Str,
@@ -42,7 +41,7 @@ sub from_json {
my $j = JSON::Any->new;
my $args = $j->decode($json);
- use Data::Dump 'pp';warn pp $args;
+
if (defined $args->{payload}) {
$args->{__crypt}=$crypt;
}