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
GitLab 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
aa097a78
Commit
aa097a78
authored
Jun 1, 2023
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
add a command-line tool for encoding data to SDMF shares
parent
86b76488
No related branches found
No related tags found
1 merge request
!10
expose random IV generation in the public interface
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
encode-ssk/Main.hs
+29
-0
29 additions, 0 deletions
encode-ssk/Main.hs
tahoe-ssk.cabal
+16
-0
16 additions, 0 deletions
tahoe-ssk.cabal
with
45 additions
and
0 deletions
encode-ssk/Main.hs
0 → 100644
+
29
−
0
View file @
aa097a78
module
Main
where
import
qualified
Crypto.PubKey.RSA
as
RSA
import
Data.Binary
(
encode
)
import
Data.ByteString.Base32
(
encodeBase32Unpadded
)
import
qualified
Data.ByteString.Lazy
as
LB
import
qualified
Data.Text
as
T
import
qualified
Data.Text.IO
as
T
import
System.IO
(
stdin
)
import
qualified
Tahoe.SDMF
as
SDMF
import
qualified
Tahoe.SDMF.Keys
as
SDMF.Keys
main
::
IO
()
main
=
do
plaintext
<-
LB
.
hGetContents
stdin
keypair
<-
SDMF
.
Keys
.
KeyPair
.
snd
<$>
RSA
.
generate
(
2048
`
div
`
8
)
e
Just
iv
<-
SDMF
.
randomIV
let
ciphertext
=
SDMF
.
encrypt
keypair
iv
plaintext
(
shares
,
writeCap
)
<-
SDMF
.
encode
keypair
iv
1
3
5
ciphertext
let
shareBytes
=
encode
<$>
shares
let
si
=
SDMF
.
Keys
.
unStorageIndex
.
SDMF
.
verifierStorageIndex
.
SDMF
.
readerVerifier
.
SDMF
.
writerReader
$
writeCap
mapM_
(
uncurry
(
writeShare
si
))
(
zip
[
0
::
Int
..
]
shareBytes
)
T
.
putStrLn
(
SDMF
.
dangerRealShow
(
SDMF
.
SDMFWriter
writeCap
))
where
e
=
0x10001
writeShare
si
shnum
=
LB
.
writeFile
$
(
T
.
unpack
.
T
.
toLower
.
encodeBase32Unpadded
$
si
)
<>
"."
<>
show
shnum
This diff is collapsed.
Click to expand it.
tahoe-ssk.cabal
+
16
−
0
View file @
aa097a78
...
...
@@ -164,3 +164,19 @@ executable make-keypairs
, cryptonite
, tahoe-ssk
, x509
executable encode-ssk
import:
warnings
, language
main-is: Main.hs
hs-source-dirs: encode-ssk
build-depends:
, base
, base32
, binary
, bytestring
, cryptonite
, tahoe-ssk
, text
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