From 9e4f996c68c3901bab4a5e1e70638c2531a85994 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 1 Jan 2013 13:08:12 -0500 Subject: Proper S2K type S2K is a seperate concept and is used in both secret key packets and SymmetricallyEncryptedSessionKey packets. It should have its own parser and thus its own type. This also cleans up the SecretKeyPacket record considerably (the many Maybe fields were a smell). SecretKeyPacket.s2k should be set to (Just $ SimpleS2K MD5) in fallback cases. symmetric_algorithm should be set to Unencrypted when s2k_useage is 0. s2k_useage itself is only needed for the different between 255 and 254 (different checksum). Round trip encode/decode tests for S2K work. --- tests/suite.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests') diff --git a/tests/suite.hs b/tests/suite.hs index 3094214..feb5fe6 100644 --- a/tests/suite.hs +++ b/tests/suite.hs @@ -44,6 +44,10 @@ prop_MPI_serialization_loop :: OpenPGP.MPI -> Bool prop_MPI_serialization_loop mpi = mpi == decode' (encode mpi) +prop_S2K_serialization_loop :: OpenPGP.S2K -> Bool +prop_S2K_serialization_loop s2k = + s2k == decode' (encode s2k) + prop_SignatureSubpacket_serialization_loop :: OpenPGP.SignatureSubpacket -> Bool prop_SignatureSubpacket_serialization_loop packet = packet == decode' (encode packet) @@ -141,6 +145,7 @@ tests = testCase "uncompressed-ops-dsa-sha384.txt.gpg" (testSerialization "uncompressed-ops-dsa-sha384.txt.gpg"), testCase "uncompressed-ops-rsa.gpg" (testSerialization "uncompressed-ops-rsa.gpg"), testProperty "MPI encode/decode" prop_MPI_serialization_loop, + testProperty "S2K encode/decode" prop_S2K_serialization_loop, testProperty "SignatureSubpacket encode/decode" prop_SignatureSubpacket_serialization_loop ], testGroup "S2K count" [ -- cgit v1.2.3