{'fraction_non_alphanumeric': 0.036049662822209616, 'fraction_numerical': 0.013928278817671898, 'mean_word_length': 4.846720707442889, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
PS-HOMO: A Protection Scheme for iOS SMS

iOS Short Message Service (SMS) transmits messages in plaintext, which would lead to potential security threats of data. It is meaningful to design a safe and effective SMS. In this paper, all iOS Security Guides are referred to and all the cryptographic algorithms in iOS data protection are analyzed. Because there is no homomorphic encryption, a library of homomorphic encryption algorithms for iOS based on RSA and Paillier is developed. Using this library, a protection scheme PS-HOMO for protecting iOS SMS data is proposed and implemented. Under the premise of ensuring the data confidentiality, PS-HOMO also has the function of ciphertext operation due to the multiplicative homomorphism of RSA and additive homomorphism of Paillier. A comprehensive performance test was performed on PS-HOMO. The results show that the performance is in line with our expectations and will not have a major impact on the original system. The security of PS-HOMO is theoretically analyzed from man-in-the-middle attack, replay attack, and traffic analysis attack. Two application scenarios of the PS-HOMO, remote anonymous voting and privacy telemedicine service are envisaged. We hope PS-HOMO would play a significant role in privacy protection.


Introduction
As the iPhone becomes part of our lives, we use it in many ways. One of ways is communicating with others by its SMS which we rely heavily on. But according to our previous research [1], we found that the iOS SMS message is plaintext transmission without any confidential protection. Thus, if an iPhone jailbreaked, the communication content will be exposed, and the privacy information will be leaked.
The privacy information on iOS SMS is under risks. Thus, it is necessary to add protection for the private data. In this paper, we referred to all the iOS Security Guides, and combed all the cryptographic algorithms used in iOS data protection. Because there is no homomorphic encryption, a library of homomorphic encryption algorithms for iOS based on RSA and Paillier is developed. Using this library, a protection scheme PS-HOMO for protecting iOS SMS data is proposed and implemented. By injecting a self-development tweak, hooking the key functions of sending and receiving messages, the functionality of iOS Message application is modified. Some tests are also designed and did, to illustrate fully its practicability. And the results show that the performance is in line with our expectations and will not have a major impact on the original system. The security of PS-HOMO is analyzed theoretically from man-in-the-middle attack, replay attack, traffic analysis attack, and the results show that PS-HOMO can be trusted. Two practical application scenarios of PS-HOMO, remote anonymous vote, private telemedicine service, are also envisaged. Extending hardware key length from 128 bits to 256 bits and embedding the AES-256 in the crypto engine correspondingly, provides higher security for data encryption. It is crypto engine that mitigates the slow operation speed and consuming more power while extending to 256 bits.
Before iOS 6, Yarrow, which includes SHA-1, are used in random number generator. In 2005, professor Wang Xiaoyun proposed a new collision search against SHA-1 [8], which reduces the complexity of the full SHA-1 collision search to 269 and destroyed the security of SHA-1 theoretically. In 2007, researchers of Google public their results [9][10], the first SHA-1 collision in practice. Owing to the unsafe SHA-1, Counter mode Deterministic Random Byte Generator (CTR_DRBG) are introduced. In the early iOS, AES-CBC was used in encryption for the files. After iOS 9, AES-XTS was introduced. In iOS 12, AES-XTS are used in most devices. In XTS, tweak keys, which are mutually independent but AES keys are same, are added. Compared to the CBC, XTS has two characteristics: One is that the same block gets different ciphertexts, and the other is that different blocks can be encrypted and decrypted independently. The results of SHA-1 are mainly used as initialization vector, so it is still in use.
A larger number of iterations has been set for the PBKDF2 (at least 10,000 times in iOS 4 [11]) by Apple, making a password attempt takes about 80 milliseconds. So, traversing all alphanumeric combinations of length 6 takes more than five and a half years. The larger number of iterations also means that the stronger the password, the stronger the exported password key.

Homomorphic Encryption Algorithms Library for iOS File System
Homomorphism is a concept in modern algebra originally. The definition of group homomorphism is as follows.
Let (G, +) and (H, * ) be groups. The map φ ∶ G → H is a homomorphism if φ(x + y) = φ(x) * φ(y) ∀ , ∈ In 1978, Ronald L. Rivest et al. first proposed the idea of homomorphic encryption which appears likely that there exist encryption functions which permit encrypted data to be operated on without preliminary decryption [12], and four possible encryption functions (RSA is one of them) are introduced in their paper. The encryption function has homomorphic if ( , are encryption and decryption functions, respectively. ⨁,⊗ are operations on plaintext and ciphertext domains, respectively. After this idea proposed, many homomorphic encryption schemes were designed by cryptologists, such as schemes in papers [13][14][15][16][17] have additive homomorphism and scheme in paper [18] has multiplicative homomorphism. Also, these schemes are applied in practice, like E-Voting [19][20], private information retrieval (PIR) [21][22], cloud computing [23][24][25][26][27] and so on. In 2005, Dan Boneh et al. proposed the first scheme [28] which has both additive and multiplicative homomorphism, and it supports any number of additions but only one multiplication.
A cryptosystem that supports arbitrary computation on ciphertexts is known as fully homomorphic encryption (FHE) [29]. In 2009, the first fully homomorphic encryption (FHE) using ideal lattices is proposed by Craig Gentry in his PhD thesis [30]. After Gentry's contribution, many cryptologists made progress on FHE. In 2010, Marten van Dijk et al. proposed a FHE over the integers [31] based on Gentry's technology. In 2010, Nigel P. Smart and Frederik Vercauteren simplified the implement of Gentry09 scheme over PKC [32]. In 2010, Craig Gentry and Shai Halevi implemented more simplification for Gentry09 scheme [33]. But due to the computational complexity, all the FHE schemes mentioned above are not practical.
Other previous researches on iOS with cryptography mainly focused on the following aspects. First, literatures [34][35] have proposed the analysis tools for misuse of cryptography in iOS applications. Second, literatures [36][37] have implemented the cryptographic algorithm simply. Third, literature [38] has implemented the cryptographic algorithm and applied it to the application developed by the author.
In 1978, Ron Rivest et al. proposed the first public key cryptosystem called RSA [39] and it widely used for secure data transmission. RSA has multiplicative homomorphism. In 1999, Paillier cryptosystem is introduced by Pascal Paillier in his paper [20]. Paillier has additive homomorphism. From the chapter 3, there are not any homomorphic encryption algorithms in iOS. Thus, in this paper, a homomorphic encryption algorithms library is developed for iOS. Due to the computational complexity and mobile computing power, it is difficult to use FHE on mobile platform. So, the Choose two large prime numbers and in secret randomly. Compute = .
( , ) is kept as the private key.

PS-HOMO: A Protection Scheme for iOSSMS Message
PS-HOMO includes users and a cloud server. Cloud server which is a third-party trusted certificate server is responsible for store and distribute certificates. It maintains a certificate list whose items are users' public key. In fact, these certificates are sent by users when users start up. When Alice wants to send a SMS message to Bob, the following steps are automatic. At a start, PS-HOMO checks the local certificate list whether stores the Bob's certificate or not. If there is, Alice sends encrypted message directly to Bob using the Bob's public key in the certificate, otherwise, Alice sends a request to the cloud server for Bob's certificate. When the cloud server receives the request, it sends the Bob's certificate to Alice with its signature. Alice receives Bob's certificate and verifies the signature using public key of cloud server (root certificate). After verification, Alice sends encrypted message to Bob, and Bob decrypts the message by his private key. The overview of PS-HOMO as Figure 1 shows.

Figure 1. The Overview of PS-HOMO.
A tweak is injected into the imagent process to implement the modification of functionality. Hook function is the main method, through the reverse engineering, by hooking functions "sendMessage:" on the sending side and "_process Received Dictionary: storage Context:" on the receiving side. GMP (GNU Multiple Precision), which is a free library for arbitrary precision arithmetic, is introduced to support the calculation of big numbers [40][41]. Two types of SMS messages, certificate message and homomorphic encryption message, and other related technologies are introduced as follows.

5.1Certificate Message
When Alice needs Bob's public key, she sends Bob's phone number to cloud server for Bob's certificate. The cloud server searches Bob's certificate and signs the information header using its private key. Then, it sends the certificate and signature to Alice. Alice verifies the signature using  6 public key (root certificate) of cloud server and extracts Bob's public key. Alice's processing of getting certificate as Figure 2 shows.

5.2Homomorphic Encryption Message
After Alice obtained Bob's public key, she can send encrypted message to Bob. First of all, Alice input text on the interface of iOS Message application; Then, encrypting timestamp and the text using Bob's public keys; What's more, adding an information header at the start of ciphertext; At last, encoding the message using Base64 for the efficient transmission. On the Bob's side, the opposite process is executed to obtain the Alice's input. As Figure 3 shows.

5.3Message Information Header
Information header which is used in two message types is designed to specify the information of a message. As table 2 shows. Message Type (4) Encryption Mode (4) Text Length (4) Phone Number (16) Timestamp (14) Reserved (2)

5.4SMS Message Encoding
For higher information transmission efficiency and reliability, Base64 is used to encode the message to be sent. According to RFC 2045 [42], 64 printable characters are chosen to represent binary data.

5.5Performance Test
In order to verify the performance of modified iOS Message application, some tests are designed. Two devices, one as user and one as cloud server, have the same parameters, and the specific information of the devices are as table 4 shows.  [43], which is a performance-analysis and testing tool, is powerful and flexible. As part of Xcode tool set, it is used for measuring the real-time usage of CPU and memory. The results of four cases, non encryption, RSA only, Paillier only, both RSA and Paillier, are listed in Figure 4 and table 5.  According to the measured data, the statistics are in reasonable intervals. Thus, the new added operations do not affect the program execution significantly.

5.5.1Time
Cost of Key Generation.Capturing the moments precisely before and after key generation operation, the time difference is the time cost of key generation. The results of three measurements for each case are shown as table 6. The target lengths of RSA and Paillier key pairs are 1024 bits and 512 bits, respectively.

5.5.3Security and Pressure
Test.Another tweak has been developed, to intercept the processed messages and log them. According to the log information, all messages are encrypted, and contents are confidential.
The group sending and extra-long message sending are also tried, to verify the tweak for iOS Message application still working under extreme conditions.

Security Analysis of PS-HOMO
PS-HOMO is a secure scheme and can against many mainstream attacks.

6.1Man-In-The-Middle (MITM) Attack
A MITM attack is an attack where the attacker secretly relays and possibly alters the communications between two parties who believe they are directly communicating with each other [44]. In PS-HOMO, the existence of third-party trusted certificate server can resist the MITM attack. Certificate server is root trust, so it is trusted by all users. Alice trusts Bob's certificate from cloud server, for she can verify signature of cloud server and confirm that no any other attacker tampered with it in the middle. Alice obtains correct Bob's public keys.

6.2Replay Attack
A replay attack (a.k.a. playback attack) is a form of network attack in which a valid data transmission is maliciously or fraudulently repeated or delayed [45]. In PS-HOMO, timestamp is used to prevent from replay attack. For preventing timestamps from being tampered with, in certificate message, timestamp is set in information header which cloud server signs. Alice verifies the signature and checks the timestamp. In homomorphic encryption message, timestamp is set in information header and ciphertext. Bob compares the two timestamps after decrypting the ciphertext.

6.3Traffic Analysis Attack
Due to the encryption operation, the ciphertext is fully confused and spread. If an attacker intercepts the message, he can't obtain communication contents.

Applications of PS-HOMO
PS-HOMO is secure communication and has homomorphic operation capability. Thus, it can be applied in some scenarios, if specific feature plugins are developed and inserted into PS-HOMO. Some application scenarios are listed.

7.1Remote Anonymous Voting
When you are on a business trip, your boss called you to vote for something, but you don't want to let him know your vote. It is anonymous and remote for you to using PS-HOMO. Deciding your vote and encrypting by homomorphic encryption. Then, message which carries your vote arrives at your boss phone. After ciphertext calculation and decryption, remote anonymous voting was operated.  10

7.2Privacy Telemedicine Service
With the help of PS-HOMO, it is convenient to implement privacy telemedicine service. Remote computing service provider receives the encrypted medical record data from client. Then, the data are processed by service provider without decryption because of homomorphic encryption technology. The processing results in encryption state are sent back to client. Client decrypts and reads them.

Conclusion
According to our previous research, the iOS SMS message is plaintext transmission without any confidential protection. This puts private information at risks. Thus, we referred to all the Apple security white books and sorted all cryptographic algorithms out. There is no any homomorphic encryption algorithm in iOS. So, a library of homomorphic encryption algorithms is developed for iOS SMS data based on RSA and Paillier. Then, using this library, a protection scheme PS-HOMO for iOS SMS is proposed and implemented. After injecting a self-development tweak, the functionality of iOS SMS is modified. Some performance tests are designed and did. The results show it has effect and in line with our expectations. The security of PS-HOMO is also theoretically analyzed from man-in-themiddle attack, replay attack, traffic analysis attack, and the results show that PS-HOMO can be trusted. Two practical application scenarios of PS-HOMO, remote anonymous vote, private telemedicine service, are also envisaged. So, PS-HOMO is practical and we wish it would play a significant role in iOS SMS privacy information protection.