applyCipherSuiteOverrides function

void applyCipherSuiteOverrides(
  1. String? kex,
  2. String? key,
  3. String? cipher,
  4. String? mac,
)

Limits cipher suite support to the specified parameter, if not null.

Implementation

void applyCipherSuiteOverrides(
    String kex, String key, String cipher, String mac) {
  if (kex != null) {
    final int kexOverride = KEX.id(kex);
    if (kexOverride == 0) {
      throw FormatException(
          'unknown kex: $kex, supported: ${KEX.preferenceCsv()}');
    }
    KEX.supported = (int id) => id == kexOverride;
  }
  if (key != null) {
    final int keyOverride = Key.id(key);
    if (keyOverride == 0) {
      throw FormatException(
          'unknown key: $key, supported: ${Key.preferenceCsv()}');
    }
    Key.supported = (int id) => id == keyOverride;
  }
  if (cipher != null) {
    final int cipherOverride = Cipher.id(cipher);
    if (cipherOverride == 0) {
      throw FormatException(
          'unknown cipher: $cipher, supported: ${Cipher.preferenceCsv()}');
    }
    Cipher.supported = (int id) => id == cipherOverride;
  }
  if (mac != null) {
    final int macOverride = MAC.id(mac);
    if (macOverride == 0) {
      throw FormatException(
          'unknown mac: $mac, supported: ${MAC.preferenceCsv()}');
    }
    MAC.supported = (int id) => id == macOverride;
  }
}