aesEcbEncrypt function

Uint8List aesEcbEncrypt(
  1. Uint8List keyBytes,
  2. Uint8List plaintext
)

Performs AES in ECB mode for Header Protection.

Implementation

Uint8List aesEcbEncrypt(Uint8List keyBytes, Uint8List plaintext) {
  if (keyBytes.length != 16 && keyBytes.length != 24 && keyBytes.length != 32) {
    throw ArgumentError("Invalid AES key size: ${keyBytes.length} bytes.");
  }

  // The plaintext for header protection MUST be 16 bytes.
  if (plaintext.length % 16 != 0) {
    throw ArgumentError("Plaintext length must be a multiple of 16 bytes.");
  }

  // Perform ECB encryption (Placeholder for crypto library function)
  final encrypted = aesEcbEncryptPrimitive(key: keyBytes, plaintext: plaintext);
  return encrypted;
}