Abilita MACsec per le funzionalità Ethernet

Questa pagina spiega come abilitare MACsec per le funzionalità Ethernet.

Utilizza MACsec per autenticare e crittografare la comunicazione Ethernet utilizzata dall'infotainment di bordo (IVI) per diverse unità ECU, proteggendo i dati da manomissioni, riproduzione o divulgazione di informazioni. Fare questo acquistando l'abilitazione di MACsec IEEE 802.11AE per la rete Ethernet.

Panoramica

Per abilitare MACsec, wpa_supplicant viene utilizzato come demone per gestire l'handshake MACsec Key Agreement (MKA). Viene definito un HAL MACsec per archiviare in modo sicuro la chiave precondivisa MACsec, denominata chiave di associazione della connettività (CAK). L'HAL MACsec supporta solo CAK. Questo HAL MACsec specifico del fornitore archivia la CAK in modo sicuro in un archivio a prova di manomissione. Il provisioning della chiave dipende dall'implementazione del fornitore.

Flusso MACsec

La Figura 1 illustra il flusso MACsec sull'unità principale.

Figura 1 : flusso MACsec.

Abilita MACsec

Per fornire supporto per le funzionalità con la chiave CAK MACsec, MACsec per Ethernet deve essere abilitato esplicitamente con un HAL MACsec specifico del fornitore.

Per abilitare la funzione, abilitare wpa_supplicant_macsec e il macsec-service specifico del fornitore su PRODUCT_PACKAGES e il file di configurazione per wpa_supplicant_macsec , lo script init rc su PRODUCT_COPY_FILES .

Ad esempio, questo file [device-product].mk :

# MACSEC HAL

# This is a mock MACsec HAL implementation with keys embedded in it. Replace with vendor specific HAL
PRODUCT_PACKAGES += android.hardware.automotive.macsec-service

# wpa_supplicant build with MACsec support

PRODUCT_PACKAGES += wpa_supplicant_macsec

# configuration file for wpa_supplicant with MACsec

PRODUCT_COPY_FILES += \
    $(LOCAL_PATH)/wpa_supplicant_macsec.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wpa_supplicant_macsec.conf \
    $(LOCAL_PATH)/wpa_supplicant_macsec.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/wpa_supplicant_macsec.rc

Ad esempio, wpa_supplicant_macsec.conf .

# wpa_supplicant_macsec.conf
eapol_version=3
ap_scan=0
fast_reauth=1
# Example configuration for MACsec with preshared key
# mka_cak is not actual key but index for MACsec HAL to specify which key to use
# and make_cak must be either 16 digits or 32 digits depends the actually CAK key length.
network={
        key_mgmt=NONE
        eapol_flags=0
        macsec_policy=1
        macsec_replay_protect=1
        macsec_replay_window=0
        mka_cak=00000000000000000000000000000001
        mka_ckn=31323334
        mka_priority=128
}

Esempio wpa_supplicant_macsec.conf su eth0 . Quando più interfacce di rete devono essere protette da MACsec, è possibile avviare più servizi.

# wpa_supplicant_macsec.rc
service wpa_supplicant_macsec /vendor/bin/hw/wpa_supplicant_macsec \
        -dd -i eth0 -Dmacsec_linux -c /vendor/etc/wpa_supplicant_macsec.conf
        oneshot

Avvia wpa_supplicant_macsec dopo che l'interfaccia Ethernet è pronta. Se la rete Ethernet del sistema non è pronta, wpa_supplicant restituisce immediatamente un errore. Per evitare condizioni di competizione, potrebbe essere necessaria un'attesa (il timeout predefinito è cinque (5) secondi) per /sys//class/net/${eth_interface} .

# init.target.rc
on late-fs
    …
    wait /sys/class/net/eth0
    start wpa_supplicant_macsec
    …

Configurare l'indirizzo IP per l'interfaccia MACsec

La configurazione dell'indirizzo IP dell'interfaccia MACsec può essere eseguita dal gestore della connettività del sistema una volta avviato zygote. Di seguito è riportato un esempio di file XML in sovrapposizione per la connettività. Se l'indirizzo IP per l'interfaccia MACsec deve essere pronto prima dell'avvio di zygote, un demone specifico del fornitore dovrebbe ascoltare l'interfaccia macsec0 e configurarla invece poiché il gestore della connettività del sistema si avvia solo dopo l'avvio di zygote.

# Example of com.google.android.connectivity.resources overlay config
<?xml version="1.0" encoding="utf-8"?>
<!-- Resources to configure the connectivity module based on each OEM's preference. -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- Whether the internal vehicle network should remain active even when no
         apps requested it. -->
    <bool name="config_vehicleInternalNetworkAlwaysRequested">true</bool>
    <string-array translatable="false" name="config_ethernet_interfaces">
        <!-- Not metered, trusted, not vpn, vehicle, not vcn managed, restricted -->
        <item>macsec0;11,14,15,27,28;ip=10.10.10.2/24 gateway=10.10.10.1 dns=4.4.4.4,8.8.8.8</item>
    </string-array>
    <string translatable="false" name="config_ethernet_iface_regex">macsec\\d</string>
</resources>

MACsec HAL

L'HAL specifico del fornitore MACsec deve implementare le seguenti funzioni per proteggere la chiave CAK. Tutta la crittografia e decrittografia con la chiave viene eseguita direttamente senza esporre la chiave a wpa_supplicant .

/**
 * MACSEC pre-shared key plugin for wpa_applicant
 *
 * The goal of this service is to provide function for using the MACSEC CAK
 *
 */
@VintfStability
interface IMacsecPSKPlugin {
    /**
     * For xTS test only, not called in production
     *
     * @param keyId is key id to add
     * @param CAK, CAK key to set
     * @param CKN, CKN to set
     *
     * @return ICV.
     */
    void addTestKey(in byte[] keyId, in byte[] CAK, in byte[] CKN);

/** * Use ICV key do AES CMAC same as ieee802_1x_icv_aes_cmac in wpa_supplicant * * @param keyId is key id to be used for AES CMAC * @param data * * @return ICV. */ byte[] calcICV(in byte[] keyId, in byte[] data);
/** * KDF with CAK key to generate SAK key same as ieee802_1x_sak_aes_cmac in wpa_supplicant * * @param keyId is key id to be used for KDF * @param seed is key seed (random number) * @param sakLength generated SAK length (16 or 32) * * @return SAK key. */ byte[] generateSAK(in byte[] keyId, in byte[] data, in int sakLength);
/** * Encrypt using KEK key, this is same as aes_wrap with kek.key in wpa_supplicant * which used to wrap a SAK key * * @param keyId is key id to be used for encryption * @param sak is SAK key (16 or 32 bytes) to be wrapped. * * @return wrapped data using KEK key. */ byte[] wrapSAK(in byte[] keyId, in byte[] sak);
/** * Decrypt using KEK key, this is same as aes_unwrap with kek.key in wpa_supplicant * which used to unwrap a SAK key * * @param keyId is key id to be used for decryption * @param sak is wrapped SAK key. * * @return unwrapped data using KEK key. */ byte[] unwrapSAK(in byte[] keyId, in byte[] sak); }

Implementazione di riferimento

Un'implementazione di riferimento è fornita in hardware/interfaces/macsec/aidl/default , che fornisce un'implementazione software dell'HAL con chiavi incorporate al suo interno. Questa implementazione fornisce solo un riferimento funzionale all'HAL poiché le chiavi non sono supportate da un archivio a prova di manomissione.

Testare l'HAL MACsec

Un test HAL MACsec è fornito in hardware/interfaces/automotive/macsec/aidl/vts/functional .

Per eseguire il test:

$ atest VtsHalMacsecPskPluginV1Test

Questo chiama addTestKey - per inserire una chiave di prova nell'HAL e per verificare rispetto ai valori attesi per calcIcv , generateSak , wrapSak e unwrapSak .

Per confermare che MACsec funziona, per i test di integrazione, eseguire il ping tra due macchine nell'interfaccia MACsec:

# ping -I macsec0 10.10.10.1

Per testare Cuttlefish con host, è necessario echo 8 > /sys/devices/virtual/net/cvd-ebr/bridge/group_fwd_mask in host per consentire il passthrough dei frame LLDP richiesti per MACsec.