Abilita MACsec per le funzionalità Ethernet

In questa pagina viene spiegato come abilitare MACsec per le funzionalità Ethernet.

Utilizza MACsec per autenticare e criptare la rete Ethernet la comunicazione utilizzata dal sistema di infotainment del veicolo (IVI) per le varie unità della ECU, proteggendo i dati da manomissioni, riproduzioni o divulgazione di informazioni. Attivazione di Do this Buy MACsec IEEE 802.11AE per la rete Ethernet.

Panoramica

Per abilitare MACsec, wpa_supplicant viene utilizzato come daemon per la gestione di handshake MACsec (Key Agreement) (MKA). Per l'archiviazione di MACsec viene definito un HAL MACsec chiave precondivisa, chiamata chiave di associazione della connettività (CAK) in modo sicuro. MACsec HAL supporta solo CAK. Questo MACsec HAL specifico del fornitore archivia la CAK in modo sicuro in una manomissione un'archiviazione resistente. Il provisioning della chiave dipende dall'implementazione del fornitore.

Flusso MACsec

La figura 1 mostra 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 esplicitamente con un MACsec HAL specifico del fornitore.

Per attivare la funzionalità, abilita wpa_supplicant_macsec e la funzionalità specifica del fornitore Da macsec-service a PRODUCT_PACKAGES e il file di configurazione per wpa_supplicant_macsec, init rc script per 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
}

Anteprima di wpa_supplicant_macsec.conf su eth0. Quando vengono usate più reti devono essere protette da MACsec, puoi 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 quando l'interfaccia Ethernet è pronta. Se la rete Ethernet di sistema non è pronta, wpa_supplicant restituisce immediatamente un errore. Per evitare le condizioni di gara, il tempo di attesa (il timeout predefinito è cinque (5) secondi) per Potrebbe essere necessario /sys//class/net/${eth_interface}.

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

Configura l'indirizzo IP per l'interfaccia MACsec

La configurazione dell'indirizzo IP dell'interfaccia MACsec può essere eseguita dalla connettività di sistema una volta avviato lo zygote. Ecco un esempio di file XML di overlay per la connettività. Se L'indirizzo IP per l'interfaccia MACsec deve essere pronto prima dell'avvio di zygote, un indirizzo IP il daemon deve ascoltare l'interfaccia macsec0 e configurarla, dato che gestione connettività di sistema viene avviata 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>

HAL MACsec

L'HAL specifico del fornitore MACsec deve implementare le seguenti funzioni per proteggere la CAK chiave. Tutte le operazioni di crittografia e decriptazione con la chiave vengono eseguite direttamente senza esporre la chiave 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 dei riferimenti

Un'implementazione di riferimento viene fornita in hardware/interfaces/macsec/aidl/default, che fornisce un software implementazione dell'HAL con chiavi incorporate. Questa implementazione fornisce solo un riferimento funzionale all'HAL poiché i tasti non sono supportati da un'archiviazione a prova di manomissione.

Testa MACsec HAL

Viene fornito un test HAL MACsec in hardware/interfaces/automotive/macsec/aidl/vts/functional.

Per eseguire il test:

$ atest VtsHalMacsecPskPluginV1Test

Questo chiama addTestKey-- per inserire una chiave di test nell'HAL ed eseguire la verifica rispetto valori previsti per calcIcv, generateSak, wrapSak e unwrapSak.

Per verificare che MACsec funzioni correttamente, per i test di integrazione, esegui il ping tra due macchine nel Interfaccia MACsec:

# ping -I macsec0 10.10.10.1

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