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
f9c1205f
Commit
f9c1205f
authored
May 12, 2023
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
add storage index derivation
parent
92e46194
No related branches found
No related tags found
1 merge request
!5
Add a Keys module with types and derivation functions
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Tahoe/SDMF/Internal/Keys.hs
+6
-0
6 additions, 0 deletions
src/Tahoe/SDMF/Internal/Keys.hs
src/Tahoe/SDMF/Keys.hs
+2
-0
2 additions, 0 deletions
src/Tahoe/SDMF/Keys.hs
test/Spec.hs
+7
-1
7 additions, 1 deletion
test/Spec.hs
test/expected_values.py
+7
-1
7 additions, 1 deletion
test/expected_values.py
with
22 additions
and
2 deletions
src/Tahoe/SDMF/Internal/Keys.hs
+
6
−
0
View file @
f9c1205f
...
...
@@ -97,9 +97,15 @@ deriveDataKey (SDMF_IV iv) r =
sbs
=
B
.
take
keyLength
.
taggedPairHash
keyLength
mutableDataKeyTag
(
B
.
pack
.
ByteArray
.
unpack
$
iv
)
.
ByteArray
.
convert
.
readKeyBytes
$
r
key
=
maybeCryptoError
.
cipherInit
$
sbs
-- | Compute the storage index for a given read key for an SDMF share.
mutableDataKeyTag
::
B
.
ByteString
mutableDataKeyTag
=
"allmydata_mutable_readkey_to_datakey_v1"
deriveStorageIndex
::
Read
->
StorageIndex
deriveStorageIndex
r
=
StorageIndex
si
where
si
=
taggedHash
keyLength
mutableStorageIndexTag
.
ByteArray
.
convert
.
readKeyBytes
$
r
mutableStorageIndexTag
::
B
.
ByteString
mutableStorageIndexTag
=
"allmydata_mutable_readkey_to_storage_index_v1"
...
...
This diff is collapsed.
Click to expand it.
src/Tahoe/SDMF/Keys.hs
+
2
−
0
View file @
f9c1205f
...
...
@@ -6,9 +6,11 @@ import Tahoe.SDMF.Internal.Keys (
Read
(
..
),
SDMF_IV
(
..
),
Signature
(
..
),
StorageIndex
(
..
),
Write
(
..
),
deriveDataKey
,
deriveReadKey
,
deriveStorageIndex
,
deriveWriteKey
,
toPublicKey
,
)
This diff is collapsed.
Click to expand it.
test/Spec.hs
+
7
−
1
View file @
f9c1205f
...
...
@@ -84,12 +84,14 @@ tests =
expectedWriteKey
=
(
"v7iymuxkc5yv2fomi3xwbjdd4e"
::
T
.
Text
)
expectedReadKey
=
(
"6ir6husgx6ubro3tbimmzskqri"
::
T
.
Text
)
expectedDataKey
=
(
"bbj67exlrkfcaqutwlgwvukbfe"
::
T
.
Text
)
expectedStorageIndex
=
(
"cmkuloz2t6fhsh7npxxteba6sq"
::
T
.
Text
)
-- Derive all the keys.
(
Just
iv
)
=
Keys
.
SDMF_IV
<$>
makeIV
(
B
.
replicate
16
0x42
)
(
Just
w
@
(
Keys
.
Write
_
derivedWriteKey
))
=
Keys
.
deriveWriteKey
sigKey
(
Just
r
@
(
Keys
.
Read
_
derivedReadKey
))
=
Keys
.
deriveReadKey
w
(
Just
d
@
(
Keys
.
Data
_
derivedDataKey
))
=
Keys
.
deriveDataKey
iv
r
(
Just
(
Keys
.
Data
_
derivedDataKey
))
=
Keys
.
deriveDataKey
iv
r
(
Keys
.
StorageIndex
derivedStorageIndex
)
=
Keys
.
deriveStorageIndex
r
-- A helper to format a key as text for convenient
-- comparison to expected value.
...
...
@@ -112,6 +114,10 @@ tests =
"expected datakey /= derived datakey"
expectedDataKey
(
fmtKey
derivedDataKey
)
assertEqual
"expected storage index /= derived storage index"
expectedStorageIndex
(
T
.
toLower
.
encodeBase32Unpadded
$
derivedStorageIndex
)
,
testProperty
"Share round-trips through bytes"
$
property
$
do
share
<-
forAll
shares
...
...
This diff is collapsed.
Click to expand it.
test/expected_values.py
+
7
−
1
View file @
f9c1205f
...
...
@@ -4,7 +4,11 @@
from
allmydata.crypto
import
rsa
from
allmydata.mutable.common
import
derive_mutable_keys
from
allmydata.util
import
base32
from
allmydata.util.hashutil
import
ssk_readkey_hash
,
ssk_readkey_data_hash
from
allmydata.util.hashutil
import
(
ssk_readkey_hash
,
ssk_readkey_data_hash
,
ssk_storage_index_hash
,
)
# Arbitrarily select an IV.
iv
=
b
"
\x42
"
*
16
...
...
@@ -15,11 +19,13 @@ with open("data/rsa-privkey-0.der", "rb") as f:
writekey
,
encprivkey
,
fingerprint
=
derive_mutable_keys
((
pub
,
priv
))
readkey
=
ssk_readkey_hash
(
writekey
)
datakey
=
ssk_readkey_data_hash
(
iv
,
readkey
)
storage_index
=
ssk_storage_index_hash
(
readkey
)
print
(
"
SDMF
"
)
print
(
"
writekey:
"
,
base32
.
b2a
(
writekey
))
print
(
"
readkey:
"
,
base32
.
b2a
(
readkey
))
print
(
"
datakey:
"
,
base32
.
b2a
(
datakey
))
print
(
"
storage index:
"
,
base32
.
b2a
(
storage_index
))
print
(
"
encrypted private key:
"
,
base32
.
b2a
(
encprivkey
))
print
(
"
signature key hash:
"
,
base32
.
b2a
(
fingerprint
))
...
...
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