Danamon NIK HMAC Validation – Deployment 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 – provides the HMAC-compatible waiting page and forwards the NIK value from the request URL.
AdminApp / Web.Admin is 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.
The current implementation uses AES-256-CBC with a random 16-byte IV for the authenticated three-segment NIK format. Integrity protection is provided by HMAC-SHA256 over the raw 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: "<64 hexadecimal characters>"
}
- The current implementation requires a dedicated 32-byte HMAC key encoded as 64 hexadecimal characters.
- The HMAC key must be generated using a cryptographically secure random source.
- The AES key and HMAC key must be different.
- The sender and AdminApi must use the same HMAC key.
- Set
nikHmacKeyin the deployed AdminApiconfig.jsfor each environment. - Do not reuse sample or development 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:
RoomIdandInteractionIdare 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.
- Set
ecvWebAppUrlinWaitForAgent.htmlto the target Web.App base URL. - 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.
- 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
- Back up the current AdminApi, ECVDemo and Web.App deployments and their configuration files.
- Set
nikHmacKeyin the deployed AdminApiconfig.jsto the agreed 64-character hexadecimal key. - Set
nikHmacRequiredtofalsefor the transition period. - Deploy AdminApi.
- Deploy ECVDemo.
- Deploy the updated Web.App files, including
WaitForAgent.htmlandWaitForAgentHmac.html. - Restart the affected services as required.
- Run the verification matrix below.
- After all senders have switched to the authenticated three-segment format and verification is complete, set
nikHmacRequiredtotrue, 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. |