Watch
1
0
Fork
You've already forked mautrix-signal
0
mirror of https://github.com/mautrix/signal.git synced 2026-08-23 04:14:56 -04:00
mautrix-signal/pkg/libsignalgo/accountentropy.go

56 lines
1.6 KiB
Go
Raw Permalink Normal View History

// mautrix-signal - A Matrix-signal puppeting bridge.
// Copyright (C) 2024 Tulir Asokan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package libsignalgo
/*
#include "./libsignal-ffi.h"
*/
import "C"
2026-08-07 14:54:56 +03:00
import "runtime"
type AccountEntropyPool string
2026-08-07 14:54:56 +03:00
type SVRKey = fixedArray32
func (aep AccountEntropyPool) DeriveSVRKey() ([]byte, error) {
2026-08-07 14:54:56 +03:00
var out SVRKey
2026-07-13 15:44:31 +03:00
aepC, free := GoStringToCString(string(aep))
defer free()
signalFfiError := C.signal_account_entropy_pool_derive_svr_key(
2026-08-07 14:54:56 +03:00
out.cFixedArray(),
2026-07-13 15:44:31 +03:00
aepC,
)
runtime.KeepAlive(aep)
if signalFfiError != nil {
return nil, wrapError(signalFfiError)
}
return out[:], nil
}
func (aep AccountEntropyPool) DeriveBackupKey() ([]byte, error) {
2026-08-07 14:54:56 +03:00
var out BackupKey
2026-07-13 15:44:31 +03:00
aepC, free := GoStringToCString(string(aep))
defer free()
signalFfiError := C.signal_account_entropy_pool_derive_backup_key(
2026-08-07 14:54:56 +03:00
out.cFixedArray(),
2026-07-13 15:44:31 +03:00
aepC,
)
runtime.KeepAlive(aep)
if signalFfiError != nil {
return nil, wrapError(signalFfiError)
}
return out[:], nil
}