From owner-svn-src-all@freebsd.org Sat Sep 3 17:24:03 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 87ADBBCE32C; Sat, 3 Sep 2016 17:24:03 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.blih.net", Issuer "mail.blih.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9D0A19D9; Sat, 3 Sep 2016 17:24:01 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id 277859ca; Sat, 3 Sep 2016 19:17:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mail; bh=18/3zrX5Dx7hZLvpb8YRjcFr91k=; b=hvpSDBE2QT+A8WDq90qJxcmQU7hA e2WlbmqJ2dDb1VyVTOmdm3BB9IuMlt4jNKOFVRSEdqOXMReLcYnB9qPAiPgBm3tn +r83JXgBlqRYosv8815LT+g614B6dwpjArRiIc5b1RM1/5HlbO1Nz611btHPI3ni 4l7DkjCysn/1+HU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= mail; b=j+0PJYSYHUP1gNifBJ9VcKVQ7qbZ0PS1rIe5e/qvaGYOFsqfZBnU01Fa q+wOgfB+8gJk/lKT/iABjYd8pPr9wnlHa66LDq8iJProLFVWtQo58oKgALJug3AW EZmtjhMxhOhKxuPrY5F+4TAG1PMm5MMwgGh2YCagNohOeFpEq3c= Received: from knuckles.blih.net (ip-54.net-82-216-203.roubaix.rev.numericable.fr [82.216.203.54]) by mail.blih.net (OpenSMTPD) with ESMTPSA id a3e34022 TLS version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Sat, 3 Sep 2016 19:17:19 +0200 (CEST) Date: Sat, 3 Sep 2016 19:17:17 +0200 From: Emmanuel Vadot To: Jared McNeill Cc: Oliver Pinter , 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: <20160903191717.437e45cb8d0d612211bdc0c5@bidouilliste.com> In-Reply-To: References: <201609031528.u83FS91u017461@repo.freebsd.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.29; amd64-portbld-freebsd12.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 17:24:03 -0000 I'll add that everybody uses this as a serial number. Since thoses are efuses, you can't change it unless a specific voltage is applied to a certain pin (which is tied to GND on every board), but no one have tried to do that. There might be some way do restrict reading that key a there is also some configuration fuses but the documentation doesn't say much about this peripheral. You can check http://linux-sunxi.org/SID for (a little) more information. On Sat, 3 Sep 2016 14:06:37 -0300 (ADT) 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" > >> > > > > -- Emmanuel Vadot