[U-Boot] [PATCH 1/3 v2] Exynos: Add hardware accelerated SHA 256

Kim Phillips kim.phillips at freescale.com
Thu Feb 28 21:10:23 CET 2013


On Thu, 28 Feb 2013 06:00:21 -0500
Akshay Saraswat <akshay.s at samsung.com> wrote:

> ---
> Changes since v1:
> 	- Moved code to drivers/crypto.
> 	- Fixed few other nits.

be more specific wrt changes between revisions.

> +	if (buf_len == 0) {
> +		/* ACE H/W cannot compute hash value for empty string */
> +		if (hash_type == ACE_SHA_TYPE_SHA1)
> +			memcpy(pout, sha1_digest_emptymsg, SHA1_SUM_LEN);
> +		else
> +			memcpy(pout, sha256_digest_emptymsg, SHA256_SUM_LEN);
> +		return 0;
> +	} else if (buf_len > BUF_LIMIT) {
> +		debug("%s: Buffer length beyond limit\n", __func__);
> +		return -1;
> +	}

erroring out just because the user asked for a hash on something
larger than 8MB is unacceptable:  any hash implementation that
replaces a corresponding software implementation must not
introduce new limitations and regressions.

If the hardware supports hash updating - which is likely - use
that to perform hashes >8MB.  If not, revert to software. And for
the 0 length case.

> +	start = get_timer(0);
> +
> +	while ((readl(&ace_sha_reg->hash_status) & ACE_HASH_MSGDONE_MASK) ==
> +		ACE_HASH_MSGDONE_OFF) {

alignment - the 'A' in ACE_H*_OFF should fall directly below
the '(' in 'readl('.

> +		if (get_timer(start) > TIMEOUT_MS) {
> +			debug("%s: Timeout waiting for ACE\n", __func__);

see my other email to v1 of this patch wrt timing-out.

> +	len = (hash_type == ACE_SHA_TYPE_SHA1) ? SHA1_SUM_LEN / 4
> +							: SHA256_SUM_LEN / 4;

alignment

a more recent version of checkpatch finds other such problems:

CHECK: No space is necessary after a cast
#610: FILE: drivers/crypto/ace_sha.c:52:
+	struct exynos_ace_sfr *ace_sha_reg =
+		(struct exynos_ace_sfr *) samsung_get_base_ace_sfr();

CHECK: Alignment should match open parenthesis
#630: FILE: drivers/crypto/ace_sha.c:72:
+	writel(ACE_HASH_SWAPDI_ON | ACE_HASH_SWAPDO_ON | ACE_HASH_SWAPIV_ON,
+			&ace_sha_reg->hash_byteswap);

CHECK: Blank lines aren't necessary after an open brace '{'
#658: FILE: drivers/crypto/ace_sha.c:100:
+		ACE_HASH_MSGDONE_OFF) {
+

CHECK: space prohibited before semicolon
#673: FILE: drivers/crypto/ace_sha.c:115:
+	for (i = 0; i < len ; i++)

Kim



More information about the U-Boot mailing list