diff options
author | Joe Crayne <joe@jerkface.net> | 2019-11-14 19:04:32 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-11-14 19:04:32 -0500 |
commit | 713295a4ac808cc4bb1eb1f7be78d79d70dc6cd1 (patch) | |
tree | 1c58ede41f76f295a42b6da431443bfb36e39e61 /Data/OpenPGP/Util/Cv25519.hs | |
parent | 6252bdbd0531feaa6ac9e881dffe5c92b8b40197 (diff) |
Enable generating cv25519 keys.
Diffstat (limited to 'Data/OpenPGP/Util/Cv25519.hs')
-rw-r--r-- | Data/OpenPGP/Util/Cv25519.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Data/OpenPGP/Util/Cv25519.hs b/Data/OpenPGP/Util/Cv25519.hs index 4900b2f..d5ac641 100644 --- a/Data/OpenPGP/Util/Cv25519.hs +++ b/Data/OpenPGP/Util/Cv25519.hs | |||
@@ -26,7 +26,7 @@ import qualified Crypto.PubKey.Curve25519 as Cv25519 | |||
26 | import Crypto.Error | 26 | import Crypto.Error |
27 | import Crypto.Cipher.AES | 27 | import Crypto.Cipher.AES |
28 | import Crypto.Cipher.Types | 28 | import Crypto.Cipher.Types |
29 | import Data.OpenPGP.Util.DecryptSecretKey -- (withS2K, simpleUnCFB, Enciphered(..)) | 29 | import Data.OpenPGP.Util.Decrypt -- (withS2K, simpleUnCFB, Enciphered(..)) |
30 | 30 | ||
31 | import Crypto.JOSE.AESKW | 31 | import Crypto.JOSE.AESKW |
32 | 32 | ||
@@ -229,3 +229,15 @@ decryptMessage ecdhkey asym encdta = do | |||
229 | b1 = BL.drop (2 + fromIntegral blksize) b0 | 229 | b1 = BL.drop (2 + fromIntegral blksize) b0 |
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 | |||
233 | importSecretCv25519 :: Cv25519.SecretKey -> [(Char,MPI)] | ||
234 | importSecretCv25519 k = | ||
235 | [ ('c', MPI oid_cv25519) | ||
236 | , ('l', MPI 128) | ||
237 | , ('n', MPI pub) | ||
238 | , ('f', MPI 0x40) | ||
239 | , ('d', MPI sec) | ||
240 | ] | ||
241 | where | ||
242 | pub = getBigNum $ BA.convert $ Cv25519.toPublic k | ||
243 | sec = getBigNumLE $ BA.convert k | ||