SECURE MULTIMEDIA COMMUNICATION IN SMART DEVICES
REINFORCED BY USING ONE-TIME KEYS
by
¨OMER MERT CANDAN
Submitted to the Graduate School of Engineering and Natural Sciences in partial fulfillment of
the requirements for the degree of Master of Science
Sabancı University
July 2017
c ¨Omer Mert Candan 2017
All Rights Reserved
ABSTRACT
SECURE MULTIMEDIA COMMUNICATION IN SMART DEVICES
REINFORCED BY USING ONE-TIME KEYS
¨OMER MERT CANDAN M.Sc. Thesis, July 2017 Supervisor: Prof. Albert Levi Co-supervisor: Asst. Prof. Cengiz To˘gay
Keywords: one-time key, multimedia communication, smart card, hash chain, security
Recently, smart devices have become more and more prevalent in the daily life. The spread of these devices introduced various use cases; however, communication has al- ways been their primary functionality. With the development of WebRTC (Web Real- Time Communication) and the availability of this technology on smart devices, applica- tions offering real-time multimedia communication features will become more pervasive.
Though WebRTC presents a promising set of standards and interfaces for the task of car-
rying data from one end to another, there are security issues that are left in the hands of
the application developers. In this thesis, we aim to achieve secure multimedia commu-
nication by tackling the key generation and distribution issue of WebRTC platform using
a smart card for secure storage and operations. We tested different cryptographic algo-
rithms on smart cards, and resultantly we designed a mechanism based on hash chains.
This mechanism allowed synchronous generation of keys at both sides. The mechanism
was implemented and tested on different brands of Java Cards. The results of the tests
indicate that it is possible to produce a key under one-second time. In addition, the re-
sults were analyzed to optimize generation times of particular keys by adjusting chain
length parameter of the mechanism. Consequently, the key generation method was inte-
grated into Media Security Platform of Netas¸ Telecommunications A.S¸., which is based
on WebRTC. The integration was performed under the guidance of a signaling scheme
drafted for the message traffic for the key agreement. In conclusion, the successful in-
tegration and better results indicate an improvement over a previously used public key
system.
¨OZET
Akıllı Cihazlarda Tek Kullanımlık Anahatar ile G¨uc¸lendirilmis¸
G¨uvenli C¸oklu Ortam ˙Iletis¸imi
¨OMER MERT CANDAN Master Tezi, Temmuz 2017 Danıs¸man: Prof. Dr. Albert Levi Es¸-danıs¸man: Asst. Cengiz To˘gay
Anahtar S¨ozc¨ukler: tek kullanımlık anahatar, multimedya iletis¸im, akıllı kart, ¨ozet zinciri, g¨uvenlik
Son yıllarda akıllı cihazlar g¨unl¨uk hayatta ¨onemli bir yer edindi. Bu cihazların yaygınlas¸ması,
onlara birc¸ok yeni is¸lev kazandırmakla beraber, yine de temel amac¸ları iletis¸im olarak
kaldı. WebRTC (˙Internet Tabanlı Gerc¸ek Zamanlı ˙Iletis¸im) teknolojisinin ortaya c¸ıkması
ve akıllı cihazlarda kullanılabilir olması, gerc¸ek zamanlı multimedya iletis¸imine olanak
veren uygulamaların artmasına neden olacaktır. WebRTC’nin amacı uc¸tan uca bilgi tas¸ınması
ic¸in standartlar ve programcı aray¨uzleri belirlemek olsa da, is¸in g¨uvenlik kısmı uygu-
lama gelis¸tiricilere bırakılmıs¸tır. Bu tezde, akıllı kartların sa˘gladı˘gı g¨uvenli depolama
ve is¸lem ¨ozelliklerinin yardımı ile, WebRTC ic¸in g¨uvenli anahtar ¨uretilmesi ve da˘gıtımı
sorunları ele alınarak g¨uvenli c¸oklu ortam iletis¸imi kurulumu hedeflenmektedir. De˘gis¸ik
kriptografik algoritmalar akıllı kartlar ¨uzerinde denenmis¸ ve sonuc¸ olarak ¨ozet zinciri
¨uzerine bir y¨ontem kullanılmasina karar verilmis¸tir. Tasarlanan mekanizma de˘gis¸ik marka
Java kartlar ¨uzerinde calıs¸tırılmıs¸ ve testlerin sonucları 1 saniyenin altında bir s¨urede
anahtar ¨uretiminin m¨umk¨un oldu˘gunu g¨ostermis¸tir. Buna ek olarak, ¨ozet zinciri uzunlu˘gu
de˘gis¸tirilerek c¸es¸itli analizler yapılmıs¸ ve bunun sonucunda hedeflenen bir anahtarın m¨umk¨un
olan en iyi s¨urede ¨uretilebilmesi ic¸in gerekli olan zincir uzunlukları hesaplanmıs¸tır. De-
vamında, anahtar ¨uretim mekanizmasının WebRTC teknolojisine dayanan Medya G¨uvenlik
Platformu ile entegrasyonuna yer verilmis¸tir. Mekanizmanın sisteme uyumu ic¸in tasar-
lanan sinyalles¸me trafi˘gi g¨oz ¨on¨une alınarak, entegrasyon bas¸arı ile tamamlanmıs¸tır. Sonuc¸lar,
daha ¨once kullanılan ac¸ık anahtarlı sisteme g¨ore daha iyi performans alındı˘gına is¸aret et-
mektedir.
dedicated to everyone who’ve been patient with me,
especially my family
ACKNOWLEDGMENTS
Special thanks to Prof. Albert Levi, my advisor and a major contributor of this thesis.
I am truly grateful for his endless guidance and sincere attention.
I also thank my co-supervisor Asst. Prof. Cengiz To˘gay for his contributions and support along the way.
I learned a great deal from the lectures of Assoc. Prof. Selim Balcısoy, Asst. Prof.
Kamer Kaya and Prof. Dr. Erkay Savas¸, and thank them for participating in my defense jury.
The project under which this thesis has been produced has been supported by T.C. Min-
istry of Science, Industry and Technology under San-Tez program grant STZ.0805.2014
(later the project has been taken over by T ¨UB˙ITAK TEYDEB grant 112D032).
TABLE OF CONTENTS
1 Introduction 1
2 Background 4
2.1 WebRTC (Web Real-Time Communication) . . . . 4
2.2 Java Card . . . . 6
2.3 Cryptographic Hash Functions . . . . 8
2.3.1 Preimage Resistance . . . . 9
2.3.2 Second Preimage Resistance . . . . 9
2.3.3 Collision Resistance . . . 10
2.4 HMAC . . . 10
2.5 One-Time Password . . . 11
2.5.1 HOTP . . . 11
2.5.2 TOTP . . . 12
2.6 Hash Chain . . . 12
3 Proposed Method 15 3.1 Introduction . . . 15
3.2 Proposed Structure . . . 18
3.3 Call Establishment Protocol . . . 20
3.3.1 Possible Scenarios During Key Establishment . . . 22
3.3.2 Distribution of Seed Values into Smart Cards . . . 24
3.4 Integration with Media Security Platform . . . 24
3.4.1 Pre-integration Preparation Work . . . 25
3.4.2 The Integration . . . 30
4 Performance Evaluation 36 4.1 Key Generation Timings . . . 36
4.2 Calculating the Optimal Chain Length for a Target Key . . . 38
4.3 Post-integration Timings . . . 40
4.4 Memory Usage on Java Card . . . 42
5 Conclusion 43
LIST OF TABLES
3.1 Unit Times on Different Cards (ms) . . . 16
3.2 Error Codes of the Protocol . . . 23
4.1 The Optimal Chain Lengths for Selected Keys . . . 40
4.2 Tests with MSP Application Using SHA-1 in Netas¸’s intranetwork . . . . 41
4.3 Tests with MSP Application Using SHA-256 in Netas¸’s intranetwork . . . 41
4.4 Tests with MSP Application Using SHA-256 outside Netas¸ network . . . 41
4.5 Memory Usage of Applets on Java Card . . . 42
LIST OF FIGURES
2.1 Key Agreement in WebRTC . . . . 5
2.2 Overview of Public Key Setting in Media Security Platform . . . . 6
2.3 Smart Card Chip . . . . 7
2.4 Java Card Architecture (taken from [9]) . . . . 8
2.5 Preimage Resistance . . . . 9
2.6 Second Preimage Resistance . . . . 9
2.7 Collision Resistance . . . 10
2.8 Lamport’s Password Authentication Scheme . . . 13
3.1 Hash Chain Tests Using SHA-1 . . . 17
3.2 Hash Chain Tests Using SHA-256 . . . 17
3.3 Hash Chaining MS1 . . . 19
3.4 Hash Chaining MS2 . . . 19
3.5 Second Phase of the Mechanism . . . 19
3.6 Two Way Hash Chain Mechanism . . . 20
3.7 Signalling Protocol for Media Security Platform. . . 21
3.8 Test Application on Android . . . 26
3.9 Result of a Test Run on Android . . . 27
3.10 SHA1 Chain Length with Android . . . 28
3.11 SHA256 Chain Length with Android . . . 28
3.12 JavaCardApi Class . . . 29
3.13 JavaCardKey Class . . . 29
3.14 JavaCardApiIml Class . . . 30
3.15 API Calls After Integration with the Media Security Platform . . . 31
3.16 The Caller Initiating in Android Application . . . 32
3.17 Caller Sends the Call Request . . . 33
3.18 The Callee’s Screen After Receiving the Call Request . . . 33
3.19 The Call is Accepted . . . 34
3.20 The Call has Started on Caller’s Application . . . 34
3.21 The Call has Started on Callee’s Application . . . 35
4.1 Tests with Different Chain Lengths (ms) . . . 37
4.2 Generation Time of Different Keys (ms) . . . 39
Chapter 1 Introduction
The technology of mobile devices has shown a great deal of improvement over the past decade. While this fast paced trend continued, the devices became more powerful and smaller in size. The transformation from brick-like phones to pocket sized phones, from room-sized computers to handheld tablets led these devices invade daily life. All the mobile devices, ranging from a smart watch to a portable personal computer have one aspect in common, that is Internet connectivity. The major demand of Internet access provoked the rapid development of the infrastructure of Internet as well as the services that rely on it. One of these services, namely WebRTC (Web Real-Time Communication), aims to allow audio and video communication over the Internet [23]. Since the Internet is publicly accessible and therefore insecure, WebRTC is designed to provide security by end-to-end encryption. What WebRTC does not provide is a standard for generation and distribution of the keys required for the security of the communication.
Media Security Platform (MSP) developed by Netas¸ Telecommunication A.S¸., tack-
les the problem of key generation for multimedia communication in WebRTC environ-
ment. The platform utilizes a public key cryptography based setting, each participating
user having a public/private key pair. The mobile environment is not the ideal place to
store private keys [20]; therefore they are stored in smart cards which also provide secure
cryptographic functions. In the existing MSP of Netas¸, before establishing a secure com-
munication channel, parties generate a session key and encrypt it with the public key of
the other party. The encrypted key is sent after being signed with the sender’s private key.
Four modular exponentiation operations are needed in this setup, two of them performed in the smart card environment, which slows the initiation process before call. Our main purpose is to devise a mechanism that will shorten the time required by the initial signal- ing process. The proposed scheme will allow remote users to create a unique and common key in a secure and an efficient way. To eliminate the cost of communication spent for key exchange, we came up with a structure based on the idea of hash chains. The users will create their keys by applying hash functions in a chain-wise manner to some initial data. Since this is a deterministic process, applying hash chain on the same data would yield the same result for different users. In order to generate the same key at both ends, both parties need to share a secret information beforehand. The security of the protocol we design depends solely on the shared secret, namely the “seed”. Therefore, the seeds will be stored inside smart cards and any computations on them will also be performed in the card. The whole key generation operation begins and ends inside the card, only the result is visible at the end of the operation. This way, the seeds or the intermediate values generated from the seeds never leave the card. The possible security threats existing in the mobile environment are circumvented with this approach.
We have set out to design a new key generation system that produces one-time keys
in a type of smart card called Java Card. Java Cards provide secure storage and atomic
transactions on a Java-based environment [3]. The product of our design had to meet strict
security requirements. One of these requirements was the security of the future and past
keys generated by the users of the platform. We had to keep in mind that, in the event of
a key compromise, none of the past keys should be revealed. In addition, when a key is
captured, our mechanism must keep on producing consequent keys not guessable by any
means. The other requirement was that two separate parties must have been able to pro-
duce the same key without exchange of information. Another requirement was to produce
these keys in a timely manner. To achieve these requirements, we knew that the involving
parties should share some information ahead of time. However, this shared information
is the most vulnerable part of the whole setting. Therefore, we have made the decision
to choose an external device that will store this information, process this information and display an output when needed. The choice of smart cards, especially Java Cards for our case brought upon its challenges. We have noticed that the smart card platform is indeed very limited in the aspect of memory and computing power. These restrictions made us realize that we are not free in our decisions while we are designing our system. As a result of this, we have moved to perform tests with different cryptographic algorithms.
As soon as we received the results of our tests, we observed significant performance dis- parity between them. Some of the algorithms have performed considerably slow or did not work at all on the smart cards. After a brief analysis of these preliminary results, we determined the main component of our design by the process of elimination. Therefore, we attained to design a scheme that does not only work in theory, but is feasible, im- plemented and tested on real devices. Our main contribution can be attained to the fact that our mechanism is designed carefully to perform well in the current restricted state of smart card technology. We have performed necessary tests on smart cards and shown that the mechanism does work successfully under one-second threshold, which is acceptable in the context of real-time applications.
The rest of this thesis is organized as follows. In Chapter 2, we provide some back-
ground information necessary for understanding the basis of the work. In Chapter 3, we
explain our design and how it works in detail. The reasons behind the choices made in
the design will be revealed. We will provide steps for generating a single key. Chapter 4
consists of the performance evaluation of the provided scheme. We disclose the tests and
their results. In Chapter 5, we provide a conclusion to wrap up.
Chapter 2 Background
2.1 WebRTC (Web Real-Time Communication)
WebRTC (Web Real-Time Communication) is a collection of APIs for modern browsers,
such as Google Chrome and Mozilla Firefox, that enable peer-to-peer Real-Time Commu-
nication (RTC) without plugins or other requirements [22]. The components of WebRTC
technology provide infrastructure for high quality audio, video and other data transfer be-
tween browsers or any application that implement the WebRTC API. The aim of WebRTC
project is to provide a set of standards that will define the future of web based communica-
tion. WebRTC is an open source project, which makes it an important move for web based
technology in a sense that relieves developers from relying on proprietary solutions. The
media transfer between clients happens in a peer-to-peer fashion; however, this transfer
of information is preceded by an initiation process that requires a server in between. With
the help of an intermediary server, the clients have to exchange information to establish
the channel with the help of Session Description Protocol (SDP) [8]. These initialization
events are part of the signaling process which is designed to overcome the difficulties in-
troduced by Network Address Translation (NAT) [19]. Translation of dynamic addresses
to private addresses and vice versa puts a hold on the possibility of creating an immedi-
ate peer-to-peer connection[1]. Interactive Connectivity Establishment (ICE) framework
comes into action at this point; it helps to initialize the connection by trying out different
connection methods, when the channel cannot be established with convenience [18]. The key agreement part of the signaling phase is relevant for the scope of our work.
Figure 2.1: Key Agreement in WebRTC
In Netas¸’s Media Security Platform, key agreement happens at the signaling phase,
shown in Figure 2.1. The key generated by the caller’s smart card is encrypted with the
public key of the other party and transferred to the demanding application. The encrypted
key is signed by the application and sent to the intermediary Media Security Server, which
then transfers the key to the receiver of the call. The callee verifies the signature and
passes the encrypted key to the smart card for decryption. The plain key returned from the
smart card is used to establish a secure multimedia communication channel. An overview
of this public key based scheme is shown in Figure 2.2.
Figure 2.2: Overview of Public Key Setting in Media Security Platform
2.2 Java Card
Smart cards are widely used in areas such as banking, security systems, personal identification and so on. A smart card is a plastic card that houses a chip containing a Central Processing Unit (CPU), Read-Only Memory (ROM), Electrically Erasable Pro- grammable Read-Only Memory (EEPROM), Random Access Memory (RAM) and a unit for input/output operations, simply presented in Figure 2.3. For the time being, smart cards carry approximately 1KB of RAM and 64KBs of flash memory space (EEPROM).
The ROM section of the smart card is used to store the operating system of the smart card and is not accessible by developers. The contents of RAM is lost when the smart card is unpowered, while EEPROM provides persistent but very slow storage compared to RAM.
Smart cards are operated by a card reader or sometimes called Card Acceptance Device (CAD) that is connected to a computer, a terminal or as in our case a smart device. The card operators provide power and clock signals to the chip embedded in the card.
Smart cards are assumed to securely store its contents, however, this assumption may not always hold true. While current smart cards are marketed with the promise of tamper- resistance, there have been various tampering techniques introduced in the past [10]. In our case, the smart card environment is a far better alternative to implement our key generation mechanism into than the operating system environment of a smart device.
Java Card is a specific type of smart card that utilizes a restricted subset of Java Envi-
ronment. Java Cards are initialized in the manufacturing process with Java Card Runtime
Figure 2.3: Smart Card Chip
Environment (JCRE) written in their ROMs. EEPROM stores the applications on Java
Card - or applets - and static data related to those applets, while the RAM is used by the
applets as temporary storage during runtime. JCRE holds Java Card Virtual Machine and
Java Card API on top of which the applets operate, as illustrated in Figure 2.4. Contrary
to the earlier smart card applications, Java Card applets work on any card that runs JCRE,
independent of the brand of the chip. A Java Card can hold multiple applets and provides
a firewall to restrict access between said applets.
Figure 2.4: Java Card Architecture (taken from [9])
2.3 Cryptographic Hash Functions
A hash function produces a fixed size of output, also called hash value or digest,
from inputs of any length. Hash functions are very fast and utilized for various purposes
in security. An example usage might be to produce the hash of a long document and
securely store this hash for future verification that the document is not modified. If there
is a modification in the document, then applying the hash function on the modified version
will create a digest that does not match with the original hash. Since the input space is
often larger than the output space, the outputs of the hash functions are not in one-to-one
correspondence with the inputs. This means that the hash function might map different
inputs to the same hash value. The case where two different inputs give the same hash
result is called a collision.
Cryptographic hash functions are a sub-type of hash functions that satisfy some se- curity properties. The security of hash functions depends on preimage resistance, second preimage resistance and collision resistance [17].
2.3.1 Preimage Resistance
From the output of the hash function, it must be difficult to find the input that produces the hash value. The hash value should not reveal any information about the input.
Figure 2.5: Preimage Resistance
2.3.2 Second Preimage Resistance
For an input and its hash, it must be difficult to find a different input that produces the same hash value.
Figure 2.6: Second Preimage Resistance
2.3.3 Collision Resistance
It must be difficult to find any input pairs that produce the same hash output.
Figure 2.7: Collision Resistance
2.4 HMAC
HMAC (Hash-based Message Authentication Code) is a cryptographic mechanism providing integrity check by validating messages using a secret key [11]. It involves a cryptographic hash function and a secret key. The hash function should be an iterative function that operates on blocks, such as a hash function from SHA family [7][6]. The name of the HMAC scheme is correlated with the underlying hash function, for example if SHA-256 is being used the scheme is called HMAC-SHA-256. In addition, the security of HMAC depends heavily on the quality of the hash function. With this in mind, crypto- graphically secure hash functions such as SHA-256 and beyond are often the choice for HMAC operations. Calculation of HMAC of message M using key K and hash function h is as follows.
HM AC(K, M ) = h(K opad kh(K ipad kM)) (2.1)
HMAC consists of two hash operations involving the message, the key and constant
values called ipad and opad. Let us assume that the hash function operates on blocks of
size b and produces a hash output of size n. The ipad and opad constants are 64 bytes
long byte strings and are repetition of the bytes 0x36 and 0x5C, respectively. As the first
step of HMAC process, if needed, the key is padded with zeroes until it is of length b.
Padded key is XOR’ed with the ipad, then concatenated with the message which forms the inner part. The first hash operation is applied on this inner part. As the next step, the padded key is XOR’ed with the opad, then concatenated with the digest coming from the previous step to form the outer part. The second hash operation is applied on the outer part to produce the result of the HMAC operation as seen in Equation 2.1.
2.5 One-Time Password
As its name suggests, one-time password algorithms are designed to produce pass- words that are supposed to be used only once. The main advantage of this scheme is to prevent attack scenarios where the adversary captures a previously used password. Imple- menting one-time password systems usually are not as straightforward as implementing a system that depends on a single (master) password. Therefore, other devices come to help in the one-time password settings in the creation of one-time passwords. This is known as two factor authentication and its security depends on not only what the user knows but also on what the user possesses. There are different algorithms to produce single use passwords. We will discuss two of them, one is based on HMAC and the other one uses the time as a source of input.
2.5.1 HOTP
HMAC-based One-Time Password Algorithm (HOTP) [13], uses a key, a counter and
HMAC-SHA-1. Obviously the key must be kept secret and should be of adequate length
which is at least 160 bits suggested in the RFC document [13]. After a run of HOTP,
the counter value is incremented. This scheme guarantees that for every iteration of the
algorithm, the outcome will be different than the previous one. By sharing a secret key, K,
and a synchronized counter, C, two remote parties can successfully generate a one-time
password as shown below.
HOT P (K, C) = T runcate(HMAC -SHA-1 (K, C)) (2.2) Let us assume that we want to have a result with d digits after the execution of HOTP algorithm. HOTP algorithm applies HMAC-SHA-1 on counter with the key, then selects specific bits of the result and shortens it to d digits as in Equation 2.2. The truncation process looks at the low-order 4 bits of the last byte of the HMAC output. This becomes the index to the bytes that will be selected again from the HMAC result. The bytes that are in the range of [index, index + 3] will make up a 32 bit number. As a final step, modulo operation is applied with modulus being 10
d, to get the result in the expected range.
2.5.2 TOTP
TOTP (Time-based One-Time Password Algorithm) is very similar to HOTP [14].
The only difference is that TOTP uses Unix time as its counter value.
T OT P = HOT P (K, T ) (2.3)
Here in equation 2.3, T is the number that represents how many time steps have been taken from a determined initial time. Assuming that the initial time is determined as T
0, and a time step is defined as X, we calculate the number of time steps in Equation 2.4 below.
T = CurrentT ime T
0X
⌫
(2.4)
2.6 Hash Chain
A hash chain is produced by applying hash operation on a given data successively.
When hash functions are chained, the result of one hash becomes the input of the upcom-
ing hash function. If we represent the hash function with h and the length of the hash
chain with L, then the hash chain F is:
h
L(m) = h...h(h(h(m))...)
| {z }
L times.