summaryrefslogtreecommitdiff
path: root/Data/OpenPGP/Util/Cv25519.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Data/OpenPGP/Util/Cv25519.hs')
-rw-r--r--Data/OpenPGP/Util/Cv25519.hs14
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
26import Crypto.Error 26import Crypto.Error
27import Crypto.Cipher.AES 27import Crypto.Cipher.AES
28import Crypto.Cipher.Types 28import Crypto.Cipher.Types
29import Data.OpenPGP.Util.DecryptSecretKey -- (withS2K, simpleUnCFB, Enciphered(..)) 29import Data.OpenPGP.Util.Decrypt -- (withS2K, simpleUnCFB, Enciphered(..))
30 30
31import Crypto.JOSE.AESKW 31import 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
233importSecretCv25519 :: Cv25519.SecretKey -> [(Char,MPI)]
234importSecretCv25519 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