Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tahoe-ssk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
PrivateStorage
tahoe-ssk
Commits
e020cea6
Commit
e020cea6
authored
2 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
haddocks and other minor tweaks
parent
6727e5f5
No related branches found
No related tags found
1 merge request
!8
Parse and serialize SDMF capabilities
Pipeline
#4675
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Tahoe/SDMF/Internal/Capability.hs
+26
-4
26 additions, 4 deletions
src/Tahoe/SDMF/Internal/Capability.hs
with
26 additions
and
4 deletions
src/Tahoe/SDMF/Internal/Capability.hs
+
26
−
4
View file @
e020cea6
...
...
@@ -26,9 +26,23 @@ import Tahoe.SDMF.Internal.Keys (
shorten
,
showBase32
,
)
import
Text.Megaparsec
(
ErrorFancy
(
ErrorFail
),
Parsec
,
count
,
failure
,
fancyFailure
,
oneOf
)
import
Text.Megaparsec
(
ErrorFancy
(
ErrorFail
),
Parsec
,
count
,
failure
,
fancyFailure
,
oneOf
,
)
import
Text.Megaparsec.Char
(
char
,
string
)
-- | Any kind of SDMF capability.
data
SDMF
=
SDMFVerifier
Verifier
|
SDMFReader
Reader
|
SDMFWriter
Writer
deriving
(
Eq
,
Show
)
-- | A verify capability for an SDMF object.
data
Verifier
=
Verifier
{
verifierStorageIndex
::
StorageIndex
...
...
@@ -57,13 +71,12 @@ deriveReader w fingerprint = Reader <$> readKey <*> verifier
readKey
=
deriveReadKey
w
verifier
=
flip
deriveVerifier
fingerprint
<$>
readKey
-- | Diminish a read key to a verify key and wrap it in a verifier capability.
deriveVerifier
::
Read
->
Digest
SHA256
->
Verifier
deriveVerifier
readKey
=
Verifier
storageIndex
where
storageIndex
=
deriveStorageIndex
readKey
data
SDMF
=
SDMFVerifier
Verifier
|
SDMFReader
Reader
|
SDMFWriter
Writer
deriving
(
Eq
,
Show
)
type
Parser
=
Parsec
Void
T
.
Text
-- | A parser for any kind of SDMF capability type.
...
...
@@ -90,7 +103,16 @@ pWriter = do
Nothing
->
failure
Nothing
mempty
Just
writer
->
pure
writer
pPieces
::
T
.
Text
->
(
B
.
ByteString
->
a
)
->
Parser
(
a
,
Digest
SHA256
)
{- | A parser for two base32-encoded bytestrings with some given prefix,
formatted as they are in the string representation of an SDMF capability.
-}
pPieces
::
-- | The prefix to expect.
T
.
Text
->
-- | A function to convert the first bytestring to a result value.
(
B
.
ByteString
->
a
)
->
-- | A parser for the two pieces of the SDMF capability.
Parser
(
a
,
Digest
SHA256
)
pPieces
prefix
convertSecret
=
do
void
$
string
prefix
secret
<-
convertSecret
<$>
pBase32
rfc3548Alphabet
128
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment