Whatsapp security is considered seriously from the day when WhatsApp was launched. It is used during a natural disaster for reuniting the family. Getting in touch with loved and dear ones in an overseas location. Talking to them over the phone, making video calls, audio notes and more.
People even share personal information. This is the reason, the security at WhatsApp is given the top most priority. The encryption technology used ensures that your message, text, videos, calls, and personal pictures are not left in wrong hands.
Default Security Feature
The End-to-End Encryption feature is enabled by default. There is no manual option to enable or disable it. When you and your friend uses the latest version of WhatsApp, the messages are encrypted by default.
It is only you and the receiver who can see and read the message. No one else. Every message has a lock and only the person intended to receive the message can only open it.
All these actions happen automatically and there is no manual option to enable and disable end to end encryption.
Whatsapp Calls Are Also Encrypted
Similar to your WhatsApp messages and chats, the WhatsApp audio and vide calls are also encrypted. You can even make international calls. These calls are also encrypted and not one can hack or listen to it.
I suggest you watch the video by CNN-News18 Channel. This clearly explains how the security feature of WhatsApp works:
Does Whatsapp Save Our Messages and MultiMedia Files?
No. Whatsapp does not store any details on their servers. For file transfer and saving messages and multimedia files, the internal/external memory of the user is used as a server. Considering that the messages must lie with the user itself, WhatsApp does not save any information on their server.
In-Depth Technical Explanation of Whatsapp Security Features
WhatsApp Messenger allows people to exchange messages (including chats, group chats, images, videos, voice messages, and files) and make WhatsApp calls around the world.
WhatsApp messages, voice and video calls between a sender and receiver that use WhatsApp client software released after March 31, 2016, are end-to-end encrypted.
The Signal Protocol, designed by Open Whisper Systems, is the basis for WhatsApp’s end-to-end encryption. This end-to-end encryption protocol is designed to prevent third parties and WhatsApp from having plaintext access to messages or calls.
Even if encryption keys from a user’s device are ever physically compromised, they cannot be used to go back in time to decrypt previously transmitted messages.
This blog post gives an overview of the Signal Protocol and its use in WhatsApp.
Public Key Types
There are 3 types of public key. Identify key pair, Signed Pre Key, One-Time Pre Keys. Let’s see them in detail below:
Identity Key Pair: A long-term Curve25519 key pair, generated during install time.
Signed Pre Key: A medium-term Curve25519 key pair, generated during install time, signed by the Identity Key, and rotated on a periodic timed basis.
One-Time Pre Keys: A queue of Curve25519 key pairs for one time use, generated at install time, and replenished as needed
Session Key Types
There are 3 types of session key types. Root key, Chain Key, and Message Key. Let’s see them in detail below:
Root Key: – A 32-byte value that is used to create Chain Keys.
Chain Key: – A 32-byte value that is used to create Message Keys.
Message Key: – An 80-byte value that is used to encrypt message contents. 32 bytes are used for an AES-256 key, 32 bytes for an HMAC-SHA256 key, and 16 bytes for an IV.
During registration of the WhatsApp mobile application, a WhatsApp client transmits its public Identity Key, public Signed Pre Key (with its signature), and a batch of public One-Time Pre Keys to the server.
The WhatsApp server stores these public keys associated with the user’s identifier. At no time does the WhatsApp server have access to any of the client’s private keys.
Initiating Session Setup
To communicate with another WhatsApp user, a WhatsApp client first needs to establish an encrypted session. Once the session is established, clients do not need to rebuild a new session with each other until the existing session state is lost through an external event such as an app reinstall or device change.
- The initiating client (“initiator”) requests the public Identity Key, public Signed Pre Key and a single public One-Time Pre Key for the recipient.
- The server returns the requested public key values. A One-Time Pre Key is only used once, so it is removed from server storage after being requested. If the recipient’s latest batch of One-Time Pre Keys has been consumed and the recipient has not replenished them, no One-Time Pre Key will be returned.
- The initiator saves the recipient’s Identity Key as I recipient, the Signed Pre Key as S recipient, and the One-Time Pre Key as O recipient.
- The initiator generates an ephemeral Curve25519 key pair, E initiator.
- The initiator loads its own Identity Key as Iinitiator.
- The initiator calculates a master secret as master_secret = ECDH(Iinitiator, Srecipient) || ECDH(Einitiator, Irecipient) || ECDH(Einitiator, Srecipient) || ECDH(Einitiator, Orecipient). If there is no One Time Pre Key, the final ECDH is omitted.
- The initiator uses HKDF to create a Root Key and Chain Keys from the master_secret.
Receiving Session Setup
After building a long-running encryption session, the initiator can immediately start sending messages to the recipient, even if the recipient is offline. Until the recipient responds, the initiator includes the information (in the header of all messages sent) that the recipient requires to build a corresponding session. This includes the initiator’s Einitiator and Iinitiator.
When the recipient receives a message that includes session setup information:
- The recipient calculates the corresponding master_secret using its own private keys and the public keys advertised in the header of the incoming message.
- The recipient deletes the One-Time Pre Key used by the initiator.
- The initiator uses HKDF to derive a corresponding Root Key and Chain Keys from the master_secret.
Once a session has been established, clients exchange messages that are protected with a Message Key using AES256 in CBC mode for encryption and HMAC-SHA256 for authentication.
The Message Key changes for each message transmitted and is ephemeral, such that the Message Key used to encrypt a message cannot be reconstructed from the session state after a message has been transmitted or received.
The Message Key is derived from a sender’s Chain Key that “ratchets” forward with every message sent. Additionally, a new ECDH agreement is performed with each message roundtrip to create a new Chain Key.
This provides forward secrecy through the combination of both an immediate “hash ratchet” and a round trip “DH ratchet.”
Calculating a Message Key from a Chain Key
Each time a new Message Key is needed by a message sender, it is calculated as:
- Message Key = HMAC-SHA256(Chain Key, 0x01).
- The Chain Key is then updated as Chain Key = HMAC-SHA256(Chain Key, 0x02).
This causes the Chain Key to “ratchet” forward, and also means that a stored Message Key can’t be used to derive current or past values of the Chain Key.
Calculating a Chain Key from a Root Key
Each time a message is transmitted, an ephemeral Curve25519 public key is advertised along with it. Once a response is received, a new Chain Key and Root Key are calculated as:
- ephemeral_secret = ECDH(Ephemeralsender, Ephemeralrecipient).
- Chain Key, Root Key = HKDF(Root Key, ephemeral_secret).
A chain is only ever used to send messages from one user, so message keys are not reused. Because of the way Message Keys and Chain Keys are calculated, messages can arrive delayed, out of order, or can be lost entirely without any problems.
Transmitting Media and Other Attachments
Large attachments of any type (video, audio, images, or files) are also end-to-end encrypted:
- The WhatsApp user sending a message (“sender”) generates an ephemeral 32 byte AES256 key, and an ephemeral 32 byte HMACSHA256 key.
- The sender encrypts the attachment with the AES256 key in CBC mode with a random IV, then appends a MAC of the ciphertext using HMAC-SHA256.
- The sender uploads the encrypted attachment to a blob store.
- The sender transmits a normal encrypted message to the recipient that contains the encryption key, the HMAC key, a SHA256 hash of the encrypted blob, and a pointer to the blob in the blob store.
- The recipient decrypts the message, retrieves the encrypted blob from the blob store, verifies the SHA256 hash of it, verifies the MAC, and decrypts the plaintext.
Traditional unencrypted messenger apps typically employ “server-side fan-out” for group messages. A client wishing to send a message to a group of users transmits a single message, which is then distributed N times to the N different group members by the server.
This is in contrast to “client-side fan-out,” where a client would transmit a single message N times to the N different group members itself.
Messages to WhatsApp groups build on the pairwise encrypted sessions outlined above to achieve efficient server-side fan-out for most messages sent to groups. This is accomplished using the “Sender Keys” component of the Signal Messaging Protocol.
The first time a WhatsApp group member sends a message to a group:
- The sender generates a random 32-byte Chain Key.
- The sender generates a random Curve25519 Signature Key key pair.
- The sender combines the 32-byte Chain Key and the public key from the Signature Key into a Sender Key message.
- The sender individually encrypts the Sender Key to each member of the group, using the pairwise messaging protocol explained previously.
For all subsequent messages to the group:
- The sender derives a Message Key from the Chain Key, and updates the Chain Key.
- The sender encrypts the message using AES256 in CBC mode.
- The sender signs the ciphertext using the Signature Key.
- The sender transmits the single ciphertext message to the server, which does server-side fan-out to all group participants.
The “hash ratchet” of the message sender’s Chain Key provides forward secrecy. Whenever a group member leaves, all group participants clear their Sender Key and start over.
WhatsApp voice and video calls are also end-to-end encrypted. When a WhatsApp user initiates a voice or video call:
- The initiator builds an encrypted session with the recipient (as outlined in Section Initiating Session Setup), if one does not already exist.
- The initiator generates a random 32-byte SRTP master secret
- The initiator transmits an encrypted message to the recipient that signals an incoming call, and contains the SRTP master secret
- If the responder answers the call, a SRTP encrypted call ensues.
WhatsApp users additionally have the option to verify the keys of the other users with whom they are communicating so that they are able to confirm that an unauthorized third party (or WhatsApp) has not initiated a man-in-the-middle attack. This can be done by scanning a QR code, or by comparing a 60-digit number.
The QR code contains:
- A version
- The user identifier for both parties.
- The full 32-byte public Identity Key for both parties.
When either user scans the other’s QR code, the keys are compared to ensure that what is in the QR code matches the Identity Key as retrieved from the server
The 60-digit number is computed by concatenating the two 30-digit numeric fingerprints for each user’s Identity Key. To calculate a 30-digit numeric fingerprint:
- Iteratively SHA-512 hash the public Identity Key and user identifier 5200 times.
- Take the first 30 bytes of the final hash output.
- Split the 30-byte result into six 5-byte chunks.
- Convert each 5-byte chunk into 5 digits by interpreting each 5-byte chunk as a big-endian unsigned integer and reducing it modulo 100000.
- Concatenate the six groups of five digits into thirty digits.
All communication between WhatsApp clients and WhatsApp servers is layered within a separate encrypted channel. On Windows Phone, iPhone, and Android, those end-to-end encryption capable clients use Noise Pipes with Curve25519, AES-GCM, and SHA256 from the Noise Protocol Framework for long running interactive connections.
This provides clients with a few nice properties:
- Extremely fast lightweight connection setup and resume.
- Encrypts metadata to hide it from unauthorized network observers. No information about the connecting user’s identity is revealed.
- No client authentication secrets are stored on the server. Clients authenticate themselves using a Curve25519 key pair, so the server only stores a client’s public authentication key. If the server’s user database is ever compromised, no private authentication credentials will be revealed.
Messages between WhatsApp users are protected with an end to-end encryption protocol so that third parties and WhatsApp cannot read them and so that the messages can only be decrypted by the recipient. All types of WhatsApp messages (including chats, group chats, images, videos, voice messages and files) and WhatsApp calls are protected by end-to-end encryption.
WhatsApp servers do not have access to the private keys of WhatsApp users, and WhatsApp users have the option to verify keys in order to ensure the integrity of their communication.