Skip to main content

Danamon NIK HMAC Validation and Backward-Compatible Rollout

Description

This document describes the backward-compatible rollout of authenticated NIK encryption for the Danamon ECV integration. The implementation supports the existing two-segment message and the new three-segment HMAC-protected message during migration. Invalid or unverifiable NIK values stop the call before a database call record or Genesys interaction is created.

Affected Services

  • AdminApi – validates the message format, HMAC and encrypted payload.
  • ECVDemo – stops call creation when NIK verification fails.
  • Web.App – includesprovides the HMACHMAC-compatible testwaiting page usedand forforwards verification.the NIK value from the request URL.

AdminApp / Web.Admin is not changed by this enhancement.unchanged.

Message Formats

Legacy Format

<iv_hex>_<ciphertext_hex>

The legacy two-segment format remains available during the migration period when nikHmacRequired is set to false.

Authenticated Format

<iv_hex>_<ciphertext_hex>_<hmac_hex>
  • iv_hex: 16 bytes, represented by 32 hexadecimal characters.
  • ciphertext_hex: AES-256-CBC encrypted payload using the random IV.
  • hmac_hex: HMAC-SHA256 output, represented by 64 hexadecimal characters.

AThe newcurrent implementation uses AES-256-CBC with a random 16-byte IV mustfor bethe generatedauthenticated three-segment NIK format. Integrity protection is provided by theHMAC-SHA256 sending application for every encryption operation. The HMAC input isover the raw IV bytes followed by the raw ciphertext bytes:of iv || ciphertext. Hex strings and underscore separators are not included in the HMAC input.

The 64-character hmac_hex field is the HMAC-SHA256 output. It must not be confused with the separately configured HMAC key, although both are represented by 64 hexadecimal characters in the current implementation.

Configuration Changes

AdminApi

Add the following settings to the existing Danamon configuration. The existing AES key is unchanged.

danamon: {
    key: "<existing AES key>",
    nikHmacRequired: false,
    nikHmacKey: process.env.DANAMON_NIK_HMAC_KEY
}

Configure the production HMAC key through the environment:

DANAMON_NIK_HMAC_KEY="<64 hexadecimal characters>"
}
  • The current implementation requires a dedicated 32-byte HMAC key encoded as 64 hexadecimal characters.
  • The HMAC key must be 32generated bytesusing (64a hexadecimalcryptographically characters).secure random source.
  • The AES key and HMAC key must be different.
  • The sender and AdminApi must use the same HMAC key.
  • Set nikHmacKey in the deployed AdminApi config.js for each environment.
  • Do not usereuse sample or development fallback keys in production.

These parameters describe the current implementation and are subject to final confirmation of the integration specification.

Backward-Compatible Behavior

Configuration Two Segments Valid Three Segments Invalid HMAC
nikHmacRequired = false Accepted HMAC is verified, then accepted Rejected
nikHmacRequired = true Rejected HMAC is verified, then accepted Rejected

A three-segment message is always validated with HMAC, regardless of the value of nikHmacRequired. HMAC comparison is constant-time and is completed before decryption.

Call Blocking Behavior

NIK verification is performed before the call is inserted into the database and before the Genesys interaction is created. The call is stopped and the response NIK could not be verified. is returned when:

  • The NIK value is missing or empty.
  • The segment count or hexadecimal format is invalid.
  • The HMAC does not match.
  • Decryption or payload parsing fails.
  • AdminApi cannot be reached or the verification request times out.

Technical details are written to the service logs. Typical messages are DECRYPT REQUEST ERROR in AdminApi and NIK verification failed in ECVDemo.

Client Response Contract

The HMAC enhancement does not change the existing DialEx success contract. Client applications and SDK integrations determine whether the call started from the DialEx response:

  • RoomId and InteractionId are both present: the call was created successfully.
  • Either identifier is missing: the client must treat the call as not started, stop the flow and may display the returned Message.

This response check existed before the HMAC enhancement. The new server-side behavior is that failed NIK verification now returns without call identifiers and includes the following user-safe message:

{
    "RoomId": null,
    "InteractionId": null,
    "Message": "NIK could not be verified."
}

For NIK verification failures, no database call record or Genesys interaction is created. This server-side guarantee applies regardless of how the customer UI handles the response. If a customer application or SDK does not display Message, the call is still blocked, but the user may only see a generic failure or no error feedback.

HMAC Test Page

Web.App includes WaitForAgentHmac.html for positive and negative HMAC validation tests. Deploy the updated Web.App files together with AdminApi and ECVDemo.

  1. Set ecvWebAppUrl in WaitForAgent.html to the target Web.App base URL.
  2. Generate a valid three-segment NIK value using the AES and HMAC keys configured for the target environment. Do not use the sample encrypted value in production.
  3. Set the generated value in WaitForAgentHmac.html, or open the following URL directly:
https://<web-app-host>/waiting/r/hmac?niknumber=<URL_ENCODED_THREE_SEGMENT_NIK>
  • Positive test: use an unchanged valid three-segment value. The call should be created.
  • Negative test: change one hexadecimal character before opening the URL. The response should contain NIK could not be verified. and no database call record or Genesys interaction should be created.

Deployment Steps

  1. Back up the current AdminApi, ECVDemo and Web.App deployments and their configuration files.
  2. ConfigureSet DANAMON_NIK_HMAC_KEYnikHmacKey within the deployed AdminApi config.js to the agreed 64-character hexadecimal key.
  3. Set nikHmacRequired to false for the transition period.
  4. Deploy AdminApi.
  5. Deploy ECVDemo.
  6. Deploy the updated Web.App.App files, including WaitForAgent.html and WaitForAgentHmac.html.
  7. Restart the affected services as required.
  8. Run the verification matrix below.
  9. After all senders have switched to the authenticated three-segment format and verification is complete, set nikHmacRequired to true, restart AdminApi, and confirm that two-segment requests are rejected while valid three-segment requests continue to work.

Post-Deployment Verification

Test nikHmacRequired Expected Result
Valid two-segment NIK false Call is accepted.
Valid two-segment NIK true Request is rejected; no call starts.
Valid three-segment NIK false HMAC is verified and the call is accepted.
Valid three-segment NIK true HMAC is verified and the call is accepted.
Modify one character in the IV, ciphertext or HMAC false or true Request is rejected; no database call record or Genesys interaction is created.
Missing or malformed NIK false or true Request is rejected.
AdminApi unavailablefalse or trueVerification fails closed and no call starts.

The Web.App test page WaitForAgentHmac.html can be used for positive and negative tests. For a negative test, change one hexadecimal character in the URL before opening it; changing the URL after the call has already started does not test the rejection path.

Final Migration Step

After all senders have switched to the authenticated three-segment format, set nikHmacRequired to true and restart AdminApi. Confirm that two-segment requests are rejected and valid three-segment requests continue to work.

Acceptance Criteria

The rollout is complete when valid authenticated requests are accepted, tampered or unverifiable NIK values do not create a database call record or Genesys interaction, legacy requests are accepted only while explicitly allowed, and service logs contain enough detail for troubleshooting without exposing key material.