From owner-svn-src-all@freebsd.org Sat Sep 3 19:16:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7A6ABCE19C for ; Sat, 3 Sep 2016 19:16:54 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7E3A4351 for ; Sat, 3 Sep 2016 19:16:54 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-wm0-x22f.google.com with SMTP id 1so77825966wmz.1 for ; Sat, 03 Sep 2016 12:16:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=IRGa1oz5jruMBwRS/e6RcXfcfP/VmMTJwQNVTi0LT0M=; b=03vQUrhh+CFPK9ch+1uCCZh4NM/PEdjw5m1lx+Ubv8kMGoBJSIk6YcOZ0uvh3CIniy Tb0o5GQnmCL2Ijp0kdShL8Mi2TEUos0Ggv7FOncVvFyJlmgDBj4ckeK8FsEJRj7bxjhp E+FpgctubzaB3RGpKFEe9GRTTeENns76P0Cgz6jnBXlFw/PwHHLvxBgX3611zNEO0PjL QFyuRrySmzZklyEuEbZmEcAZMfw9tgL/vb/+CidGHR6tqQ9vFgu8flyieW5WUJxoVUF0 yD8f15qmBnih9sKsdyOqGMMc6/hElYsVnp5HFI3mhOT2Ev0bogHXeteIGszz/j1dm5mT HIVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=IRGa1oz5jruMBwRS/e6RcXfcfP/VmMTJwQNVTi0LT0M=; b=KEssjlvexeFQs3pc98Psf5R53DioFRe+CEsqaHAxxA4IhpzRpQiiSb0iGHpVLfXUBq BjJ5nBu5rFownyQo68QwsjmzEMz+ufWyDoP0EKjv5XtjK+f+Fm2tPHyLxp3jfp6Gie4s XBzz0BpBQCYrtJLf9RnoVpo3UGyFc8ZrieI1ds60p0Yiw8h1pNooNMElwQBaiG6Aef40 gy6jM6MMC45755tmM7hwXJ5IhlG6WiThJubUGSB1FXmfDsOwfvd7VTiJipJ4Tygqp26/ 3k04GYh9FGkfqbWEfbC0FFtp7hYIywDRb2oiZA3YIop+YxrrPhKKacicqAqrPMB6NlY4 esOg== X-Gm-Message-State: AE9vXwOBseHv6NQ5VB1/yziQBSSrz2cS71NdzBYm3EZhXs/uUzUgVPJ6nlN4HSN/m4L+/AYRU3t5qrADGmzde+cB X-Received: by 10.194.144.114 with SMTP id sl18mr24828466wjb.123.1472930212473; Sat, 03 Sep 2016 12:16:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.236.231 with HTTP; Sat, 3 Sep 2016 12:16:51 -0700 (PDT) In-Reply-To: References: <201609031528.u83FS91u017461@repo.freebsd.org> From: Oliver Pinter Date: Sat, 3 Sep 2016 21:16:51 +0200 Message-ID: Subject: Re: svn commit: r305354 - head/sys/arm/allwinner To: Jared McNeill Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Sep 2016 19:16:55 -0000 Hi! Thanks for explanation. The feature's name is very misleading... On 9/3/16, Jared McNeill wrote: > Hi Oliver -- > > It's really just a serial number. The Allwinner A20 datasheet refers to it > as a root key, later ones such as A83T refer to it as chip ID. U-Boot > uses the same process to generate MAC addresses for all Allwinner boards. > > Cheers, > Jared > > > On Sat, 3 Sep 2016, Oliver Pinter wrote: > >> Hi! >> >> On 9/3/16, Jared McNeill 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 >>> >>> #include >>> +#include >>> #include >>> #include >>> >>> @@ -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" >>> >> >> >