calculateSessionKeys static method

  1. @visibleForTesting
Pair<Uint8List, Uint8List> calculateSessionKeys({
  1. required Uint8List Kifd,
  2. required Uint8List Kicc,
})

Calculates Session keys KSenc and KSmac from Kifd and Kicc.

Implementation

@visibleForTesting
static Pair<Uint8List, Uint8List> calculateSessionKeys(
    {required final Uint8List Kifd, required final Uint8List Kicc}) {
  assert(Kifd.length == kLen);
  assert(Kicc.length == kLen);

  // Generate key seed
  final keySeed = Uint8List(kLen);
  for (int i = 0; i < Kifd.length; i++) {
    keySeed[i] = Kifd[i] ^ Kicc[i];
  }

  // Derive keys from key seed
  final KSenc = DeriveKey.desEDE(keySeed);
  final KSmac = DeriveKey.iso9797MacAlg3(keySeed);
  return Pair<Uint8List, Uint8List>(KSenc, KSmac);
}