Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/connector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,12 @@ func (lc *LineClient) markMissingE2EEKey(ctx context.Context, err error) {
if isTerminalCryptoError(err) || !errors.Is(err, e2ee.ErrMissingOwnPrivateKey) || lc.UserLogin == nil {
return
}
var missingKey *e2ee.MissingOwnKeyError
if errors.As(err, &missingKey) && lc.E2EE != nil {
if myRawKeyID, _, errKey := lc.E2EE.MyKeyIDs(); errKey == nil && missingKey.KeyID < myRawKeyID {
return
}
}
lc.missingE2EEKeyMu.Lock()
if lc.missingE2EEKeyMarked {
lc.missingE2EEKeyMu.Unlock()
Expand Down
18 changes: 15 additions & 3 deletions pkg/e2ee/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ var (
ErrGroupKeyNotLoaded = errors.New("e2ee key not loaded")
)

type MissingOwnKeyError struct {
KeyID int
}

func (e *MissingOwnKeyError) Error() string {
return fmt.Sprintf("%s for %d", ErrMissingOwnPrivateKey, e.KeyID)
}

func (e *MissingOwnKeyError) Unwrap() error {
return ErrMissingOwnPrivateKey
}

func isFatalLTSMError(err error) bool {
return errors.Is(err, ltsm.ErrAbort) || errors.Is(err, gen.ErrRunnerClosed)
}
Expand Down Expand Up @@ -597,7 +609,7 @@ func (m *Manager) UnwrapGroupSharedKey(chatMid string, sharedKey *line.E2EEGroup
}

if myRunnerKey == 0 {
return 0, fmt.Errorf("%w for %d", ErrMissingOwnPrivateKey, receiverRawKeyID)
return 0, &MissingOwnKeyError{KeyID: receiverRawKeyID}
}

chanID, err := m.runner.ChannelCreate(myRunnerKey, creatorPubKeyB64)
Expand Down Expand Up @@ -992,10 +1004,10 @@ func (m *Manager) channelFromKeyIDs(senderKeyID, receiverKeyID int) (int, error)
privKeyID = id
} else {
if _, ok := peerPub[senderKeyID]; ok {
return 0, fmt.Errorf("%w for %d", ErrMissingOwnPrivateKey, receiverKeyID)
return 0, &MissingOwnKeyError{KeyID: receiverKeyID}
}
if _, ok := peerPub[receiverKeyID]; ok {
return 0, fmt.Errorf("%w for %d", ErrMissingOwnPrivateKey, senderKeyID)
return 0, &MissingOwnKeyError{KeyID: senderKeyID}
}
return 0, fmt.Errorf("no matching private key for senderKeyID=%d receiverKeyID=%d", senderKeyID, receiverKeyID)
}
Expand Down
Loading