Date: Sat, 3 Sep 2016 17:47:11 +0200 From: Oliver Pinter <oliver.pinter@hardenedbsd.org> To: Jared McNeill <jmcneill@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r305354 - head/sys/arm/allwinner Message-ID: <CAPQ4ffs%2BdexyyewdwLg1Hp1j30Yn5Lfu5uajzVy99sgwBjNXAA@mail.gmail.com> In-Reply-To: <201609031528.u83FS91u017461@repo.freebsd.org> References: <201609031528.u83FS91u017461@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi! On 9/3/16, Jared McNeill <jmcneill@freebsd.org> wrote: > Author: jmcneill > Date: Sat Sep 3 15:28:09 2016 > New Revision: 305354 > URL: https://svnweb.freebsd.org/changeset/base/305354 > > Log: > Use the root key in the Security ID EFUSE (when valid) to generate a > MAC address instead of creating a random one each boot. Could you please describe a little more about this root key? What is it? What's the main purpose? Is is a crypto root key? > > Modified: > head/sys/arm/allwinner/if_awg.c > > Modified: head/sys/arm/allwinner/if_awg.c > ============================================================================== > --- head/sys/arm/allwinner/if_awg.c Sat Sep 3 15:26:28 2016 (r305353) > +++ head/sys/arm/allwinner/if_awg.c Sat Sep 3 15:28:09 2016 (r305354) > @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); > #include <dev/ofw/ofw_bus_subr.h> > > #include <arm/allwinner/if_awgreg.h> > +#include <arm/allwinner/aw_sid.h> > #include <dev/mii/mii.h> > #include <dev/mii/miivar.h> > > @@ -1277,6 +1278,7 @@ awg_get_eaddr(device_t dev, uint8_t *ead > { > struct awg_softc *sc; > uint32_t maclo, machi, rnd; > + u_char rootkey[16]; > > sc = device_get_softc(dev); > > @@ -1285,9 +1287,19 @@ awg_get_eaddr(device_t dev, uint8_t *ead > > if (maclo == 0xffffffff && machi == 0xffff) { > /* MAC address in hardware is invalid, create one */ > - rnd = arc4random(); > - maclo = 0x00f2 | (rnd & 0xffff0000); > - machi = rnd & 0xffff; > + if (aw_sid_get_rootkey(rootkey) == 0 && > + (rootkey[3] | rootkey[12] | rootkey[13] | rootkey[14] | > + rootkey[15]) != 0) { > + /* MAC address is derived from the root key in SID */ > + maclo = (rootkey[13] << 24) | (rootkey[12] << 16) | > + (rootkey[3] << 8) | 0x02; > + machi = (rootkey[15] << 8) | rootkey[14]; > + } else { > + /* Create one */ > + rnd = arc4random(); > + maclo = 0x00f2 | (rnd & 0xffff0000); > + machi = rnd & 0xffff; > + } > } > > eaddr[0] = maclo & 0xff; > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPQ4ffs%2BdexyyewdwLg1Hp1j30Yn5Lfu5uajzVy99sgwBjNXAA>