DeviceAuthenticationRotation

Routine device authentication key rotation, format version 1 (docs/device-authentication-rotation.md). All three constructions share the rotation statement:

u32 length | userId (UTF-8) | u32 length | deviceId (UTF-8)
current public key (32)
replacement public key (32)
expected authentication epoch: i64 (>= 1)
timestamp: i64, epoch milliseconds
nonce (16)

and prefix it with u32 length | domain (UTF-8):

  • authorization, Ed25519 by the current key: KSecureMessage-DeviceAuthRotation-v1;

  • proof of possession, Ed25519 by the replacement key: KSecureMessage-DeviceAuthRotation-PoP-v1;

  • DeviceAuthenticationRotationId, SHA-256: KSecureMessage-DeviceAuthRotationId-v1.

Integers are big-endian. The domains keep the three apart from each other, from device recovery and from server request signatures.

Properties

Link copied to clipboard
const val PUBLIC_KEY_SIZE: Int

Size of a device authentication public key (Ed25519).

Link copied to clipboard
const val SIGNATURE_SIZE: Int

Size of a rotation signature (Ed25519).

Link copied to clipboard

Accepted clock difference in each direction: now - VALIDITY_WINDOW <= timestamp <= now + VALIDITY_WINDOW. The same as for server requests and device recovery.

Functions

Link copied to clipboard

The bytes the current key signs.

Link copied to clipboard
fun create(current: DeviceAuthenticationKeyPair, replacement: DeviceAuthenticationKeyPair, address: DeviceAddress, expectedAuthEpoch: Long, timestamp: Instant, nonce: RequestNonce = RequestNonce.random()): DeviceAuthenticationRotationAuthorization

The statement for replacing current (registered for address at expectedAuthEpoch) with replacement, signed by both keys. timestamp is truncated to milliseconds. Throws IllegalArgumentException if both keys are the same.

Link copied to clipboard

The bytes the replacement key signs.

Link copied to clipboard

true if authorization's authorization signature verifies with currentPublicKey. The server passes the registered key. Does not check the proof of possession.

Link copied to clipboard

true if the proof of possession verifies with the statement's replacement key.