mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Fix Go 1.13 requirement and make compiling SAS optional
This commit is contained in:
parent
2c882a33ba
commit
c3c4f6afe0
6 changed files with 15 additions and 9 deletions
|
|
@ -1,15 +1,17 @@
|
|||
package olm
|
||||
// +build !nosas
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"unsafe"
|
||||
)
|
||||
package olm
|
||||
|
||||
// #cgo LDFLAGS: -lolm -lstdc++
|
||||
// #include <olm/olm.h>
|
||||
// #include <olm/sas.h>
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// SAS stores an Olm Short Authentication String (SAS) object.
|
||||
type SAS struct {
|
||||
int *C.OlmSAS
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"testing"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
||||
"maunium.net/go/mautrix/crypto/olm"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
// 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/.
|
||||
|
||||
// +build !nosas
|
||||
|
||||
package crypto
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ func (VerificationMethodEmoji) GetVerificationSAS(initUserID id.UserID, initDevi
|
|||
|
||||
for i := 0; i < len(emojis); i++ {
|
||||
// take nth group of 6 bits
|
||||
emojiIdx := (sasNum >> (48 - (i+1)*6)) & 0x3F
|
||||
emojiIdx := (sasNum >> uint(48-(i+1)*6)) & 0x3F
|
||||
emoji := allEmojis[emojiIdx]
|
||||
emojis[i] = emoji
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ package event
|
|||
import (
|
||||
"encoding/json"
|
||||
|
||||
"maunium.net/go/mautrix/crypto/olm"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
|
|
@ -57,7 +58,7 @@ func (content *EncryptedEventContent) UnmarshalJSON(data []byte) error {
|
|||
return json.Unmarshal(content.Ciphertext, &content.OlmCiphertext)
|
||||
case id.AlgorithmMegolmV1:
|
||||
if len(content.Ciphertext) == 0 || content.Ciphertext[0] != '"' || content.Ciphertext[len(content.Ciphertext)-1] != '"' {
|
||||
return olm.InputNotJSONString
|
||||
return errors.New("input doesn't look like a JSON string")
|
||||
}
|
||||
content.MegolmCiphertext = content.Ciphertext[1 : len(content.Ciphertext)-1]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
package mautrix
|
||||
|
||||
const Version = "v0.7.0-rc.2"
|
||||
const Version = "v0.7.0-rc.3"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue