diff options
author | Joe Crayne <joe@jerkface.net> | 2019-11-15 16:27:28 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-11-15 16:27:28 -0500 |
commit | 02680b1ed3b37c0cc16e04e51e613d53ff9dbab8 (patch) | |
tree | e88364cb3813dc0d93d5ab2311e533e5983dfe62 | |
parent | 387491e6517fe41bd242b294ba1fe52881cac6b2 (diff) |
cv25519: Fixed missing algorithm preferences.
-rw-r--r-- | Data/OpenPGP/Util/Cv25519.hs | 8 | ||||
-rw-r--r-- | Data/OpenPGP/Util/Gen.hs | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/Data/OpenPGP/Util/Cv25519.hs b/Data/OpenPGP/Util/Cv25519.hs index d5ac641..abf1ba6 100644 --- a/Data/OpenPGP/Util/Cv25519.hs +++ b/Data/OpenPGP/Util/Cv25519.hs | |||
@@ -230,13 +230,17 @@ decryptMessage ecdhkey asym encdta = do | |||
230 | (_,_, Message ps) <- either (const Nothing) Just $ decodeOrFail b1 | 230 | (_,_, Message ps) <- either (const Nothing) Just $ decodeOrFail b1 |
231 | return ps | 231 | return ps |
232 | 232 | ||
233 | importSecretCv25519 :: Cv25519.SecretKey -> [(Char,MPI)] | 233 | encodeAlgorithms :: OpenPGP.HashAlgorithm -> OpenPGP.SymmetricAlgorithm -> Integer |
234 | importSecretCv25519 k = | 234 | encodeAlgorithms hsh sym = fromIntegral $ 0x03010000 .|. (fromEnum hsh `shiftR` 8) .|. fromEnum sym |
235 | |||
236 | importSecretCv25519 :: OpenPGP.HashAlgorithm -> OpenPGP.SymmetricAlgorithm -> Cv25519.SecretKey -> [(Char,MPI)] | ||
237 | importSecretCv25519 hsh sym k = | ||
235 | [ ('c', MPI oid_cv25519) | 238 | [ ('c', MPI oid_cv25519) |
236 | , ('l', MPI 128) | 239 | , ('l', MPI 128) |
237 | , ('n', MPI pub) | 240 | , ('n', MPI pub) |
238 | , ('f', MPI 0x40) | 241 | , ('f', MPI 0x40) |
239 | , ('d', MPI sec) | 242 | , ('d', MPI sec) |
243 | , ('e', MPI $ encodeAlgorithms hsh sym) | ||
240 | ] | 244 | ] |
241 | where | 245 | where |
242 | pub = getBigNum $ BA.convert $ Cv25519.toPublic k | 246 | pub = getBigNum $ BA.convert $ Cv25519.toPublic k |
diff --git a/Data/OpenPGP/Util/Gen.hs b/Data/OpenPGP/Util/Gen.hs index babd12d..713e909 100644 --- a/Data/OpenPGP/Util/Gen.hs +++ b/Data/OpenPGP/Util/Gen.hs | |||
@@ -127,7 +127,7 @@ generateKey' (GenEd25519 {}) g = withDRG g $ do | |||
127 | return $ importSecretEd25519 k | 127 | return $ importSecretEd25519 k |
128 | generateKey' (GenCv25519 {}) g = withDRG g $ do | 128 | generateKey' (GenCv25519 {}) g = withDRG g $ do |
129 | k <- Cv25519.generateSecretKey | 129 | k <- Cv25519.generateSecretKey |
130 | return $ importSecretCv25519 k | 130 | return $ importSecretCv25519 SHA512 AES128 k |
131 | 131 | ||
132 | 132 | ||
133 | #endif | 133 | #endif |