Skip to content

Configuration

Inspecting Configuration

getConfiguration()

Return the decoder’s current configuration: systemIdentifier, applicationId, sdmSettings, and keys (each entry is { masterKey (32-hex upper), diversify }).

const config = decoder.getConfiguration();

Returns

{
systemIdentifier: 'CRYPTAG',
applicationId: '3042F5',
sdmSettings: {
sdmMetaRead: 'free',
sdmFileRead: 2,
cmacSeparator: '&cmac='
},
keys: {
'0': { masterKey: '00000000000000000000000000000000', diversify: false },
'1': { masterKey: 'D3F7A91C5E08B264A1F9C7E03B5D8A42', diversify: true },
'2': { masterKey: 'D3F7A91C5E08B264A1F9C7E03B5D8A42', diversify: true },
'3': { masterKey: '00000000000000000000000000000000', diversify: false },
'4': { masterKey: '00000000000000000000000000000000', diversify: false }
}
}

getKey(keyNo, uid?)

Return the key for an operation, diversified when configured and a UID is given (results are cached). Throws on an invalid key number or diversification failure.

const key = decoder.getKey(2, '04A1B2C3D4E580');

Returns a Buffer

// → <Buffer 9a 4c 21 ef 7b 03 d8 56 1f c2 a0 9e 64 b7 35 8d>

Updating Keys & Parameters

updateKey(keyNo, config)

Update a single key ({ masterKey, diversify }) and clear the diversification cache. Throws if keyNo is out of range (0-4) or the config is invalid.

decoder.updateKey(2, { masterKey: 'D3F7A91C5E08B264A1F9C7E03B5D8A42', diversify: true });

Returns void

// → undefined

setKeys(keyList?)

Replace the entire key list. Re-validates every entry and clears the cache. Throws if any key configuration is invalid or diversification parameters fail validation.

decoder.setKeys({
'0': { masterKey: '00000000000000000000000000000000', diversify: false },
'2': { masterKey: 'D3F7A91C5E08B264A1F9C7E03B5D8A42', diversify: true }
});

Returns void

// → undefined

setParameters(settings?)

Update diversification / SDM settings. Validated, rolled back on error, and clears the cache. settings accepts systemIdentifier, applicationId, and sdmSettings.

decoder.setParameters({
systemIdentifier: 'CRYPTAG',
applicationId: '3042F5',
sdmSettings: { sdmMetaRead: 'free', sdmFileRead: 2, cmacSeparator: '&cmac=' }
});

Returns void

// → undefined