From nobody Thu Oct 06 08:38:44 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MjlGF2QYSz4fL7l for ; Thu, 6 Oct 2022 08:38:45 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MjlGF0mGNz3xnY for ; Thu, 6 Oct 2022 08:38:45 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MjlGD6mPDz1BQY for ; Thu, 6 Oct 2022 08:38:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 2968ciBf050168 for ; Thu, 6 Oct 2022 08:38:44 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 2968ci6O050167 for bugs@FreeBSD.org; Thu, 6 Oct 2022 08:38:44 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 266863] SHA512_224_Final() is broken on little-endian machines Date: Thu, 06 Oct 2022 08:38:44 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: sebastian.huber@embedded-brains.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665045525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iM7F2LNM8cpUAnHJHG8oVDfOlV2WYUXPMMuYr+XuTCU=; b=VH6C5VRKEo0JR0GbvvgqoBESblsTeC/huM3UxycmIbLwHFyFzT46m3PAyPlTt708ofoLlq 7frSO2Znjxk7gJYSLd/+dEbZYPTnJblIZRmGrplJrka295zOy81iPRH1tGevXjHZfoJtMt xy1WgNz9osfkApyVNxOeagfDlTnBS8pldkkm911CsAhC3nuxyktsSdS10fQubND8lfjsXE U00b1qbVKmnnaE55wQJfhnSQu1kcew11wJeiuASgyZS+vLnUo2+wMH0sFAwtLTqQki2J5C ZO44PvD9cuA4CjPKChBak68KgNUP0uzeNyfzSsOXEptp/9Ld/cutji8X7Gsluw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665045525; a=rsa-sha256; cv=none; b=buSX1ksHIoVkUGscIMSYIx169rpMjkeACYVCmNfm9xb+NUoIQX6CA3VJWQsAwrXWvf6oAQ +eyqMA9zCjaMz8GGq3kH8xf247AX+VWRLShF+yigmLB8FFrPiOjbHszfgslzDXfKAXJrYG h4cg7MZeH8edeeKgdbDduf6q0PATDtAYsJaEPShb+2BYYRZXgWwnDxgLdufVOeixWh0QNO LlkVqFuRLTAxkjHh0F4ntELjNy2R4e+vbCIysTaianuopPMYitnd8sI3NAmvxvySaCo62R bDQgA3mURl5DWWq3Zk4yMGLhvFkqNZV+5QmQFy1q+5UCZCua5AXGMgfgUKTM1A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D266863 Bug ID: 266863 Summary: SHA512_224_Final() is broken on little-endian machines Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: misc Assignee: bugs@FreeBSD.org Reporter: sebastian.huber@embedded-brains.de I am referring to the SHA512_224_Final() implementation in sys/crypto/sha2/sha512c.c: void SHA512_224_Final(unsigned char digest[static SHA512_224_DIGEST_LENGTH], SHA512_CTX * ctx) { /* Add padding */ SHA512_Pad(ctx); /* Write the hash */ be64enc_vect(digest, ctx->state, SHA512_224_DIGEST_LENGTH); /* Clear the context state */ explicit_bzero(ctx, sizeof(*ctx)); } We have #define SHA512_224_DIGEST_LENGTH 28 which is not a multiple of 8. We have for little-endian machines: /* * Encode a length len/4 vector of (uint64_t) into a length len vector of * (unsigned char) in big-endian form. Assumes len is a multiple of 8. */ static void be64enc_vect(unsigned char *dst, const uint64_t *src, size_t len) { size_t i; for (i =3D 0; i < len / 8; i++) be64enc(dst + i * 8, src[i]); } The result is that the last 32-bits of the digest are not written. --=20 You are receiving this mail because: You are the assignee for the bug.=