MT20W_Direct_USB_Feature_v0.06

MT20W Direct USB Feature

REVISION CONTROL RECORD   
VERDATEDESCRIPTION OF CHANGEAUTHOR
0.0110/29/2018Initial DraftT. Stuart
0.0211/01/2018Formatted document into Allegion standard MS Word document template and edited for grammar, etc.A. Clark
0.0311/12/2018Incorporated most of Troy Stuart’s comments. Added Section 1.3 to Set USB mode and made more edits.A. Clark
0.0412/21/2018Added Pre-requisites section (2.1) under the “API Changes” headerD. Shetty
0.0501/11/2019Updated document for the following updates - Handling of the driver token in the API (section 2.2.1.3) - Including examples for creating driver token and API response (section 2.2.1.1) - Including example for existing method of primary credential encryption (section 2.3.1)D. Shetty / H. Jain / P. SA
0.0601/15/2019Reviewed updates for grammar, edits, and consistent formatting for pre-release.A. Clark

Abbreviations and Definitions

AbbreviationDefinition
AES 256Advanced Encryption Standard utilizing a key length of 256 bits
APIApplication Program Interface – The interface provided by the ENGAGE enabled devices and Web Application
BLEBluetooth Low Energy
CommissionProcess in which the device gets a replaceable encryption key (REK) or the site key.
Db or DBDatabase
DeviceGeneric term to refer to any lock, reader, or other ENGAGE component.
Edge DeviceAny ENGAGE enabled device used for access control such as an NDE or LE lock.
ENGAGEConnectivity Platform Technology
FDRFactory Default Reset
Host or Host ServerAn Alliance Partner server, external server outside of the Allegion domain
HTTPHypertext Transfer Protocol
HTTPSHTTP Secure, or HTTP over SSL
InstallerThe person who installs the ENGAGE device. These individuals will most likely be the ones also commissioning the device. These installers may or may not work for the Service Provider. There are situations where unions dictate where installers come from.
IPInternet Protocol
JS Driver AppDesktop Application for USB data transfer from MT20W to PC
JSONJava Script Object Notation
LANLocal Area Network
MAPPMobile Application
Mobile DeviceA handheld computer that is made for portability. (i.e. tablets, smart phones, iPads, etc.)
NDEENGAGE™ Wireless Cylindrical Lock
OPENA security protocol in which credentials between an access point and a client need not be exchanged
PEKProduction Encryption Key, generated during the manufacturing process and unique to each edge device
SAMAllegion ENGAGE Software Alliance Member
SiteLogical grouping of ENGAGE devices which all share the same site key. In Engage this is referred to as a facility.
Site KeyThe site key is a key that is used on all Engage enabled devices on a site, (e.g. In a building or on a floor in a building).
SSLSecure Sockets Layer, a standard security technology which allows encrypted links to be established between nodes is a network
TLSTransport Layer Security, cryptographic protocol allowing for secure communications
URIUniform Resource Identifier
URLUniform Resource Locator

MT20W Direct USB Feature

Background

Prior to this feature, all data transfer between the MT20W Enrollment Reader and the Host Server was conveyed via WiFi. WiFi stability is a concern for proper MT20W operation in some facilities. To overcome this issue, the new MT20W Direct USB Feature is introduced.

The scope of this document is to provide a description of the MT20W Direct USB Feature and the changes that need to be made to the ENGAGE API to support communication between the MT20W and Host Server over USB via the ENGAGE Desktop Application.

Solution

The MT20W is detected by the JS Driver App (Desktop Application) installed on your PC. This makes use of USB communication to do data transfer. Any form of data that was previously exchanged via WiFi can now be sent to the Desktop Application via USB.

The design transfers all WiFi based communication to the USB of the MT20W device. The Desktop Application receives the information from the device (MT20W) and makes appropriate HTTP calls over the Desktop’s internet connection. Since this application does not understand the information that is being exchanged (i.e. URL, AuthToken, method to use.), the MT20W provides the data in a format which helps the Desktop App make the appropriate calls.

The MT20W firmware builds all the HTTP requests in the JSON format and transmits over USB to the Desktop Application. Similarly, the Desktop Application collects the received http responses and sends them to the MT20W in JSON format.

MT20W USB Installation

Verifying and Updating MT20W Firmware

If your MT20W is already Commissioned at your site, there are two ways to confirm the MT20W firmware version. You can either use your desktop application or your mobile application.

NOTE: For USB communication, the MT20W firmware must be at version 39.02.00 or higher.

Using the Desktop Application

To verify the current MT20W firmware revision:

  • Open the ENGAGE Web Application on your desktop.

  • Navigate to the ADVANCED tab.

  • Select Firmware.

  • Locate the MT20W device in the Device List.

  • View the MT20W Current Firmware Version versus the Latest Firmware Version.

NOTE: In this case the MT20W firmware is not at the latest revision.

  • If the current firmware version is earlier than version 39.02.00, you must update the firmware using the mobile application to enable USB communication.

Using the Mobile Application

This process assumes that there is a WiFi network already saved and available for use by the mobile application.

Verify the MT20W has latest Firmware by following steps 1 through 3 below:

1. Select MT20W device2. Select Update Firmware3. Is Firmware Current?
  • When the current firmware version is earlier than version 39.02.00, you must update the firmware when using USB communication.

  • Click on the Update button from the mobile app to update the firmware.

  • The Initiating firmware download screen displays.

  • The firmware is downloaded to the MT20W.

  • The Installing firmware screen displays.

  • Click Finish.

  • The blank In Range mobile display is shown.

  • The MT20W automatically finishes its firmware installation process and reboots. Be patient, this may take a few minutes. Wait for all LED flashing to stop.

  • The boot-up process is complete and the MT20W is communicating when a solid BLUE LED displays.

  • The mobile app screen does not update again until the User swipes down to refresh the screen or navigates away and comes back to the All devices or In Range screen.

Setting and Selecting USB Mode

Connected to MT20W – Toggle from WiFi to USB Communication Mode

a. Select Settingsb. Select Comm Modec. Select USB Mode

Usage – Normal Operation

MT20W light interpretation remains the same.

  • Solid blue means the MT20W is communicating; Solid Red, 1 Green Blink, 3 green blinks…

The Desktop Application acts as a transmitter/receiver between the MT20W and the ENGAGE Web Application.

On opening the ENGAGE Desktop Application, the information on the screen instructs you to connect the MT20W to your PC to get started (Figure 1).

Figure 1: MT20W Direct

Once you plug the MT20W into the USB port on the PC, the ENGAGE Desktop Application detects the reader and begins communication (Figure 2 & 3).

NOTE: The ENGAGE Application does not start automatically when the MT20W is first connected. When using USB communication, the ENGAGE Desktop Application must be running.

After power up, the MT20W must go through a boot up process BEFORE a connection is accomplished. Be patient, this may take a few seconds.

Figure 2: Reader Detected

After the connection is established, the serial number and firmware version of the ENGAGE Desktop Application displays on the screen (Figure 3).

Figure 3: Reader Connected

NOTE: If you close the ENGAGE Desktop Application on the PC by clicking on the ‘X’ in the upper right-hand corner, you must restart it again before USB communication is available. The MT20W shows a solid RED LED in this case.

The ENGAGE Icon symbol shows in your PC system tray anytime the ENGAGE Application is running.

If any error occurs during the communication, an error message along with the error code displays on the screen along with a notification (Figure 4).

Figure 4: Error Detected

When the reader is un-plugged from the Desktop/System, the Application screen shows that the reader is disconnected (Figure 5).

Figure 5: Reader Disconnected

Setting and Selecting WiFi Mode (Optional)

If you intend to use WiFi instead of USB Direct Mode, and the MT20W has already been commissioned in an earlier process, perform the following steps to enable WiFi.

WARNING: A Saved Network MUST be locally available at the location where the device is being installed and commissioned. Be sure a saved WiFi network is present and locally available before selection.

  • If there are no saved WiFi networks, a new network MUST be added. (see the Adding a new WiFi Network section).

  • When a Saved Network is available, the property administrator may select that WiFi network for quick and accurate data entry.

  • Ensure the Schlage MT20W is in signal range of the local WiFi network access point.

  • Select Next.

  • Confirm the Schlage MT20W Credential Reader selected for Commissioning.

    • The Blue LED should be flashing slowly to indicate it has been selected.

  • Select Yes.

Connected to MT20W – Toggle from USB to WiFi Communication Mode

a. Select Settingsb. Select Comm Modec. Select WiFi Mode
  • Next the Property Administrator selects the local WiFi network for the device. There are one of two options available. No Saved or Saved Networks.
No Saved WiFi NetworksOne Saved WiFi Network Available

Adding a new WiFi Network

  • Initially the Property Administrator MUST select Add a new network to enter the WiFi network Security Settings. See the next section when Selecting a Saved Network.

  • Enter the WiFi SSID.

    • This is the name of the local wireless local area network

    • This entry must be EXACT and is CASE SENSITIVE

  • Select the WiFi Security used by the local area wireless network

    • OPEN, WPA2, WPA2 (PEAP), or WEP

NOTE: Depending on the WiFi network security chosen, you may need to enter different information. Those items highlighted in the screen below (not grayed out) are required.

In this case we chose WiFi SSID 610baLWLAN and the WPA2 (PEAP) network security protocol. Both a Username and Password are required.

  • After entering all required information, Select Next

NOTE: The WiFi network settings can now be programmed into the Schlage MT20W and the Schlage MT20W connects to the local WiFi network using the entered network settings. Wait a few moments until the Schlage MT20W provides a solid Blue LED indicating it has successfully connected with the local wireless area network.

WARNING: If the Schlage MT20W does not provide a solid Blue LED and tries to reconnect but fails, the WiFi network settings are not entered correctly or the local WiFi network is not present.

  • Recheck the WiFi network settings and Try Again.

HINT: You can also verify the local network security settings by using your Mobile Phone to enter the network settings and temporarily connect to verify local WiFi network connection requirements.

  • Select the Press if Solid Blue (Connected) Blue bar to continue.

  • Acknowledge the “Setup Complete” message.

  • Select Exit.

VERIFY SUCCESS

  • The MT20W device is now shown in the ENGAGE™ Mobile application All Devices menu and the In Range menu when the mobile device is nearby the MT20W.

  • The Schlage MT20W LED illuminates solid BLUE after power is applied and boot-up is completed indicating successful connection to the local WiFi Network.

NOTES:

  1. The Schlage MT20W solid BLUE “Connected” LED display indicates the Schlage MT20W is connected to the local wireless WiFi network and operating properly.

  2. The Schlage MT20W flashes BLUE quickly while trying to connect with the local WiFi network.

  3. When the local WiFi network connection fails, the Schlage MT20W displays a solid RED LED.

  4. When the local WiFi network is not available (failed or down for maintenance), the Schlage MT20W automatically retries to reconnect to the local WiFi network every few minutes.

Selecting a Saved Network

  • Instead of selecting “Add a new network”, the Property Administrator may select the appropriate (locally available) WiFi SSID in the displayed list of Saved Networks. In this case only one Saved Network has been saved and made available for selection; 610baLWLAN.

  • Select the Saved Network: 610aLWLAN.
then…

NOTE: The Schlage MT20W resets and tries to connect to the local WiFi network using the saved network settings. Be patient, wait a few moments while the Schlage MT20W tries to connect to the local WiFi (fast Blue LED blinking) and then provides a solid Blue LED indicating it has successfully connected to the local WiFi network.

  • Select the Press here on solid blue bar to continue.

WARNING: If the Schlage MT20W does not provide a solid Blue LED and tries to reconnect but fails, the WiFi network settings are not correct or the local WiFi network is not present.

  • Recheck or reenter the WiFi network settings and Try Again

HINT: You can also verify the local network security settings by using your mobile phone to enter the network settings and temporarily connect with your phone. When successful, the local WiFi network connection requirements are verified and can be re-entered as a saved network.

  • Acknowledge the Setup Complete message and select Exit.

Installing the ENGAGE PC Desktop Application

After the Send Link button is selected, the system sends a link to your email. Go to your email and follow the instructions.

  • Check Email – look for this item in the System Administrator’s email.

  • Open the email and select the Correct Operating System version for your PC.

  • Select Windows or macOS operating system button.

  • Navigate to the PC “Download” folder.

  • Locate the Engage_Setup installation application.

  • Run (Double-Click) the Engage_Setup-X.x.x-win.exe installation application to install it.

NOTE: PC Administration authority (permissions) are required.

  • Observe the installation process where the next screens are immediately shown.

When the installation is successful, the following screens display on the desktop.

Reader Detected

After the connection is established, the serial number and firmware version of the application displays on the screen.

Reader Connected

NOTE: Do NOT close this application. 

API Changes for MT20W Direct

There are changes to existing API integrations that need to be made to use the MT20W Direct USB Feature.

Pre-Requisites

HTTPS Everywhere

All communication between the Desktop Application and the host server is over HTTPS(i.e. communication is secure/encrypted). For this you need to install an SSL certificate onto the web server to initiate a secure session with the Desktop Application. SSL proves to the user that they are really connecting to the site they requested, and not to an attacker masquerading as the end site.

NOTE: Regardless of whether ‘Secured’ or ‘Unsecured’ configuration is selected during MT20W setup, the communication is ‘Secured’ (using HTTPS) between the host server and the Desktop Application. Thus, a valid SSL certificate for the web server is required.

Server DNS/IP Configuration Must Match the SSL Certificate

SSL certificates are bound to a ‘common name’, which is usually a fully qualified domain name but sometimes are a wildcard name (e.g. *.domain.com) or even an IP address. The configuration (‘DNS’ name or ‘IP’ address) entered for the MT20W must match the ‘common name’ provided in the certificate or the connection between the web server and Desktop Application fails.

Authentication Changes

Driver Token

The APIs should now support a new authentication scheme called Driver. All MT20Ws that are commissioned in the USB mode use this Driver authorization scheme header (i.e. Authorization: Driver {token}) to communicate with the APIs. The MT20Ws that are in WiFi mode continue to use the existing Device authorization scheme.

If the MT20W is in USB mode and tries to call the API with Device authorization scheme (i.e. Authorization: Device {token}) instead of Driver authorization scheme, the API sends back a 401-Unauthorized message.

The Driver token is a combination of the serial number of the device and a timestamp (or random number). See the details below on how the driver token is generated from the firmware.

Generating Driver Token from Firmware

The following algorithm is used in the MT20W firmware to generate the driver token.

  • Append 16-byte random number or timestamp (i.e the value of response header 'X-Device-Last-Connected') to the 16-byte serial number. The total length = 32-bytes (16-bytes number + 16-bytes SN). Reference the Section: Handling Driver Token from the API for more details about 'X-Device-Last-Connected'.

  • A sample random number could be 20180919105017.

  • Encrypt this 32-byte data with the site key. This encrypted value is appended with the serial number.

  • Encode the entire string to base64.

  • The resulting string is the auth token that is sent to the host.

Example: Consider Site Key to be BAE3B37054AFDF441390B29032417F5BF1739AE1B784BF6C6A8A9617CC5B19

Let 16-byte random number be 2019011103485600

BitPosition0123456789101112131415
Data (0x)32303139303131313033343835360000

Let Serial number be A0C1777700000017

BitPosition0123456789101112131415
Data (0x)0000000000000000A0C1777700000017

Step 1: Append random number to serial number to form 32-byte data, the result would be:

BitPosition0123456789101112131415
Data (0x)32303139303131313033343835360000
BitPosition16171819202122232425262728293031
Data (0x)0000000000000000A0C1777700000017

Step 2: Encrypt 32-byte data with Site Key (AES 256 encryption), the result would be:

EF8A7F17E39973D9154E7AFDDD5EC93A8BD13710A2CA943E24CFF8AA391DB8B4

Step 3: Append Serial Number to Encrypted data, the result would be:

0000000000000000A0C1777700000017:EF8A7F17E39973D9154E7AFDDD5EC93A8BD13710A2CA943E24CFF8AA391DB8B4:1

Step 4: Encode the entire string to base64, the result would be:

MDAwMDAwMDAwMDAwMDAwMEEwQzE3Nzc3MDAwMDAwMTc6RUY4QTdGMTdFMzk5NzNEOTE1NEU3QUZEREQ1RUM5M0E 4QkQxMzcxMEEyQ0E5NDNFMjRDRkY4QUEzOTFEQjhCNDox

This is the Auth Token to be sent in the API request with Driver as prefix.

Sample API Request Example

Below is an existing API that is used to transfer No Tour data to the MT20W. This API is called each time a card is presented to the MT20W reader.

API: POST /api/credentials/scan

Request Headers:

Authorization: Driver

MDAwMDAwMDAwMDAwMDAwMEEwQzE3Nzc3MDAwMDAwMTc6RUY4QTdGMTdFMzk5NzNEOTE1NEU3 QUZEREQ1RUM5M0E4QkQxMzcxMEEyQ0E5NDNFMjRDRkY4QUEzOTFEQjhCNDox

Content-Type: application/json; charset=UTF-8

Request Body:

{
"BadgeId":"65535",
"Primary":" MmBz+Li+C3Pk5GNR8oSsjWY6qa98PdTSAQS4RcbwCk=",
"CardFormat": "smart",
"Format":"Bytes"
}

Response: There is no change in the response format. It remains the same as the existing response. The only difference now is every API request that is made using Driver auth token is expected to send a response header ‘X-Device-Last-Connected’. (Ref: Handling Driver Token from the API)

Handling Driver token from the API

API requests from MT20W with Driver token are in USB mode. Furthermore, API requests with Driver token are always responded with an encrypted + encoded timestamp (or random number) value in the response header. The response header is X-Device-Last-Connected.

This timestamp must be unique for the consecutive requests. The MT20W uses the timestamp from the response header in the authorization token of the next request (This is done to ensure dynamic token generation. Since the messages are now exchanged over USB with the Desktop application, dynamic tokens are necessary to avoid record and replay attacks).

It is recommended that the API keep the information of the timestamp sent in the response header and perform an equality check during the next request (This is to ensure the authorization tokens are always unique and previous authorization tokens are always invalid, to avoid any request replays). However, for the very first request from the MT20W, this check cannot be done as the host does not have the information of the timestamp used in the token, which would be acceptable.

NOTES:

  1. Here timestamp must be a 14-digit number. You could use any 14-digit random number as long as consecutive requests do not have the same value for this number.

  2. The timestamp is encrypted with the siteKey and encoded in base64 format and sent as ‘X-Device-Last-Connected’ response header value.

  3. The existing validation check remains as it is (i.e. Serial number validation, commissioned or not validation etc.)

Primary Credential Encryption Changes

There were some enhancement changes made to security by introducing changes to the encryption of the Primary credential which is part of the API request body.

Existing Encryption Methodology for Primary Credential

NOTE: This is still applicable for WiFi mode of operation.

  1. Primary credential is 8 bytes (16 hex digits) in length.

  2. The credential value is filled with b0s until the byte boundary and 0xFF for the rest of the bytes (to form an 8 byte credential ID)

  3. MT20W fills 0xFF as the most significant 8 bytes to form a 16 byte (128 bits) block of data for encryption

  4. MT20W encrypts (AES 256) the 16 bytes (from step 2) using the Site Key as the encryption key and zeros for Init Vector.

  5. This encrypted value (16 bytes OR 32 hex digits) is encoded in Base 64 format (24 bytes) and sent as the Primary credential data to ORCA.

  6. ORCA decodes the Base 64 encoded data and then decrypts the Primary value from step 4, using the site key as the decryption key and zeros for Init Vector.

  7. The decryption results in a 16 byte (32 hex digits) data and ORCA pulls the least significant 8 byte to get the Primary Credential value.

Bit Format for UNencrypted Data: 16 bytes

Bit position0 -78-15
DataRaw card data0xFF

Encryption Example

Raw card data as printed on the card: 0x9400016009A4

Unencrypted data Encrypted data Encoded data Site Key    
Bit positionData Bit positionData Bit positionData Bit positionData
00x94 00xEB 00x36 00xD4
10x00 10x10 10x78 10xBE
20x01 20x94 20x43 20x94
30x60 30xDA 30x55 30x94
40x09 40x0B 40x32 40xB8
50xA4 50xCE 50x67 50x3F
60xFF 60x42 60x76 60xF0
70xFF 70xE5 70x4F 70xC0
80xFF 80x9E 80x51 80x18
90xFF 90x41 90x75 90x87
100xFF 100xB7 100x57 100x24
110xFF 110xCF 110x65 110xE2
120xFF 120xEF 120x51 120x56
130xFF 130x51 130x62 130xC9
140xFF 140x8F 140x66 140xEE
150xFF 150x4A 150x50 150x51
      160x37 160x1D
      170x31 170x40
      180x47 180x07
      190x50 190x6A
      200x53 200x52
      210x67 210xA0
      220x3D 220x82
      230x3D 230xC5
      240x00 240xDE
         250x9D
         260x30
         270xF3
         280x5B
         290x16
         300x85
         310x28

Encryption Changes for Primary Credential

The Primary credential is 8-bytes (16 hex digits) in length. The following steps are used to encrypt the Primary credential:

  1. The credential value is filled with binary bit 0s up to the byte boundary and 0xFF for the rest of the bytes (to form an 8-byte credential ID).

  2. The MT20W fills 0xFF as the most significant 8-bytes to form a 16-byte (128 bits) block of data.

  3. A random number of 12 bytes is generated and used as the first part of data to be encrypted. This is followed by the Primary credential of 16-bytes mentioned in the previous step.

  4. Two additional bytes of 0x00s are added to the data to make it 30-bytes long.

  5. CRC is calculated on this entire data and placed in the last two bytes of the 32-byte unencrypted data array.

  6. The MT20W encrypts (AES 256) the 32-bytes (from above step) using the Site Key as the encryption key and zeros for Init Vector.

  7. This encrypted value (32-bytes OR 64 hex digits) is encoded in Base64 format (44-bytes) and sent as the Primary credential data to ORCA.

Bit Format for UNencrypted Data: 16 bytes

Bit position0 -1112-1920-2728-2930-31
Data12-byte Random numberRaw card data padded with 0xFF to form 8 bytes0xFF0X00CRC-16

Encryption Example

Raw card data as printed on the card: 0x9400016009A4.

UNencrypted data Encrypted data Encoded data Site Key    
Bit positionData Bit positionData Bit positionData Bit positionData
00xAE 00x51 00x55 00xD4
10xB0 10xAF 10x61 10xBE
20x8A 20x52 20x39 20x94
30xF2 30x14 30x53 30x94
40x44 40xA6 40x46 40xB8
50x7E 50xB5 50x4B 50x3F
60x0C 60xF0 60x61 60xF0
70x7C 70xBC 70x31 70xC0
80xF8 80xDA 80x38 80x18
90xF5 90x59 90x4C 90x87
100x3A 100xE6 100x7A 100x24
110x3B 110xCB 110x61 110xE2
120x94 120x11 120x57 120x56
130x00 130xA3 130x65 130xC9
140x01 140xD6 140x62 140xEE
150x60 150xC9 150x4C 150x51
160x09 160x80 160x45 160x1D
170xA4 170x63 170x61 170x40
180xFF 180x0E 180x50 180x07
190xFF 190x5D 190x57 190x6A
200xFF 200xAA 200x79 200x52
210xFF 210xA6 210x59 210xA0
220xFF 220xBE 220x42 220x82
230xFF 230x45 230x6A 230xC5
240xFF 240x22 240x44 240xDE
250xFF 250xCA 250x6C 250x9D
260xFF 260xFC 260x32 260x30
270xFF 270x43 270x71 270xF3
280x00 280xA5 280x70 280x5B
290x00 290x44 290x72 290x16
300XE9 300x42 300x35 300x85
310x4C 310xE9 310x46 310x28
      320x49   
      330x73   
      340x72   
      350x38   
      360x51   
      370x36   
      380x56   
      390x45   
      400x51   
      410x75   
      420x6B   
      430x3D   
      440x6D   

Decryption of Primary

API must decode Base 64 and decrypt the Primary value using the site key as the decryption key. The decryption results in a 32-byte (32 hex digits) data and API pulls the masked 8-bytes to get the Primary Credential value.

The following steps are used to decrypt the Primary credential:

  1. Decode the base64 formatted Primary credential.

  2. Decrypt the decoded data using the Site key. This results in 32-byte un-encrypted Primary credential (Byte array of Hex values).

  3. The last two bytes of this array contains CRC. This CRC follows [LSB, MSB] format, hence reverse the CRC byte array.

  4. Compute the CRC16 for the first 30 bytes excluding the CRC.

  5. Compare the CRC obtained with the CRC of incoming request. If the CRC check fails, then API returns Bad Request with a message Credential data is corrupt.

  6. Once the CRC check is passed, Primary data (Total of from Byte[12] to Byte[27] – includes raw card data (8bytes) and padded 0xFF(8bytes)), is extracted from UNencrypted data. (See the Section: Encryption Changes for Primary Credential).

Computing CRC16

This is the method used to compute CRC. 0x10FFFF is used for masking in CRC 16 calculation and 0x1021 is the polynomial used.

public uint ComputeCrc16(byte [] bytes)
     {  
       uint crc = 0;
       foreach (byte b in bytes)
       {  
         crc ^= (uint) (b << 8);
         for (int i = 0; i < 8; i++)
         {
           if ((crc & 0x8000)! = 0)
           {
             crc = (((crc << 1) & 0x10FFFF) ^ 0x1021);
           }
           else
           {
             crc <<= 1;
           }
         }
       }
       return crc;}