Documentation
¶
Index ¶
- Constants
- Variables
- func AesgcmDecrypt(key, nonce, data, mac []byte) ([]byte, error)
- func AesgcmEncrypt(key, nonce, plaintext []byte) ([]byte, error)
- func DataMessageForDelete(targetMessageTimestamp uint64) *signalpb.Content
- func DataMessageForReaction(reaction string, targetMessageSender uuid.UUID, targetMessageTimestamp uint64, ...) *signalpb.Content
- func DecryptDeviceName(wrappedData []byte, identityKey *libsignalgo.PrivateKey) (string, error)
- func DeliveredReceiptMessageForTimestamps(timestamps []uint64) *signalpb.Content
- func DownloadAttachment(ctx context.Context, a *signalpb.AttachmentPointer) ([]byte, error)
- func EncryptDeviceName(name string, identityKey *libsignalgo.PublicKey) ([]byte, error)
- func GenerateKyberPreKeys(startKeyId uint, count uint, uuidKind types.UUIDKind, ...) []*libsignalgo.KyberPreKeyRecord
- func GeneratePreKeys(startKeyId uint, count uint, uuidKind types.UUIDKind) []*libsignalgo.PreKeyRecord
- func GenerateSignedPreKey(startSignedKeyId uint32, uuidKind types.UUIDKind, ...) *libsignalgo.SignedPreKeyRecord
- func KyberPreKeyToJSON(kyberPreKey *libsignalgo.KyberPreKeyRecord) map[string]interface{}
- func PerformProvisioning(ctx context.Context, deviceStore store.DeviceStore, deviceName string) chan ProvisioningResponse
- func PreKeyToJSON(preKey *libsignalgo.PreKeyRecord) map[string]interface{}
- func ReadReceptMessageForTimestamps(timestamps []uint64) *signalpb.Content
- func RegisterPreKeys(ctx context.Context, generatedPreKeys *GeneratedPreKeys, ...) error
- func SetLogger(l zerolog.Logger)
- func SignedPreKeyToJSON(signedPreKey *libsignalgo.SignedPreKeyRecord) map[string]interface{}
- func TypingMessage(isTyping bool) *signalpb.Content
- func UnpadPKCS7(data []byte) ([]byte, error)
- type AccessControl
- type AddMember
- type BannedMember
- type CDSResponseEntry
- type Capabilities
- type Client
- func (cli *Client) CheckAndUploadNewPreKeys(ctx context.Context, uuidKind types.UUIDKind) error
- func (cli *Client) ClearKeysAndDisconnect(ctx context.Context) error
- func (cli *Client) ConnectAuthedWS(ctx context.Context, requestHandler web.RequestHandlerFunc) (chan web.SignalWebsocketConnectionStatus, error)
- func (cli *Client) ConnectUnauthedWS(ctx context.Context) (chan web.SignalWebsocketConnectionStatus, error)
- func (cli *Client) ContactByE164(ctx context.Context, e164 string) (*types.Contact, error)
- func (cli *Client) ContactByID(ctx context.Context, uuid uuid.UUID) (*types.Contact, error)
- func (cli *Client) DecryptGroupChange(ctx context.Context, groupContext *signalpb.GroupContextV2) (*GroupChange, error)
- func (cli *Client) DownloadGroupAvatar(ctx context.Context, group GroupAvatarMeta) ([]byte, error)
- func (cli *Client) DownloadUserAvatar(ctx context.Context, avatarPath string, profileKey libsignalgo.ProfileKey) ([]byte, error)
- func (cli *Client) FetchAndProcessPreKey(ctx context.Context, theirUUID uuid.UUID, specificDeviceID int) error
- func (cli *Client) FetchStorage(ctx context.Context, masterKey []byte, currentVersion uint64, ...) (*StorageUpdate, error)
- func (cli *Client) GenerateAndRegisterPreKeys(ctx context.Context, uuidKind types.UUIDKind) error
- func (cli *Client) GenerateAndSaveNextKyberPreKeyBatch(ctx context.Context, uuidKind types.UUIDKind) ([]*libsignalgo.KyberPreKeyRecord, error)
- func (cli *Client) GenerateAndSaveNextPreKeyBatch(ctx context.Context, uuidKind types.UUIDKind) ([]*libsignalgo.PreKeyRecord, error)
- func (cli *Client) GetAuthorizationForToday(ctx context.Context, masterKey libsignalgo.GroupMasterKey) (*GroupAuth, error)
- func (cli *Client) GetMyKeyCounts(ctx context.Context, uuidKind types.UUIDKind) (int, int, error)
- func (cli *Client) IsConnected() bool
- func (cli *Client) IsLoggedIn() bool
- func (cli *Client) LastConnectionStatus() SignalConnectionStatus
- func (cli *Client) LookupPhone(ctx context.Context, e164s ...uint64) (ContactDiscoveryResponse, error)
- func (cli *Client) ProfileKeyCredentialRequest(ctx context.Context, signalACI uuid.UUID) ([]byte, error)
- func (cli *Client) ProfileKeyForSignalID(ctx context.Context, signalACI uuid.UUID) (*libsignalgo.ProfileKey, error)
- func (cli *Client) RegisterAllPreKeys(ctx context.Context, uuidKind types.UUIDKind) error
- func (cli *Client) RetrieveGroupByID(ctx context.Context, gid types.GroupIdentifier, revision uint32) (*Group, error)
- func (cli *Client) RetrieveProfileByID(ctx context.Context, signalID uuid.UUID) (*types.Profile, error)
- func (cli *Client) SendContactSyncRequest(ctx context.Context) error
- func (cli *Client) SendGroupMessage(ctx context.Context, gid types.GroupIdentifier, content *signalpb.Content) (*GroupMessageSendResult, error)
- func (cli *Client) SendMessage(ctx context.Context, recipientID uuid.UUID, content *signalpb.Content) SendMessageResult
- func (cli *Client) StartKeyCheckLoop(ctx context.Context, uuidKind types.UUIDKind)
- func (cli *Client) StartReceiveLoops(ctx context.Context) (chan SignalConnectionStatus, error)
- func (cli *Client) StopReceiveLoops() error
- func (cli *Client) StoreContactDetailsAsContact(ctx context.Context, contactDetails *signalpb.ContactDetails, avatar *[]byte) (*types.Contact, error)
- func (cli *Client) StoreMasterKey(ctx context.Context, groupMasterKey types.SerializedGroupMasterKey) (types.GroupIdentifier, error)
- func (cli *Client) UpdateActiveCalls(gid types.GroupIdentifier, callID string) (isActive bool)
- func (cli *Client) UpdateContactE164(ctx context.Context, uuid uuid.UUID, e164 string) error
- func (cli *Client) UpdateDeviceName(ctx context.Context, name string) error
- func (cli *Client) UploadAttachment(ctx context.Context, body []byte) (*signalpb.AttachmentPointer, error)
- type ConfirmDeviceResponse
- type ContactDiscoveryClient
- type ContactDiscoveryRateLimitError
- type ContactDiscoveryResponse
- type DecryptedStorageRecord
- type DecryptionResult
- type FFILogger
- type FailedSendResult
- type GeneratedPreKeys
- type Group
- type GroupAccessControl
- type GroupAuth
- type GroupAvatarMeta
- type GroupCache
- type GroupChange
- type GroupCredential
- type GroupCredentials
- type GroupExternalCredential
- type GroupMember
- type GroupMemberRole
- type GroupMessageSendResult
- type MyMessage
- type MyMessages
- type PendingMember
- type ProfileCache
- type ProfileKeyMember
- type ProfileResponse
- type ProvisioningCipher
- type ProvisioningResponse
- type ProvisioningState
- type RequestingMember
- type RoleMember
- type SendMessageResult
- type SignalConnectionEvent
- type SignalConnectionStatus
- type StorageUpdate
- type SuccessfulSendResult
Constants ¶
const CIPHERTEXT_OFFSET uint = IV_OFFSET + IV_LENGTH
const CIPHER_KEY_SIZE uint = 32
const ContactDiscoveryAuthTTL = 23 * time.Hour
const IV_LENGTH uint = 16
const IV_OFFSET uint = VERSION_OFFSET + VERSION_LENGTH
const MAC_SIZE uint = 32
const MaxReadStorageRecords = 2500
MaxReadStorageRecords is the maximum number of storage records to fetch at once from https://github.com/signalapp/Signal-Desktop/blob/v6.44.0/ts/services/storageConstants.ts
const NONCE_LENGTH = 12
const PREKEY_BATCH_SIZE = 100
const ProdContactDiscoveryMrenclave = "0f6fd79cdfdaa5b2e6337f534d3baf999318b0c462a7ac1f41297a3e4b424a57"
const ProdContactDiscoveryServer = "cdsi.signal.org"
const SUPPORTED_VERSION uint8 = 1
const TAG_LENGTH_BYTES = 16
const VERSION_LENGTH uint = 1
const VERSION_OFFSET uint = 0
Variables ¶
var ErrInvalidDigestForAttachment = errors.New("invalid digest for attachment")
var ErrInvalidMACForAttachment = errors.New("invalid MAC for attachment")
ErrInvalidMACForAttachment signals that the downloaded attachment has an invalid MAC.
Functions ¶
func AesgcmDecrypt ¶
func AesgcmEncrypt ¶
func DataMessageForDelete ¶
func DataMessageForReaction ¶
func DecryptDeviceName ¶
func DecryptDeviceName(wrappedData []byte, identityKey *libsignalgo.PrivateKey) (string, error)
func DownloadAttachment ¶
func EncryptDeviceName ¶
func EncryptDeviceName(name string, identityKey *libsignalgo.PublicKey) ([]byte, error)
func GenerateKyberPreKeys ¶
func GenerateKyberPreKeys(startKeyId uint, count uint, uuidKind types.UUIDKind, identityKeyPair *libsignalgo.IdentityKeyPair) []*libsignalgo.KyberPreKeyRecord
func GeneratePreKeys ¶
func GeneratePreKeys(startKeyId uint, count uint, uuidKind types.UUIDKind) []*libsignalgo.PreKeyRecord
func GenerateSignedPreKey ¶
func GenerateSignedPreKey(startSignedKeyId uint32, uuidKind types.UUIDKind, identityKeyPair *libsignalgo.IdentityKeyPair) *libsignalgo.SignedPreKeyRecord
func KyberPreKeyToJSON ¶
func KyberPreKeyToJSON(kyberPreKey *libsignalgo.KyberPreKeyRecord) map[string]interface{}
func PerformProvisioning ¶
func PerformProvisioning(ctx context.Context, deviceStore store.DeviceStore, deviceName string) chan ProvisioningResponse
func PreKeyToJSON ¶
func PreKeyToJSON(preKey *libsignalgo.PreKeyRecord) map[string]interface{}
func RegisterPreKeys ¶
func SignedPreKeyToJSON ¶
func SignedPreKeyToJSON(signedPreKey *libsignalgo.SignedPreKeyRecord) map[string]interface{}
func TypingMessage ¶
func UnpadPKCS7 ¶
Types ¶
type AccessControl ¶
type AccessControl int32
const ( AccessControl_UNKNOWN AccessControl = 0 AccessControl_ANY AccessControl = 1 AccessControl_MEMBER AccessControl = 2 AccessControl_ADMINISTRATOR AccessControl = 3 AccessControl_UNSATISFIABLE AccessControl = 4 )
type AddMember ¶
type AddMember struct {
GroupMember
JoinFromInviteLink bool
}
type BannedMember ¶
type Capabilities ¶
type Capabilities struct {
SenderKey bool `json:"senderKey"`
AnnouncementGroup bool `json:"announcementGroup"`
ChangeNumber bool `json:"changeNumber"`
Stories bool `json:"stories"`
GiftBadges bool `json:"giftBadges"`
PaymentActivation bool `json:"paymentActivation"`
PNI bool `json:"pni"`
Gv1Migration bool `json:"gv1-migration"`
}
type Client ¶
type Client struct {
Store *store.Device
SenderCertificate *libsignalgo.SenderCertificate
GroupCredentials *GroupCredentials
GroupCache *GroupCache
ProfileCache *ProfileCache
GroupCallCache *map[string]bool
LastContactRequestTime *int64
AuthedWS *web.SignalWebsocket
UnauthedWS *web.SignalWebsocket
WSCancel context.CancelFunc
EventHandler func(events.SignalEvent)
// contains filtered or unexported fields
}
func (*Client) CheckAndUploadNewPreKeys ¶
func (*Client) ClearKeysAndDisconnect ¶
func (*Client) ConnectAuthedWS ¶
func (cli *Client) ConnectAuthedWS(ctx context.Context, requestHandler web.RequestHandlerFunc) (chan web.SignalWebsocketConnectionStatus, error)
func (*Client) ConnectUnauthedWS ¶
func (*Client) ContactByE164 ¶
func (*Client) ContactByID ¶
func (*Client) DecryptGroupChange ¶
func (cli *Client) DecryptGroupChange(ctx context.Context, groupContext *signalpb.GroupContextV2) (*GroupChange, error)
func (*Client) DownloadGroupAvatar ¶
func (*Client) DownloadUserAvatar ¶
func (cli *Client) DownloadUserAvatar(ctx context.Context, avatarPath string, profileKey libsignalgo.ProfileKey) ([]byte, error)
func (*Client) FetchAndProcessPreKey ¶
func (*Client) FetchStorage ¶
func (*Client) GenerateAndRegisterPreKeys ¶
func (*Client) GenerateAndSaveNextKyberPreKeyBatch ¶
func (cli *Client) GenerateAndSaveNextKyberPreKeyBatch(ctx context.Context, uuidKind types.UUIDKind) ([]*libsignalgo.KyberPreKeyRecord, error)
func (*Client) GenerateAndSaveNextPreKeyBatch ¶
func (cli *Client) GenerateAndSaveNextPreKeyBatch(ctx context.Context, uuidKind types.UUIDKind) ([]*libsignalgo.PreKeyRecord, error)
func (*Client) GetAuthorizationForToday ¶
func (cli *Client) GetAuthorizationForToday(ctx context.Context, masterKey libsignalgo.GroupMasterKey) (*GroupAuth, error)
func (*Client) GetMyKeyCounts ¶
func (*Client) IsConnected ¶
func (*Client) IsLoggedIn ¶
func (*Client) LastConnectionStatus ¶
func (cli *Client) LastConnectionStatus() SignalConnectionStatus
func (*Client) LookupPhone ¶
func (*Client) ProfileKeyCredentialRequest ¶
func (*Client) ProfileKeyForSignalID ¶
func (cli *Client) ProfileKeyForSignalID(ctx context.Context, signalACI uuid.UUID) (*libsignalgo.ProfileKey, error)
func (*Client) RegisterAllPreKeys ¶
func (*Client) RetrieveGroupByID ¶
func (*Client) RetrieveProfileByID ¶
func (*Client) SendContactSyncRequest ¶
func (*Client) SendGroupMessage ¶
func (cli *Client) SendGroupMessage(ctx context.Context, gid types.GroupIdentifier, content *signalpb.Content) (*GroupMessageSendResult, error)
func (*Client) SendMessage ¶
func (*Client) StartKeyCheckLoop ¶
func (*Client) StartReceiveLoops ¶
func (cli *Client) StartReceiveLoops(ctx context.Context) (chan SignalConnectionStatus, error)
func (*Client) StopReceiveLoops ¶
func (*Client) StoreContactDetailsAsContact ¶
func (*Client) StoreMasterKey ¶
func (cli *Client) StoreMasterKey(ctx context.Context, groupMasterKey types.SerializedGroupMasterKey) (types.GroupIdentifier, error)
We should store the group master key in the group store as soon as we see it, then use the group identifier to refer to groups. As a convenience, we return the group identifier, which is derived from the group master key.
func (*Client) UpdateActiveCalls ¶
func (cli *Client) UpdateActiveCalls(gid types.GroupIdentifier, callID string) (isActive bool)
We need to track active calls so we don't send too many IncomingSignalMessageCalls Of course for group calls Signal doesn't tell us *anything* so we're mostly just inferring So we just jam a new call ID in, and return true if we *think* this is a new incoming call
func (*Client) UpdateContactE164 ¶
func (*Client) UpdateDeviceName ¶
func (*Client) UploadAttachment ¶
type ConfirmDeviceResponse ¶
type ContactDiscoveryClient ¶
type ContactDiscoveryClient struct {
CDS *libsignalgo.SGXClientState
WS *websocket.Conn
Token []byte
Response ContactDiscoveryResponse
// contains filtered or unexported fields
}
func (*ContactDiscoveryClient) Handshake ¶
func (cdc *ContactDiscoveryClient) Handshake(ctx context.Context) error
func (*ContactDiscoveryClient) ReadResponse ¶
func (cdc *ContactDiscoveryClient) ReadResponse(ctx context.Context) error
func (*ContactDiscoveryClient) SendRequest ¶
func (cdc *ContactDiscoveryClient) SendRequest(ctx context.Context, req *signalpb.CDSClientRequest) error
type ContactDiscoveryRateLimitError ¶
func (ContactDiscoveryRateLimitError) Error ¶
func (cdrle ContactDiscoveryRateLimitError) Error() string
type ContactDiscoveryResponse ¶
type ContactDiscoveryResponse map[uint64]CDSResponseEntry
type DecryptedStorageRecord ¶
type DecryptedStorageRecord struct {
ItemType signalpb.ManifestRecord_Identifier_Type
StorageID string
StorageRecord *signalpb.StorageRecord
}
type DecryptionResult ¶
type DecryptionResult struct {
SenderAddress *libsignalgo.Address
Content *signalpb.Content
SealedSender bool
}
type FailedSendResult ¶
type GeneratedPreKeys ¶
type GeneratedPreKeys struct {
PreKeys []*libsignalgo.PreKeyRecord
KyberPreKeys []*libsignalgo.KyberPreKeyRecord
IdentityKey []uint8
}
type Group ¶
type Group struct {
GroupIdentifier types.GroupIdentifier // This is what we should use to identify a group outside this file
Title string
AvatarPath string
Members []*GroupMember
Description string
AnnouncementsOnly bool
Revision uint32
DisappearingMessagesDuration uint32
AccessControl *GroupAccessControl
PendingMembers []*PendingMember
RequestingMembers []*RequestingMember
BannedMembers []*BannedMember
// contains filtered or unexported fields
}
func (*Group) GetAvatarPath ¶
type GroupAccessControl ¶
type GroupAccessControl struct {
Members AccessControl
AddFromInviteLink AccessControl
Attributes AccessControl
}
type GroupAvatarMeta ¶
type GroupAvatarMeta interface {
GetAvatarPath() *string
// contains filtered or unexported methods
}
type GroupCache ¶
type GroupCache struct {
// contains filtered or unexported fields
}
type GroupChange ¶
type GroupChange struct {
Revision uint32
AddMembers []*AddMember
DeleteMembers []*uuid.UUID
ModifyMemberRoles []*RoleMember
ModifyMemberProfileKeys []*ProfileKeyMember
AddPendingMembers []*PendingMember
DeletePendingMembers []*uuid.UUID
PromotePendingMembers []*ProfileKeyMember
ModifyTitle *string
ModifyAvatar *string
ModifyDisappearingMessagesDuration *uint32
ModifyAttributesAccess *AccessControl
ModifyMemberAccess *AccessControl
ModifyAddFromInviteLinkAccess *AccessControl
AddRequestingMembers []*RequestingMember
DeleteRequestingMembers []*uuid.UUID
PromoteRequestingMembers []*RoleMember
ModifyDescription *string
ModifyAnnouncementsOnly *bool
AddBannedMembers []*BannedMember
DeleteBannedMembers []*uuid.UUID
PromotePendingPniAciMembers []*ProfileKeyMember
// contains filtered or unexported fields
}
func (*GroupChange) GetAvatarPath ¶
func (groupChange *GroupChange) GetAvatarPath() *string
type GroupCredential ¶
type GroupCredentials ¶
type GroupCredentials struct {
Credentials []GroupCredential `json:"credentials"`
PNI uuid.UUID `json:"pni"`
}
type GroupExternalCredential ¶
type GroupExternalCredential struct {
Token []byte `json:"token"`
}
type GroupMember ¶
type GroupMember struct {
UserID uuid.UUID
Role GroupMemberRole
ProfileKey libsignalgo.ProfileKey
JoinedAtRevision uint32
}
type GroupMemberRole ¶
type GroupMemberRole int32
const ( // Note: right now we assume these match the equivalent values in the protobuf (signalpb.Member_Role) GroupMember_UNKNOWN GroupMemberRole = 0 GroupMember_DEFAULT GroupMemberRole = 1 GroupMember_ADMINISTRATOR GroupMemberRole = 2 )
type GroupMessageSendResult ¶
type GroupMessageSendResult struct {
SuccessfullySentTo []SuccessfulSendResult
FailedToSendTo []FailedSendResult
}
type MyMessages ¶
type PendingMember ¶
type PendingMember struct {
GroupMember
AddedByUserID uuid.UUID
Timestamp uint64
}
type ProfileCache ¶
type ProfileCache struct {
// contains filtered or unexported fields
}
type ProfileKeyMember ¶
type ProfileKeyMember struct {
UserID uuid.UUID
ProfileKey libsignalgo.ProfileKey
}
type ProfileResponse ¶
type ProfileResponse struct {
UUID uuid.UUID `json:"uuid"`
Name []byte `json:"name"`
About []byte `json:"about"`
AboutEmoji []byte `json:"aboutEmoji"`
Avatar string `json:"avatar"`
Capabilities Capabilities `json:"capabilities"`
Credential []byte `json:"credential"`
IdentityKey []byte `json:"identityKey"`
UnidentifiedAccess []byte `json:"unidentifiedAccess"`
UnrestrictedUnidentifiedAccess bool `json:"UnrestrictedUnidentifiedAccess"`
}
type ProvisioningCipher ¶
type ProvisioningCipher struct {
// contains filtered or unexported fields
}
func NewProvisioningCipher ¶
func NewProvisioningCipher() *ProvisioningCipher
func (*ProvisioningCipher) Decrypt ¶
func (c *ProvisioningCipher) Decrypt(env *signalpb.ProvisionEnvelope) (*signalpb.ProvisionMessage, error)
func (*ProvisioningCipher) GetPublicKey ¶
func (c *ProvisioningCipher) GetPublicKey() *libsignalgo.PublicKey
type ProvisioningResponse ¶
type ProvisioningResponse struct {
State ProvisioningState
ProvisioningURL string
ProvisioningData *store.DeviceData
Err error
}
Enum for the provisioningUrl, ProvisioningMessage, and error
type ProvisioningState ¶
type ProvisioningState int
const ( StateProvisioningError ProvisioningState = iota StateProvisioningURLReceived StateProvisioningDataReceived StateProvisioningPreKeysRegistered )
func (ProvisioningState) String ¶
func (s ProvisioningState) String() string
type RequestingMember ¶
type RequestingMember struct {
UserID uuid.UUID
ProfileKey libsignalgo.ProfileKey
Timestamp uint64
}
type RoleMember ¶
type RoleMember struct {
UserID uuid.UUID
Role GroupMemberRole
}
type SendMessageResult ¶
type SendMessageResult struct {
WasSuccessful bool
*SuccessfulSendResult
*FailedSendResult
}
type SignalConnectionEvent ¶
type SignalConnectionEvent int
const ( SignalConnectionEventNone SignalConnectionEvent = iota SignalConnectionEventConnected SignalConnectionEventDisconnected SignalConnectionEventLoggedOut SignalConnectionEventError SignalConnectionCleanShutdown )
func (SignalConnectionEvent) String ¶
func (s SignalConnectionEvent) String() string
Implement the fmt.Stringer interface
type SignalConnectionStatus ¶
type SignalConnectionStatus struct {
Event SignalConnectionEvent
Err error
}
type StorageUpdate ¶
type StorageUpdate struct {
Version uint64
NewRecords []*DecryptedStorageRecord
RemovedRecords []string
MissingRecords []string
}