nextAuthenticationGeneration method

int nextAuthenticationGeneration(
  1. String enrollmentId,
  2. CryptographicMaterialAlgorithm algorithm
)

The generation number fileApkamMaterial will use next for enrollmentId's algorithm — one past the highest already filed, or 1.

Derived from the keyIds present rather than counted separately, so it cannot drift from what the file actually holds. An id whose suffix is not a number is ignored rather than rejected: a keyfile written by a build that spells generations differently must still be readable.

Implementation

int nextAuthenticationGeneration(
        String enrollmentId, CryptographicMaterialAlgorithm algorithm) =>
    _nextGeneration(
        _enrollments[enrollmentId]?.materialsByKeyId.keys ?? const [],
        keyIdPrefix('auth', algorithm));