Skype Protocol

From Wikipedia, the free encyclopedia

Skype
Skype logo
Image:Skype windows.png
Skype on Windows XP
Maintainer: Skype Limited
Stable release: 3.1.0.152 (Windows),
1.3.0.53 (Linux),
2.5.0.85 (Mac OS X),
2.1.0.66 (Pocket PC)
 (March 28, 2007) [+/-]
Preview release: 3.2.0.63. (Windows)  (April 4 2007) [+/-]
OS: Cross-platform
Use: P2P/VoIP/instant messaging/
video call/videophone
License: Freeware
Website: www.skype.com

Skype is a proprietary Internet telephony (VoIP) network. The protocol is has not been made publicly available by Skype and official applications using the protocol are closed-source. Numerous attempts to study and/or reverse engineer the protocol to allow unofficial clients to use Skype have been undertaken.

Contents

[edit] Protocol

A Skype network is a peer-to-peer network with three main entities: supernodes, ordinary nodes and the login server. It is an overlay network: each client builds and refreshes a list of reachable nodes known as the host cache. The host cache contains IP address and port numbers of supernodes. Communication is encrypted using RC4; the method used does not provide any privacy but instead merely obfuscates the traffic.

Supernodes relay communications to other clients behind a firewall. Any skype client can become a supernode if it has good bandwidth, no firewall and adequate processing power. Supernodes are grouped into slots (9-10 supernodes). Slots are grouped into blocks (8 slots).

[edit] Preliminaries

Abbreviations that are used:

  • SN: Skype network
  • SC: Skype client
  • HC: host cache

[edit] Skype client

The main functions of a Skype client are:

  • login
  • user search
  • start and end calls
  • media transfer
  • presence messages
Reverse engineered Chinese program (left) in conversation with the official Skype client (right).[1]
Reverse engineered Chinese program (left) in conversation with the official Skype client (right).[1]

[edit] Login

A Skype client authenticates the user with the login server, advertises its presence to other peers, determines the type of NAT and firewall it is behind and discovers nodes that have public IP addresses.

To connect to the Skype network, the host cache must contain a valid entry. A TCP connection must be established (i.e. to a supernode) otherwise the login will fail.

 1.  start
 2.  send UDP packet(s) to HC
 3.  if no response within 5 seconds then
 4.    attempt TCP connection with HC
 5.    if not connected then
 6.      attempt TCP connection with HC on port 80 (HTTP)
 7.      if not connected then
 8.        attempt TCP connection with HC on port 443 (HTTPS)
 9.        if not connected then
10.          attempts++
11.          if attempts==5 then 
12.            fail
13.          else
14.            wait 6 seconds
15.            goto step 2
16.  Success

After a Skype client is connected it must authenticate the username and password with the Skype login server. There are many different Skype login servers using different ports. An obfuscated list of servers is hardcoded in the Skype executable.

On each login session, Skype generates a session key from 192 random bits. The session key is encrypted with the hard-coded login server's 1536-bit RSA key to form an encrypted session key. Skype also generate a 1024-bit private/public RSA key pair. A MD5 hash of a concatenation of the user name, constant string ("\nSkyper\n") and password is used as a shared secret with the login server. The plain session key is hashed into a 256-bit AES key that is used to encrypt the session's public RSA key and the shared secret. The encrypted session key and the AES encrypted value are sent to the login server.

On the login server side, The plain session key is obtained by decrypting the encrypted session key using the login server's private RSA key. The plain session key is then used to decrypt the session's public RSA key and the shared secret. If the shared secret match, the login server will sign the user's public RSA key with its private key. The signed data is dispatched to the super nodes.

Upon searching for a buddy, a super node will return the buddy's public key signed by Skype. The SC will authenticate the buddy and agree on a session key by using the mentioned RSA key.

[edit] UDP

UDP packets:

IP
UDP
Skype SoF
Skype Crypted Data

The Start of Frame (SoF) consists of:

  1. frame ID number (2 bytes)
  2. payload type (1 byte)
    • obfuscated payload
    • Ack/NAck packet
    • payload forwarding packet
    • payload resending packet
    • other

[edit] Obfuscation Layer

The RC4 encryption algorithm is used to obfuscate the payload of datagrams.

  1. The CRC32 of public source and destination IP, Skype's packet ID are taken
  2. Skype obfuscation layer's initialization vector (IV).

The XOR of these two 32 bit values is transformed to a 80-byte RC4 key using an unknown key engine.

A notable misuse of RC4 in skype can be found on TCP streams (UDP is unaffected). The first 14 bytes (10 of which are known) are xored with the RC4 stream. Then, the cipher is reinitialized to encrypt the rest of the TCP stream.

[edit] TCP

TCP packets:

TCP
Skype Init TCP packet

The Skype Init TCP packet contains

  • the seed (4 bytes)
  • init_str string 00 01 00 00 01 00 00 00 01/03

[edit] Low-level Datagrams

Almost all traffic is ciphered. Each command has its parameters appended in an object list. The object list can be compressed.

                                 / Object List     ... -|
        Enc      -> Cmd -> Encod 
                     ^           \ Compressed List ... -|
        Frag         |                                  |
                     |------------------<---------------|
        Ack

        NAck

        Forward  -> Forwarded..Message

[edit] Object Lists

An object can be a number, string, an IP:port, or even another object list. Each object has an ID. This ID identifies which command parameter the object is.

 Object:
         Number
         IP:Port
         List of numbers
         String
         RSA key
 Object List
         List Size (n)
         Object 1
         .
         .
         Object n

[edit] Packet compression

Packets can be compressed. The algorithm is a variation of arithmetic compression that uses reals instead of bits.

[edit] Legal Issues

  • Reverse engineering of the Skype protocol from network traffic is legal.
  • Reverse engineering of the Skype protocol by inspecting/disassembling binaries is prohibited by the terms and conditions of Skype's license agreement. However there are legal precedents when the reverse-engineering is aimed at interoperability of file formats and protocols.[2][3][4]

[edit] See also

[edit] References

  1. ^  Sega vs Accolade, 1992.
  2. ^  Sony vs Connectix, 2000.
  3. ^  Pamela Samuelson and Suzanne Scotchmer, "The Law and Economics of Reverse Engineering", 111 Yale Law Journal 1575-1663 (May 2002) [7].