mautrix-go/crypto/goolm/session/register.go
Tulir Asokan 315d2ab17d
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
all: fix staticcheck issues
2025-12-08 00:07:25 +02:00

61 lines
1.9 KiB
Go

// Copyright (c) 2024 Sumner Evans
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package session
import (
"maunium.net/go/mautrix/crypto/olm"
)
func Register() {
// Inbound Session
olm.InitInboundGroupSessionFromPickled = func(pickled, key []byte) (olm.InboundGroupSession, error) {
if len(pickled) == 0 {
return nil, olm.ErrEmptyInput
}
if len(key) == 0 {
key = []byte(" ")
}
return MegolmInboundSessionFromPickled(pickled, key)
}
olm.InitNewInboundGroupSession = func(sessionKey []byte) (olm.InboundGroupSession, error) {
if len(sessionKey) == 0 {
return nil, olm.ErrEmptyInput
}
return NewMegolmInboundSession(sessionKey)
}
olm.InitInboundGroupSessionImport = func(sessionKey []byte) (olm.InboundGroupSession, error) {
if len(sessionKey) == 0 {
return nil, olm.ErrEmptyInput
}
return NewMegolmInboundSessionFromExport(sessionKey)
}
olm.InitBlankInboundGroupSession = func() olm.InboundGroupSession {
return &MegolmInboundSession{}
}
// Outbound Session
olm.InitNewOutboundGroupSessionFromPickled = func(pickled, key []byte) (olm.OutboundGroupSession, error) {
if len(pickled) == 0 {
return nil, olm.ErrEmptyInput
}
lenKey := len(key)
if lenKey == 0 {
key = []byte(" ")
}
return MegolmOutboundSessionFromPickled(pickled, key)
}
olm.InitNewOutboundGroupSession = func() (olm.OutboundGroupSession, error) { return NewMegolmOutboundSession() }
olm.InitNewBlankOutboundGroupSession = func() olm.OutboundGroupSession { return &MegolmOutboundSession{} }
// Olm Session
olm.InitSessionFromPickled = func(pickled, key []byte) (olm.Session, error) {
return OlmSessionFromPickled(pickled, key)
}
olm.InitNewBlankSession = func() olm.Session {
return NewOlmSession()
}
}