Signal
Signal
Universiteit
Leuven
Department of
Computer Science
2 LINDDUN Analysis 4
2.1 Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Identifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Non-Repudiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4 Detecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.5 Data Disclosure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.6 Unawareness & Un-intervenability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.7 Non Compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Risks 6
3.1 Technical risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 Phone Numbers & Privacy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 Contact Discovery mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.3 Contact Discovery crawling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.4 Metadata capture on peer-to-peer calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Legal risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 Ethical risks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4 Testing 8
4.1 Contact Discovery Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.2 Meta-Data Capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5 Recommendations 10
5.1 Improve Membership Privacy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1.1 Mutual Contact Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1.2 Mitigation strategy for crawling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1.3 Optional Hidden Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2 Alternatives to phone numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.3 Upcoming Signal Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6 Conclusion 11
A Appendices 15
A.1 Signal Code snippet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
A.2 Proposed unit test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
A.3 Scenario tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
A.3.1 Arbitrary contact discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
A.3.2 Sending a message to an arbitrary number . . . . . . . . . . . . . . . . . . . . . . . . . . 21
List of Figures
1 Signal application diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Old Contact Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 Wireshark Capture Regular Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4 Wireshark Capture VPN Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5 Wireshark Capture Proxy Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
6 Wireshark Capture VPN & Proxy Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
7 Scenario test 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
8 Scenario test 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1
1 Application Description
1.1 Introduction
This report presents an in-depth privacy impact assessment of the Signal messaging app on Android, with a
focus on the use of phone numbers and the contact discovery feature. It evaluates how these aspects potentially
affect user privacy using the LINDDUN framework and provides recommendations to improve upon them.
1.2 Functionality
Signal is known for its commitment to user privacy through robust end-to-end encryption and minimal data
collection. Whether it’s messages, calls, or video calls, Signal uses the Signal Protocol to ensure that the
content of these communications remains exclusively accessible to the intended recipients. As a result of
state of the art encryption neither malicious actors nor Signal itself can decipher the data being transmitted,
establishing a high standard of security and confidentiality.
In addition to its security measures, Signal also offers other features. These include customizable chat
options with various colors and themes, scheduling messages for future delivery, and the ability to set messages
to disappear after a specified time. Users can also manage their data usage preferences, utilize an incognito
keyboard for added privacy, and make in-app payments securely [1].
Signal is available on multiple platforms, like iOS, Android, and Desktop. However, it’s important to
note that synchronizing old messages is not a feature as Signal prioritizes data privacy. All data, including
messages, is stored locally on individual devices, enhancing security and maintaining user privacy.
1.3 Stakeholders
One of the main stakeholders in Signal are the developers and donors, which consists of entities like the Signal
Technology Foundation, Signal Messenger LLC, and a global network of individuals who contribute to its
open-source code. The initial development of Signal, under Open Whisper Systems, was funded through a
combination of consulting work, donations, and grant money.
Countries and states are crucial stakeholders when considering the intricate dynamics surrounding Signal.
National governments and regional authorities worldwide are constantly seeking to balance the rights of their
citizens to privacy with the imperatives of national security and law enforcement. Signal, with its strong data
privacy features and end-to-end encryption, significantly limits the amount of user data accessible to external
parties, including governmental agencies. The NSA has identified Signal as a significant challenge in their
mission to access users’ private data [2].
• User profile name and picture (optional): Users can optionally add this information to their profile
to make them recognizable to others. However, this information is end-to-end encrypted and not stored
on Signal’s servers [4].
• Contacts (optional): Users have the option to give Signal access to their contacts to check if they
are registered users. The application can then browse through the system contacts in order to discover
which contacts are registered Signal users. The contact discovery process is designed in such a way that
Signal never obtains information of your contacts. [5].
• Messages: Only stored locally on user-devices. Encrypted so that Signal cannot read them [3].
• User: Signal stores technical information such as randomly generated authentication tokens and keys.
These are not associated with the user, and are solely used for setting up calls or transmitting messages [3].
• User: Unix timestamps of when the user was last logged into the app, and when the user created their
account [6].
2
1.5 Design and Implementation
Signal is well-known for its strong commitment to user privacy and data protection. The application incorpo-
rates several key design and implementation choices that prioritize user privacy.
On the client side, the application incorporates an encrypted SQLite database for local chat storage on
users’ devices [7]. This database enables users to access their chat history conveniently. This means that a
users chat history is unavailable on any other device logged in to the same account unless you transfer them [8].
The server-side, on the other hand, comprises Signal’s cloud servers, which act as intermediaries in the
messaging process. These servers play a crucial role in securely transmitting messages between users. When
a message is sent, it is temporarily stored in an encrypted form on Signal’s cloud servers until it reaches its
intended recipient. Upon the recipient opening the Signal application, the message is retrieved from the cloud
server and delivered. Once the delivery is successfully completed and confirmed, the encrypted message is
promptly removed from Signal’s database [3].
At the heart of the Signal Application is End-to-End encryption (E2EE), which ensures the privacy of
the content of the messages sent in through the application. To understand how this concept is implemented
we must understand the Signal protocol. The Signal Protocol uses state of the art encryption techniques
to ensure safe transfer of user data. The protocol combines the Double Ratchet algorithm, prekeys, and a
triple Elliptic-curve Diffie–Hellman (3-DH) handshake, and uses Curve25519, AES-256, and HMAC-SHA256
as primitives [9]. The key takeaway from this is that they ensure that only the intended recipient can decipher
messages. This design choice ensures that even Signal cannot access the content of your messages [10].
3
2 LINDDUN Analysis
In this section we will highlight some threats found using the LINDDUN threat modelling system [11].
2.1 Linking
Linking is a potential privacy threat where the data points of a user are connected with other data sources to
retrieve information about the user. Signal uses phone numbers for logging in, creating a one-to-one link to a
specific phone number.
• Third party services and account registration: A third party verification service can link a phone
number and verification code to a specific user.
• IP addressing: Signal allows for redirecting all calls through their service, but this is only done by
default when receiving calls from someone outside your contact list. This makes it possible to track IP
addresses of the people you are communicating with. IP addresses can e.g., be used to infer information
about a geo-location, the use of a service provider or belonging to an organization.
• Messaging metadata: Signal is able to read metadata of messages, but this information is not stored.
If Signal was a malicious actor, this information could be used to deduce a social graph to see which
users are talking to each other. Avoiding metadata entirely would however be nearly impossible and
impractical in terms of sending messages.
2.2 Identifying
• Use of phone numbers: The threat of identification is associated with linking. The users provided
phone number is potentially identifiable data. This means the identity of the user may be revealed if the
phone number can be linked to an identity. Some phone numbers are searchable online, which makes
them identifiable. Even though a phone number is not searchable online, it is still relatively easy to gain
information about it.
2.3 Non-Repudiation
Not being able to refute claims. Signal, like many other messaging apps, has the functionality of reading
confirmations and typing indicators (pop-up that shows if someone is typing).
• Read Confirmation: Signal has read confirmations on messages that are read by the user. This may
prevent a user from using the argument of plausible deniability if for example Signal messages are used
as evidence in a legal case.
2.4 Detecting
The threat of detection is similar to what is outlined under Linking and Identifying. As stated above, one can
infer that a person is a user of Signal.
• Contact Discovery: Signal provides a contact discovery feature to see if a personal contact’s phone
number is linked to a Signal account.
4
• Maximum security by default: Some features that provide additional/improved privacy settings
are not turned on by default. Examples of these are the registration lock or the ”always relay calls”
option [12].
• Access to physical devices: Face ID or password are not turned on by default, meaning that if
someone gets access to your phone, this implies access to your Signal account.
5
3 Risks
3.1 Technical risks
3.1.1 Phone Numbers & Privacy
The Signal foundation has faced much criticism regarding the use of phone numbers for user authentication.
This is because, inherently, a phone number is a potential personally identifiable piece of information. Phone
numbers are often leaked in data breaches [13], and in many countries, one must provide an identity to register
a phone number.
Some users may be uncomfortable sharing their phone number with all people they communicate with
through Signal. Currently, there is no option to hide your phone number from other users. Therefore, messages
cannot be sent without revealing this information.
Source: [14]
Figure 2: Old Contact Discovery
Figure 2 depicts the construction of a discovery request in the old contact discovery implementation. While
this hashing was intended to prevent the Signal service from seeing your contacts, the reversal of hashes has
been shown to be trivial. One can leverage the knowledge of the structure of the original data, the phone
number, and potentially additional information such as the country of origin. Marx et al. have demonstrated
this for phone numbers using a mask attack. A mask attack can make the brute force reversal of a hash faster
by providing priors on the structure of the data to be recovered. Hagen et al. demonstrated this vulnerability
at scale, in the setting of contact discovery for multiple messaging apps. Methods include the creation of a
key-value lookup table, brute-forcing and rainbow tables. All these methods’ efficiencies benefit heavily from
implying phone number standards, rendering the hashes trivial to reverse. [15, 16]
Signal has identified this shortcoming. In a more recent implementation, contact discovery is done trough
a secure enclave using Intel® SGX. This secure enclave protects data while in use. The host operating system
can not access and therefore not tamper with this environment. The Signal Client can verify that the contact
discovery code that is running on the Signal server is the same as the published open source code. Furthermore,
Signal implemented oblivious RAM, ORAM, to prevent the operating system from inferring information from
memory access patterns. [17] While a secure enclave, like Intel SGX is very secure in theory, in practice many
potential exploits have been found. [18, 19]
6
3.1.4 Metadata capture on peer-to-peer calls
In March 2017, Signal implemented peer-to-peer calls as their default connection method for calls. The reason
for this was to reduce call latency and improve the user experience. [12]. Whenever the user makes or receives
a call from someone in their contacts, Signal will attempt to establish the connection peer-to-peer. The issue
with this is that it exposes the IP-address of the user, and consequently reveals the users rough location. In
4.2 we demonstrate how this information can be extracted.
The greatest risk regarding this issue, is that user might not know that IP addresses are exposed when
calling and that they can be used to infer a users location. There is an option in the Signal settings to relay
all calls through the Signal servers, however, this is disabled by default an thus goes against the principle of
privacy by default. Users unaware of this could take it for granted that their location is completely undisclosed.
7
4 Testing
4.1 Contact Discovery Service
In order to test potential vulnerabilities in Signal’s Android app, we developed a unit test that simulates the call
to the Contact Discovery Service (CDS), a server-side component provided by Signal. This service establishes a
secure connection between the application and the server for contact discovery, ensuring end-to-end encryption
up to the secure enclave.
Our testing approach utilizes functionality from the getRegisteredUsersWithCdsi() method in SignalSer-
viceAccountManager.java, as detailed in Appendix A.1, to check for the possibility to exploit the CDS. To
create a valid request to the CDS, we must provide several input parameters, including a set of correctly
formatted telephone numbers. Following the construction of a valid request, we establish a connection to the
secure enclave by assuming the presence of a valid SignalServiceConfiguration and PushServiceSocket, allowing
us to obtain tokens for CDS calls.
The test concludes with the submission of a request to the CDS, parsing the response, and verifying that
no registered users are found. This verification ensures that the synthetic E.164 numbers used in the test do
not correspond to any registered users in the system. The complete test can be found in Appendix A.2.
It’s essential to note that to run this unit test, you need a valid instance of SignalServiceConfiguration
and PushServiceSocket, a condition that we failed to replicate fully in a unit test. To showcase our expected
results, we conducted scenario tests (Appendix A.3) and found that contact discovery crawling is possible. In
both scenario tests we where able to link arbitrary telephone numbers to active Signal accounts.
Figure 3 shows how Wireshark can be used to expose the IP address of the caller. Utilizing the online tool IP
Tracker [22], we were able to deduce that the caller had Telenet in Belgium as their provider and that they
were located in Ghent during the call.
There are, however, ways to prevent this. Firstly, Signal offers the option to always relay calls via the
Signal servers [12]. The IP addresses of the users will then be hidden from each peer. Another mitigation
method can be to use VPN when calling with Signal.
8
Figure 4: Wireshark Capture VPN Call
Figure 4 shows the Wireshark capture of a call where the caller has set their VPN location to Canada while
calling from Ghent, Belgium. As expected, the location and service provider were skewed.
In figure 5 the caller activated the option in their settings to ”always relay calls”. This relays the call via
the Signal servers, which in turn also skews the position of the caller. IP-Tracker showed that the user was
calling from Groningen in the Netherlands.
9
Figure 6: Wireshark Capture VPN & Proxy Call
With both VPN and call relay activated, we get the result displayed in figure 6. In this case, the call was
made from Leuven in Belgium, the caller‘s VPN location was set to Norway, while the location deducted from
Wireshark and IP-tracker showed that the call came from Finland.
Our testing shows that there is some correlation between the actual position, and skewed position of the
user when relaying their call through Signal. Even though it is very rough, it still reveals which part of the
world the user is located. It is reasonable for Signal to do this for latency purposes, as this was already the
reason behind the peer-to-peer call implementation [12]. However, to be completely sure that their position is
different, a user must utilize a VPN.
5 Recommendations
5.1 Improve Membership Privacy
An issue with Signal today is the fact that any adversary can use contact discovery to reveal if a phone number
is a registered user of the application. This can be done either by syncing the contact list stored on the device,
or by looking up a phone number manually in the ”write new message” service. Other users will also be
notified if someone in their contact list registers a new account with Signal. User’s have no intervenability
in this matter and all users are discoverable through this feature. It is clear that Signal has intentionally
sacrificed some privacy for practicality or ease of use. However, this can be a deal breaker for someone who
wants to send messages in full confidentiality.
10
separate leaky bucket structure. This implementation would allow Signal to set more stringent rate limits on
contact discovery with the entire data set and a more lenient limit on discovery of the most recently registered
Signal users. [15]
• Identifiers: Users can create usernames which will be paired and displayed along with a random nu-
meric identifier. The random number allows multiple users to have the same username. These identifiers
will be hashed and not stored in plain text on server.
• Storage: Server stores a map of 16 Byte UUIDs and encrypted usernames. The usernames are
encrypted using an entropy, a 32 Byte string of random characters. The encryption ensures that the
service is unable to track of what links correspond to a username [25].
• Contact: Users will be able to hide their phone number from others, as well as hide their number from
contact discovery. Which would only make them searchable from username [26].
The messaging app Briar omitted the phone number entirely, by replacing it by a QR code or link that
need to be exchanged by both parties. While this implementation is very secure, it adds much ’friction’ to the
on boarding process of the service, hampering the growth of the network. This does not align with Signal’s
goal of bringing private communication to the masses. [27]
Telegram has a feature to hide your phone number from other users. Additionally, it allows this in a granular
way, with the ability to block or allow certain users to see your phone number. In 2022, Telegram implemented
the possibility to sign up using an ”anonymous” phone number which are tradeable on a blockchain platform
’Fragment’.
6 Conclusion
In this work, we analyzed the privacy impact of Signal for Android, focusing on the use of phone numbers and
contact discovery.
Phone numbers are used as a means for registration and identification. While very convenient, phone
numbers can potentially be personally identifiable. As any contact between two users requires the exchange
of phone numbers, this is a concern for some. Other apps, like Briar only allow you to contact the other party
when both parties have scanned a QR code or have a link from the other user. While secure, one immediately
recognises the friction that arises from such a feature. Implementing this would hamper the scaling of the
Signal network. In a trade off, Signal is testing the implementation of usernames as an identification method.
11
We studied in detail the contact discovery feature of Signal. It enables the user to import their entire
social graph. We have showed, however, that such a contact discovery feature allows for large scale crawling
of the service, uncovering the users of the service en masse. Furthermore, with the specific implementation of
the feature, potential attack vectors may arise. Given these concerns, other services have omitted this feature
entirely. Once again, in light of convenience and growing the userbase, Signal has opted to keep this feature.
While Signal aims to provide an end to end encrypted service and a privacy first approach, security features
often collide with the service’s useability and convenience. With the competition Signal faces, the foundation
may make these compromises.
12
References
[1] Signal, “Signal features.” [Online]. Available: https://support.signal.org/hc/en-us/sections/
360001602792-Signal-Messenger-Features
[2] A. G. Jacob Appelbaum, “Inside the nsa´s war on internet security,” https://www.spiegel.de/
international/germany/inside-the-nsa-s-war-on-internet-security-a-1010361.html, 2014.
[3] Signal, “Signal terms & privacy policy.” [Online]. Available: https://signal.org/legal/
[4] ——. (2017) Encrypted profiles for signal now in public beta. [Online]. Available: https:
//signal.org/blog/signal-profiles-beta/
[5] ——, “Technology preview: Private contact discovery for signal,” 2017. [Online]. Available:
https://signal.org/blog/private-contact-discovery/
[6] ——, “Grand jury subpoena for signal user data, central district of california,” 2021. [Online]. Available:
https://signal.org/bigbrother/central-california-grand-jury/
[7] ——, “Storage management for signal android.” [Online]. Available: https://signal.org/blog/
storage-management-for-android/
[8] ——, “Backup and restore messages.” [Online]. Available: https://support.signal.org/hc/en-us/articles/
360007059752-Backup-and-Restore-Messages
[9] ——, “Signal-app documentation,” 2023. [Online]. Available: https://signal.org/docs/
[10] ——, “Signal and the general data protection regulation (gdpr).” [Online]. Available: https://support.
signal.org/hc/en-us/articles/360007059412-Signal-and-the-General-Data-Protection-Regulation-GDPR-
[11] LINDDUN, “Privacy threat types.” [Online]. Available: https://linddun.org/threat-types/
[12] Signal, “Video calls for signal out of beta,” 2017. [Online]. Available: https://signal.org/blog/
signal-video-calls/
[13] J. Lapienytė, “Whatsapp data leaked - 500 million user records for sale online.” [Online]. Available:
https://cybernews.com/news/whatsapp-data-leak/
[14] Signal, “Signal-app github repository.” [Online]. Available: https://github.com/signalapp/libsignal
[15] C. Hagen, C. Weinert, C. Sendner, A. Dmitrienko, and T. Schneider, “All the Numbers are US: Large-
scale Abuse of Contact Discovery in Mobile Messengers,” in Proceedings 2021 Network and Distributed
System Security Symposium. Virtual: Internet Society, 2021.
[16] M. Marx, E. Zimmer, T. Mueller, M. Blochberger, and H. Federrath, “Hashing of personally identifiable
information is not sufficient,” 2018.
[17] “Technology preview: Private contact discovery for Signal,” Sep. 2017.
[18] D. Moghimi, “Downfall: Exploiting Speculative Data Gathering.”
[19] “Software Guard Extensions - Wikipedia — en.wikipedia.org,” https://en.wikipedia.org/wiki/Software
Guard Extensions.
[20] UK Parliament, “Online safety act 2023 - parliamentary bills - uk parliament,” Oct 2023. [Online].
Available: https://bills.parliament.uk/bills/3137
[21] E. Woollacott, “Signal threatens to pull out of uk,” 2023. [Online]. Available: https:
//cybernews.com/news/signal-to-leave-uk/
[22] “IP tracker.” [Online]. Available: http://ip-tracker.org
[23] J.-H. Hoepman, “Mutual contact discovery,” 05 2023. [Online]. Available: https://www.cs.ru.nl/∼jhh/
publications/mutual-contact-discovery.pdf
[24] “Public Username Testing (Staging Environment),” Nov. 2023. [Online]. Available: https:
//community.signalusers.org/t/public-username-testing-staging-environment/56866
13
[25] “Signal forum - username.” [Online]. Available: https://community.signalusers.org/t/
usernames-in-signal/9157/1300
14
A Appendices
A.1 Signal Code snippet
SignalServiceAccountManager.java (line 367:419)
public CdsiV2Service . Response g e t R e g i s t e r e d U s e r s W i t h C d s i ( Set < String >
previousE164s ,
Set < String >
newE164s ,
Map < ServiceId ,
ProfileKey >
serviceIds ,
boolean requireAcis ,
Optional < byte [] >
token ,
String mrEnclave ,
Long timeoutMs ,
Consumer < byte [] >
tokenSaver )
throws IOException
{
CdsiAuthResponse auth = p ushSer viceSo cket . getCdsiAuth () ;
CdsiV2Service service = new CdsiV2Service ( configuration , mrEnclave ) ;
CdsiV2Service . Request request = new CdsiV2Service . Request ( previousE164s ,
newE164s , serviceIds , requireAcis , token ) ;
Single < ServiceResponse < CdsiV2Service . Response > > single =
service . ge tRe gi st er ed Us er s ( auth . getUsername () , auth . getPassword () ,
request , tokenSaver ) ;
15
throw ( IOException ) serviceResponse . g e t Ap p l ic a t io n E rr o r () . get () ;
} else {
throw new IOException ( serviceResponse . g e t Ap p l ic a t io n E rr o r () . get () ) ;
}
} else if ( serviceResponse . getEx ecutio nError () . isPresent () ) {
throw new IOException ( serviceResponse . getEx ecutio nError () . get () ) ;
} else {
throw new IOException ( " Missing ␣ result ! " ) ;
}
}
The code above is a snippet from the Android implementation of Signal. You can find the complete
implementation on Signal’s GitHub1 .
1 https://github.com/signalapp/Signal-Android
16
A.2 Proposed unit test
CdsExploitTest.java
/*
* Copyright 2023 Signal Messenger , LLC
* SPDX - License - Identifier : AGPL -3.0 - only
*/
/* *
* Generates a set of random E164 phone numbers tailored for US format .
* If we want the test to fail consequently , we have to add number of a
user we already know is registered .
* We have NOT done this , as we don ’t want to disclose a known registered
user .
* @param count the number of phone numbers to generate
* @return a set of generated E164 phone numbers
*/
private static Set < String > g en e r at e R an d o mE 1 6 4 s ( int count ) {
Random rand = new Random () ;
Set < String > e164s = new HashSet < >() ;
17
sb . append (( rand . nextInt (9000000) + 1000000) ) ;
// Convert to string
String e164 = sb . toString () ;
/* *
* Tests the CDS ( Contact Discovery Service ) functionality .
* @throws IOException if an I / O error occurs
*/
@Test
public void testCds () throws IOException {
/*
The test works in the following way :
1 Assume a valid S i g n a l S e r v i c e C o n f i g u r a t i o n
2 Assume a valid PushS ervice Socket and obtain valid authorization token
3 Generate a CdsiV2Service to connect to the secure enclave
4 Construct a CdsiV2Service . Request with synthetic phone numbers and send
it to the Contact Discovery Service
5 Parse response Contact Discovery Service
6 Check results
*/
S i g n a l S e r v i c e C o n f i g u r a t i o n configuration ;
Push Servic eSock et pus hServi ceSock et ;
18
Single < ServiceResponse < CdsiV2Service . Response > > single =
service . ge tRe gi st er ed Us er s ( auth . getUsername () , auth . getPassword () ,
request , null ) ;
// Preset variables
Long timeoutMs = null ; // Set to null to ignore time restrictions , can
be set to an arbitrary time to streamline calls to the service
19
} else if ( serviceResponse . getEx ecutio nError () . isPresent () ) {
throw new IOException ( serviceResponse . getEx ecutio nError () . get () ) ;
} else {
throw new IOException ( " Missing ␣ result ! " ) ;
}
20
A.3 Scenario tests
A.3.1 Arbitrary contact discovery
Test description: The test checks whether an Android user can add an arbitrary phone number in their contact
list and verify if that user is a Signal user or not.
Preconditions: The user has given permission for the Signal Application to retrieve contact information.
21