From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b4oM5-0000ZL-D4 for barebox@lists.infradead.org; Mon, 23 May 2016 11:49:06 +0000 From: =?UTF-8?q?Ulrich=20=C3=96lmann?= Date: Mon, 23 May 2016 13:48:42 +0200 Message-Id: <1464004122-15815-3-git-send-email-u.oelmann@pengutronix.de> In-Reply-To: <1464004122-15815-1-git-send-email-u.oelmann@pengutronix.de> References: <1464004122-15815-1-git-send-email-u.oelmann@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 2/2] images: add function to verify checksum in barebox header To: Barebox List RnJvbTogSmFuIEx1ZWJiZSA8amx1QHBlbmd1dHJvbml4LmRlPgoKU2lnbmVkLW9mZi1ieTogSmFu IEx1ZWJiZSA8amx1QHBlbmd1dHJvbml4LmRlPgpTaWduZWQtb2ZmLWJ5OiBVbHJpY2ggw5ZsbWFu biA8dS5vZWxtYW5uQHBlbmd1dHJvbml4LmRlPgotLS0KIGNvbW1vbi9LY29uZmlnICAgICAgICAg fCAgOSArKysrKysKIGNvbW1vbi9NYWtlZmlsZSAgICAgICAgfCAgMSArCiBjb21tb24vYmFyZWJv eC1pbWFnZS5jIHwgODUgKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrKysKIGluY2x1ZGUvY29tbW9uLmggICAgICAgfCAgOSArKysrKysKIDQgZmlsZXMgY2hh bmdlZCwgMTA0IGluc2VydGlvbnMoKykKIGNyZWF0ZSBtb2RlIDEwMDY0NCBjb21tb24vYmFyZWJv eC1pbWFnZS5jCgpkaWZmIC0tZ2l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