Skip to content

Commit

Permalink
Update to libsignal 0.44.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Apr 10, 2024
1 parent 680e0b8 commit 57348d0
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 70 deletions.
16 changes: 9 additions & 7 deletions pkg/libsignalgo/authcredential.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package libsignalgo
*/
import "C"
import (
"fmt"
"unsafe"

"github.com/google/uuid"
Expand All @@ -45,23 +46,25 @@ func ReceiveAuthCredentialWithPni(
redemptionTime uint64,
authCredResponse AuthCredentialWithPniResponse,
) (*AuthCredentialWithPni, error) {
c_result := [C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN]C.uchar{}
var c_result C.SignalOwnedBuffer = C.SignalOwnedBuffer{}
c_serverPublicParams := (*[C.SignalSERVER_PUBLIC_PARAMS_LEN]C.uchar)(unsafe.Pointer(&serverPublicParams[0]))
c_authCredResponse := (*[C.SignalAUTH_CREDENTIAL_WITH_PNI_RESPONSE_LEN]C.uchar)(unsafe.Pointer(&authCredResponse[0]))

signalFfiError := C.signal_server_public_params_receive_auth_credential_with_pni_as_service_id(
&c_result,
c_serverPublicParams,
NewACIServiceID(aci).CFixedBytes(),
NewPNIServiceID(pni).CFixedBytes(),
C.uint64_t(redemptionTime),
c_authCredResponse,
BytesToBuffer(authCredResponse[:]),
)
if signalFfiError != nil {
return nil, wrapError(signalFfiError)
}
result := AuthCredentialWithPni(C.GoBytes(unsafe.Pointer(&c_result), C.int(C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN)))
return &result, nil
resultBytes := CopySignalOwnedBufferToBytes(c_result)
if len(resultBytes) != C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN {
return nil, fmt.Errorf("invalid response length %d (expected %d)", len(resultBytes), C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN)
}
return (*AuthCredentialWithPni)(resultBytes), nil
}

func NewAuthCredentialWithPniResponse(b []byte) (*AuthCredentialWithPniResponse, error) {
Expand All @@ -84,14 +87,13 @@ func CreateAuthCredentialWithPniPresentation(
c_serverPublicParams := (*[C.SignalSERVER_PUBLIC_PARAMS_LEN]C.uchar)(unsafe.Pointer(&serverPublicParams[0]))
c_randomness := (*[C.SignalRANDOMNESS_LEN]C.uchar)(unsafe.Pointer(&randomness[0]))
c_groupSecretParams := (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uchar)(unsafe.Pointer(&groupSecretParams[0]))
c_authCredWithPni := (*[C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN]C.uchar)(unsafe.Pointer(&authCredWithPni[0]))

signalFfiError := C.signal_server_public_params_create_auth_credential_with_pni_presentation_deterministic(
&c_result,
c_serverPublicParams,
c_randomness,
c_groupSecretParams,
c_authCredWithPni,
BytesToBuffer(authCredWithPni[:]),
)
if signalFfiError != nil {
return nil, wrapError(signalFfiError)
Expand Down
2 changes: 1 addition & 1 deletion pkg/libsignalgo/libsignal
Submodule libsignal updated 304 files
Loading

0 comments on commit 57348d0

Please sign in to comment.