Verhoeff Checksum

This module includes functions for Verhoeff checksum calculation and validation.

Summary

The functions in this module are available when OPENTHREAD_CONFIG_VERHOEFF_CHECKSUM_ENABLE is enabled.

Functions

otVerhoeffChecksumCalculate(const char *aDecimalString, char *aChecksum)
Calculates the Verhoeff checksum for a given decimal string.
otVerhoeffChecksumValidate(const char *aDecimalString)
Validates the Verhoeff checksum for a given decimal string.

Macros

OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH 128
Specifies the maximum length of decimal string input in otVerhoeffChecksum functions.

Functions

otVerhoeffChecksumCalculate

otError otVerhoeffChecksumCalculate(
  const char *aDecimalString,
  char *aChecksum
)

Calculates the Verhoeff checksum for a given decimal string.

Requires OPENTHREAD_CONFIG_VERHOEFF_CHECKSUM_ENABLE.

Details
Parameters
[in] aDecimalString
The string containing decimal digits.
[out] aChecksum
Pointer to a char to return the calculated checksum.
Return Values
OT_ERROR_NONE
Successfully calculated the checksum, aChecksum is updated.
OT_ERROR_INVALID_ARGS
The aDecimalString is not valid, i.e. it either contains chars other than ['0'-'9'], or is longer than OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH.

otVerhoeffChecksumValidate

otError otVerhoeffChecksumValidate(
  const char *aDecimalString
)

Validates the Verhoeff checksum for a given decimal string.

Requires OPENTHREAD_CONFIG_VERHOEFF_CHECKSUM_ENABLE.

Details
Parameters
[in] aDecimalString
The string containing decimal digits (last char is treated as checksum).
Return Values
OT_ERROR_NONE
Successfully validated the checksum in aDecimalString.
OT_ERROR_FAILED
Checksum validation failed.
OT_ERROR_INVALID_ARGS
The aDecimalString is not valid, i.e. it either contains chars other than ['0'-'9'], or is longer than OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH.

Macros

OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH

 OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH 128

Specifies the maximum length of decimal string input in otVerhoeffChecksum functions.

Resources

OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.