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

RS IZ; now signatures work like in real life

parent 406c00ae
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -47,8 +47,11 @@ class Post ...@@ -47,8 +47,11 @@ class Post
key :owner_signature, String key :owner_signature, String
def verify_signature def verify_signature
return false unless owner_signature && person.key_fingerprint return false unless owner_signature && person.key_fingerprint
puts to_xml.to_s
GPGME::verify(owner_signature, {:always_trust => true}){ |signature| puts owner_signature
GPGME::verify(owner_signature, nil, {:armor => true, :always_trust => true}){ |signature|
puts signature
puts signature.inspect
return signature.status == GPGME::GPG_ERR_NO_ERROR && return signature.status == GPGME::GPG_ERR_NO_ERROR &&
#signature.to_s.include?("Good signature from ") && #signature.to_s.include?("Good signature from ") &&
signature.fpr == person.key_fingerprint signature.fpr == person.key_fingerprint
...@@ -60,7 +63,7 @@ class Post ...@@ -60,7 +63,7 @@ class Post
def sign_if_mine def sign_if_mine
if self.person == User.first if self.person == User.first
self.owner_signature = GPGME::sign(to_xml.to_s,nil,{ self.owner_signature = GPGME::sign(to_xml.to_s,nil,{
:armor=> true, :mode => GPGME::SIG_MODE_DETACH}) :armor=> true})
end end
end end
......
<status_message>
<message>jimmy's 1 whales</message>
<_id>4c3b7cf9312f91367f000004</_id>
<person>
<email>bob1@aol.com</email>
<url>http://www.example.com/</url>
<_id>4c3b7c64312f913664000005</_id>
<key_fingerprint>0264242496D4B585297BF236BEEFE6DEBE3407AA</key_fingerprint>
<profile>
<first_name>Bob</first_name>
<last_name>Smith</last_name>
</profile>
</person>
</status_message>
\ No newline at end of file
-----BEGIN PGP SIGNATURE----- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux) Version: GnuPG v1.4.10 (GNU/Linux)
iEYEABECAAYFAkw7p+YACgkQ5hWCpTN+yRIrHgCghpIwNtqODBwaEjL6duFNcTKv iEYEABECAAYFAkw72oUACgkQ5hWCpTN+yRLSuwCgwphc3LWMM0LOZ5wreKjNeaja
+XYAoKWvcAz76dmAvD71QkTue5F67cq8 BCsAoIzYO9AG3fgV0KbtIFAtuwlNiFxt
=jIOx =W2K4
-----END PGP SIGNATURE----- -----END PGP SIGNATURE-----
...@@ -85,7 +85,7 @@ describe 'user encryption' do ...@@ -85,7 +85,7 @@ describe 'user encryption' do
it 'should verify a remote signature' do it 'should verify a remote signature' do
person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr)
message = Factory.create(:status_message, :person => person, message = Factory.create(:status_message, :person => person,
:owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read)
# :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read)
# :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read)
...@@ -95,7 +95,7 @@ describe 'user encryption' do ...@@ -95,7 +95,7 @@ describe 'user encryption' do
it 'should know if the signature is from the wrong person' do it 'should know if the signature is from the wrong person' do
person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr)
message = Factory.create(:status_message, :person => person, message = Factory.create(:status_message, :person => person,
:owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read)
# :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read)
# :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read)
...@@ -104,7 +104,11 @@ describe 'user encryption' do ...@@ -104,7 +104,11 @@ describe 'user encryption' do
end end
it 'should know if the signature is for the wrong text' do it 'should know if the signature is for the wrong text' do
pending person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr)
message = Factory.create(:status_message, :message => 'I love VENISON', :person => person,
:owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read)
message.verify_signature.should be false
end end
end end
end end
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