SW1/SW2

Status Word 1 / Status Word 2

Other
Introduced in Rel-6
The two individual bytes that constitute the Status Word (SW). SW1 is the first byte, often indicating the response class (normal, warning, error). SW2 is the second byte, providing a qualifier or detailed code within that class.

Description

SW1 and SW2 are the constituent bytes of the two-byte Status Word (SW) response in smart card communication. They are always transmitted and analyzed as a pair. SW1, the high-order byte, typically defines the general category or class of the response. For instance, values of SW1 like '61', '62', '63', '6A', or '90' indicate different classes such as 'normal processing with extra information', 'warning', 'execution error', or 'normal ending'. SW2, the low-order byte, provides a specific meaning or qualifier within the class defined by SW1. For example, if SW1 is '61' (warning, normal response), the value in SW2 indicates the exact number of data bytes still available to be read in a subsequent GET RESPONSE command.

The technical operation is integral to the APDU (Application Protocol Data Unit) response structure. After a terminal sends a command APDU (containing a CLA, INS, P1, P2, and possibly data) to the UICC, the card's operating system or application processes it. Upon completion, it formulates the response. This response consists of optional returned data (the response body) followed by the mandatory two-byte trailer: SW1 and then SW2. The terminal's software must parse these bytes sequentially. Interpretation is done via a lookup against standardized tables in ISO/IEC 7816-4 and 3GPP TS 31.102 (for USIM-specific commands).

Their role is to enable precise and efficient error handling and flow control. By separating the response into a class (SW1) and a detail (SW2), the system allows for both generic handling (e.g., 'any error in the 6Axx range is a parameter error') and specific actions (e.g., SW='6A86' means 'incorrect P1 P2'). This is crucial for the robustness of procedures like file access, authentication, and profile management on the UICC. The terminal's logic can branch based on the SW1/SW2 pair, deciding whether to retry a command, request more data, or abort an operation and alert the user.

Purpose & Motivation

SW1 and SW2 exist to decompose the Status Word into a structured, hierarchical code for more efficient and logical processing by the terminal. A single, monolithic response code would be less intuitive to parse and categorize. The split allows for a family of related error or warning conditions to be grouped under a common SW1 prefix, simplifying software design. It addresses the need for both high-level outcome determination and low-level diagnostic information.

This structure was inherited from the ISO/IEC 7816 smart card standards, which were designed for a wide range of card applications beyond telecommunications. 3GPP adopted this proven model for the UICC to ensure global interoperability and leverage existing industry expertise. The purpose is to provide a compact yet highly expressive means of communication from a resource-constrained smart card to a more powerful terminal processor. It solves the problem of conveying a wide array of possible command execution states—from success with ancillary data to fatal security failures—using only two bytes of overhead, which is critical for efficient low-level communication.

Key Features

  • SW1 is the first byte, indicating the response class or category
  • SW2 is the second byte, providing a specific qualifier or detail code
  • Always transmitted and interpreted as a pair (SW1||SW2)
  • Enables hierarchical error and status code processing
  • Defined in ISO/IEC 7816-4 with 3GPP-specific extensions in TS 31.102
  • Fundamental to APDU response parsing and terminal logic flow

Evolution Across Releases

Rel-6 Initial

Formally introduced the explicit breakdown of the Status Word into SW1 and SW2 components within 3GPP specifications, particularly for USIM and ISIM applications. This release reinforced the use of ISO/IEC 7816-4 coding schemes and defined specific SW1/SW2 values for new USIM commands introduced for 3G services, providing clearer guidelines for terminal implementation.

Defining Specifications

SpecificationTitle
TS 21.905 3GPP TS 21.905
TS 31.113 3GPP TR 31.113