Home >

ProtectToolkit-C Programming Guide > Object Classes > Monotonic Counter Objects

Monotonic Counter Objects

Monotonic counter objects represent hardware counters that exist on the device. Also:

The value of the counter is guaranteed to increase by 1 each time it is read.

The monotonic counter is supported only on soft (non-smart card based) tokens and the value of the counter on each different token is the same. 

There is only one monotonic counter per token.

The monotonic counter is automatically created whenever a token is initialized and exists by default on the Admin Token.

The value is interpreted as a 160-bit big-endian binary integer (MSB on left).

The Token SO may change the count value by setting the CKA_VALUE attribute.

Table 1: Monotonic Counter Attributes

Attribute

Data Type

Meaning

CKA_RESET_ON_INIT1 CK_BBOOL

The value of the counter will reset to a previously returned value if the token is initialized using C_InitializeToken.

CKA_HAS_RESET1 CK_BBOOL

The value of the counter has been reset at least once at some point in time. 

CKA_VALUE

Byte Array

The current version of the monotonic counter. The value is returned in big endian order. This value must be 20 bytes in size. Any attempt to set a value less than 20 bytes will fail.

1 Read Only. The CKA_VALUE attribute may not be set by the client.