summaryrefslogtreecommitdiffhomepage
path: root/Serialization.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-10 12:16:44 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-10 12:16:44 -0400
commit90b7c385f4e2f293502f9aca38aaa041b7b2f486 (patch)
tree5cc2d68b41406081d9c52271af5852ab148d1ba6 /Serialization.hs
parent730c54a40681776aaaab1b727af42559cf1592fe (diff)
downloadkeysafe-90b7c385f4e2f293502f9aca38aaa041b7b2f486.tar.gz
types for new version storage scheme
Diffstat (limited to 'Serialization.hs')
-rw-r--r--Serialization.hs38
1 files changed, 0 insertions, 38 deletions
diff --git a/Serialization.hs b/Serialization.hs
index 172c6f9..6a283ff 100644
--- a/Serialization.hs
+++ b/Serialization.hs
@@ -4,51 +4,13 @@
module Serialization where
import Types
-import Cost
import Raaz.Core.Encode
-import qualified Crypto.Argon2 as Argon2
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as B8
import Data.Monoid
import Data.Word
import Text.Read
-instance Encodable ExpensiveHashTunable where
- toByteString (UseArgon2 o _) = B.intercalate (B.singleton sepChar)
- [ showb (Argon2.hashIterations o)
- , showb (Argon2.hashMemory o)
- , showb (Argon2.hashParallelism o)
- , case Argon2.hashVariant o of
- Argon2.Argon2i -> "argon2i"
- Argon2.Argon2d -> "argon2d"
- ]
- where
- showb = B8.pack . show
- fromByteString b = case B.split sepChar b of
- (i:m:p:v:[]) -> do
- o <- Argon2.HashOptions
- <$> readb i
- <*> readb m
- <*> readb p
- <*> case v of
- "argon2i" -> return Argon2.Argon2i
- "argon2d" -> return Argon2.Argon2d
- _ -> Nothing
- return $ UseArgon2 o unknownCost
- _ -> Nothing
- where
- readb = readMaybe . B8.unpack
-
-instance Encodable EncryptionTunable where
- toByteString UseAES256 = "AES"
- fromByteString "AES" = Just UseAES256
- fromByteString _ = Nothing
-
-instance Encodable DecryptionPuzzleTunable where
- toByteString (KeyBlindingLeftSide _) = ">"
- fromByteString ">" = Just (KeyBlindingLeftSide unknownCost)
- fromByteString _ = Nothing
-
-- TODO
-- | An EncryptedSecretKey is serialized as first a md5sum of the rest
-- of the content, and then a SelfDescription EncryptedSecretKey,