Skip to content
Extraits de code Groupes Projets
Valider c7d29b29 rédigé par ilya's avatar ilya
Parcourir les fichiers

the salmon now encrypts the activity, and stores the aes key in the header

parent 6eede48f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -41,7 +41,19 @@ end
module Salmon
class SalmonSlap
attr_accessor :magic_sig, :author, :author_email, :parsed_data, :data_type, :sig
attr_accessor :magic_sig, :author, :author_email, :aes_key, :iv, :parsed_data,
:data_type, :sig
def self.create(user, activity)
salmon = self.new
salmon.author = user.person
aes_key_hash = user.person.gen_aes_key
salmon.aes_key = aes_key_hash['key']
salmon.iv = aes_key_hash['iv']
salmon.magic_sig = MagicSigEnvelope.create(user , user.person.aes_encrypt(activity, aes_key_hash))
salmon
end
def self.parse(xml)
slap = self.new
doc = Nokogiri::XML(xml)
......@@ -65,13 +77,6 @@ module Salmon
slap
end
def self.create(user, activity)
salmon = self.new
salmon.author = user.person
salmon.magic_sig = MagicSigEnvelope.create(user , activity)
salmon
end
def to_xml
xml =<<ENTRY
<?xml version='1.0' encoding='UTF-8'?>
......
......@@ -18,7 +18,17 @@ describe Salmon do
it 'has no parsed_data' do
created_salmon.parsed_data.should be nil
end
it 'sets aes and iv key' do
created_salmon.aes_key.should_not be nil
created_salmon.iv.should_not be nil
end
it 'should make the data in the signature encrypted with that key' do
key_hash = {'key' => created_salmon.aes_key, 'iv' => created_salmon.iv}
decoded_string = Salmon::SalmonSlap.decode64url(created_salmon.magic_sig.data)
user.aes_decrypt(decoded_string, key_hash).to_s.should == post.to_diaspora_xml.to_s
end
end
context 'round trip' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter