From 224a8b45e09c70760e2be82aac3126fd3554cdbc Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Fri, 12 May 2023 15:34:56 -0400 Subject: [PATCH] add some types --- src/Tahoe/SDMF.hs | 8 ++++++-- src/Tahoe/SDMF/Internal/Capability.hs | 19 +++++++++++++++++++ src/Tahoe/SDMF/Internal/Keys.hs | 5 +++++ tahoe-ssk.cabal | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/Tahoe/SDMF/Internal/Capability.hs diff --git a/src/Tahoe/SDMF.hs b/src/Tahoe/SDMF.hs index 0aaf41a..b398639 100644 --- a/src/Tahoe/SDMF.hs +++ b/src/Tahoe/SDMF.hs @@ -1,4 +1,8 @@ -- | Expose the library's public interface. -module Tahoe.SDMF (Share (..)) where +module Tahoe.SDMF ( + module Tahoe.SDMF.Internal.Share, + module Tahoe.SDMF.Internal.Capability, +) where -import Tahoe.SDMF.Internal.Share +import Tahoe.SDMF.Internal.Capability (Reader (..), Writer (..)) +import Tahoe.SDMF.Internal.Share (Share (..)) diff --git a/src/Tahoe/SDMF/Internal/Capability.hs b/src/Tahoe/SDMF/Internal/Capability.hs new file mode 100644 index 0000000..52201b4 --- /dev/null +++ b/src/Tahoe/SDMF/Internal/Capability.hs @@ -0,0 +1,19 @@ +-- | Structured representations of SDMF capabilities. +module Tahoe.SDMF.Internal.Capability where + +import Prelude hiding (Read) + +import qualified Data.ByteString as B +import Tahoe.SDMF.Internal.Keys (Read, Write) + +data Reader = Reader + { readerReadKey :: Read + , readerVerificationKeyHash :: B.ByteString + } + deriving (Show) + +data Writer = Writer + { writerWriteKey :: Write + , writerReader :: Reader + } + deriving (Show) diff --git a/src/Tahoe/SDMF/Internal/Keys.hs b/src/Tahoe/SDMF/Internal/Keys.hs index e40d6fb..29f38c6 100644 --- a/src/Tahoe/SDMF/Internal/Keys.hs +++ b/src/Tahoe/SDMF/Internal/Keys.hs @@ -34,10 +34,15 @@ newtype Signature = Signature {unSignature :: RSA.PrivateKey} deriving newtype (Eq, Show) data Write = Write {unWrite :: AES128, writeKeyBytes :: ByteArray.ScrubbedBytes} + instance Show Write where show (Write _ bs) = T.unpack $ T.concat ["<WriteKey ", encodeBase32Unpadded (ByteArray.convert bs), ">"] data Read = Read {unRead :: AES128, readKeyBytes :: ByteArray.ScrubbedBytes} + +instance Show Read where + show (Read _ bs) = T.unpack $ T.concat ["<ReadKey ", encodeBase32Unpadded (ByteArray.convert bs), ">"] + newtype StorageIndex = StorageIndex {unStorageIndex :: B.ByteString} newtype WriteEnablerMaster = WriteEnablerMaster ByteArray.ScrubbedBytes diff --git a/tahoe-ssk.cabal b/tahoe-ssk.cabal index d7e3e7b..a87dac7 100644 --- a/tahoe-ssk.cabal +++ b/tahoe-ssk.cabal @@ -64,6 +64,7 @@ library hs-source-dirs: src exposed-modules: Tahoe.SDMF + Tahoe.SDMF.Internal.Capability Tahoe.SDMF.Internal.Keys Tahoe.SDMF.Internal.Share Tahoe.SDMF.Keys -- GitLab