mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-26 15:08:28 +00:00
Test sig upload
This commit is contained in:
parent
85342a1d4f
commit
f5756f1c59
1 changed files with 68 additions and 1 deletions
|
@ -218,13 +218,32 @@ func (a *KeyInternalAPI) PerformUploadDeviceSignatures(ctx context.Context, req
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *KeyInternalAPI) processSelfSignatures(
|
func (a *KeyInternalAPI) processSelfSignatures(
|
||||||
ctx context.Context, userID string,
|
ctx context.Context, _ string,
|
||||||
signatures map[string]map[gomatrixserverlib.KeyID]gomatrixserverlib.CrossSigningForKeyOrDevice,
|
signatures map[string]map[gomatrixserverlib.KeyID]gomatrixserverlib.CrossSigningForKeyOrDevice,
|
||||||
) error {
|
) error {
|
||||||
// Here we will process:
|
// Here we will process:
|
||||||
// * The user signing their own devices using their self-signing key
|
// * The user signing their own devices using their self-signing key
|
||||||
// * The user signing their master key using one of their devices
|
// * The user signing their master key using one of their devices
|
||||||
|
|
||||||
|
for targetUserID, forTargetUserID := range signatures {
|
||||||
|
for targetKeyID, signature := range forTargetUserID {
|
||||||
|
switch sig := signature.CrossSigningBody.(type) {
|
||||||
|
case *gomatrixserverlib.CrossSigningForKey:
|
||||||
|
for originUserID, forOriginUserID := range sig.Signatures {
|
||||||
|
for originKeyID, originSig := range forOriginUserID {
|
||||||
|
if err := a.DB.StoreCrossSigningSigsForTarget(
|
||||||
|
ctx, originUserID, originKeyID, targetUserID, targetKeyID, originSig,
|
||||||
|
); err != nil {
|
||||||
|
return fmt.Errorf("a.DB.StoreCrossSigningKeysForTarget: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case *gomatrixserverlib.CrossSigningForDevice:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +257,54 @@ func (a *KeyInternalAPI) processOtherSignatures(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func (a *KeyInternalAPI) crossSigningKeysForUser(
|
||||||
|
ctx context.Context, userID string,
|
||||||
|
) (api.CrossSigningKeyMap, error) {
|
||||||
|
keymap, err := a.DB.CrossSigningKeysForUser(ctx, userID)
|
||||||
|
if err != nil && err != sql.ErrNoRows {
|
||||||
|
return nil, fmt.Errorf("a.DB.CrossSigningKeysForUser: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(keymap) > 0 {
|
||||||
|
return keymap, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
req := &api.QueryKeysRequest{
|
||||||
|
UserToDevices: map[string][]string{
|
||||||
|
userID: {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
res := &api.QueryKeysResponse{}
|
||||||
|
a.QueryKeys(ctx, req, res)
|
||||||
|
if res.Error != nil {
|
||||||
|
return nil, fmt.Errorf("a.QueryKeys: %s", res.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
result := api.CrossSigningKeyMap{}
|
||||||
|
if masterKey, ok := res.MasterKeys[userID]; ok {
|
||||||
|
if err := sanityCheckKey(masterKey, userID, gomatrixserverlib.CrossSigningKeyPurposeMaster); err != nil {
|
||||||
|
return nil, fmt.Errorf("sanityCheckKey: %w", err)
|
||||||
|
}
|
||||||
|
for _, key := range masterKey.Keys {
|
||||||
|
result[gomatrixserverlib.CrossSigningKeyPurposeMaster] = key
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if selfSigningKey, ok := res.SelfSigningKeys[userID]; ok {
|
||||||
|
if err := sanityCheckKey(selfSigningKey, userID, gomatrixserverlib.CrossSigningKeyPurposeSelfSigning); err != nil {
|
||||||
|
return nil, fmt.Errorf("sanityCheckKey: %w", err)
|
||||||
|
}
|
||||||
|
for _, key := range selfSigningKey.Keys {
|
||||||
|
result[gomatrixserverlib.CrossSigningKeyPurposeSelfSigning] = key
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (a *KeyInternalAPI) crossSigningKeysFromDatabase(
|
func (a *KeyInternalAPI) crossSigningKeysFromDatabase(
|
||||||
ctx context.Context, req *api.QueryKeysRequest, res *api.QueryKeysResponse,
|
ctx context.Context, req *api.QueryKeysRequest, res *api.QueryKeysResponse,
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Reference in a new issue