Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1797186pxb; Mon, 11 Oct 2021 13:21:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz62Ybjh45AP5IlQ197jewBpcqfT+cGCO+f0reeu9n84g/BH/vTN5WKlJe0UHfblp1bw+UM X-Received: by 2002:a17:906:7854:: with SMTP id p20mr5828407ejm.19.1633983700776; Mon, 11 Oct 2021 13:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633983700; cv=none; d=google.com; s=arc-20160816; b=pTJhlfqkiJkhIvmMrsXhYd4TX77lGfTA69Eb9ubEb0y2VCmW7r91lJlHE+1fasujn8 mrp8MBX24pVT49o/+sP7V8hGlEDTD4uQk/zfkdXbPZa1mhDB9PZECaoUr/+7ty28KPVM f3C2jNmycKBbPrHv/AQwV9FtJLte9gfpSC33FoDJpJgw13ES9z2uo8R7p9gCb2Fnprc8 xIqer1IGnhnFlqGCxU2RpO2I5nJodNTrg8eHcldX9Zssdvty2S3vVJOE/qIF5kWhDVxr I6A3zbGjhmKgTluTHb3FFW6SsOQdfPxOsMw7gb/4vlcWkPe2RNzZxhe9YzarloJb2tVv gsZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=XtTy8WvQ0hpoqhC3rfRnrj4NdBBNddupmEQ5INjAsvw=; b=cHK6GLEBmbtEFUDcLHfgPtH79LJIWWMKTduuZFeC3x5GFFiEx9SVQ3g10EsOcaSL+a SHxJXjXeuFmYIeghNOvkBJ6D1RvNOR6LulrTo8zHgUVYqDgly0pmSo+59ZW0wCffhVqy fG8vZLbqiXiT6semRXHAKHtWZre1oYld7Q504olsQLkIAH9ke9gKoWUOoncvHYfyTbr6 rjuYPvRfuiYTs7w5JNRwbylxanV73XOThU2AO/jalSQecG1URpXxPgLOHudkIUohyOU4 2S5Vs/J9vtHx2kLdcIoYRk2AOWbbvG2cXsJ7mPj1zTBVVR4iuiScif0p1Ym6fx83SEBx eO8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o11si11238468edc.51.2021.10.11.13.21.03; Mon, 11 Oct 2021 13:21:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234909AbhJKUWk (ORCPT + 99 others); Mon, 11 Oct 2021 16:22:40 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:50860 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234867AbhJKUWk (ORCPT ); Mon, 11 Oct 2021 16:22:40 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 19BKKZLi029752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 16:20:36 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 7057815C00CA; Mon, 11 Oct 2021 16:20:35 -0400 (EDT) Date: Mon, 11 Oct 2021 16:20:35 -0400 From: "Theodore Ts'o" To: Avi Deitcher Cc: linux-ext4@vger.kernel.org Subject: Re: algorithm for half-md4 used in htree directories Message-ID: References: <3A493D20-568A-4D63-A575-5DEEBFAAF41A@dilger.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Oct 11, 2021 at 08:30:36AM -0700, Avi Deitcher wrote: > Does someone know how this is constructed and used? > > On Mon, Oct 4, 2021 at 12:57 AM Avi Deitcher wrote: > > > > Hi Andreas, > > > > I had looked in __ext4fs_dirhash(). Yes, it does reference the seed - > > and create a default if none is there at the filesystem level - but it > > doesn't appear to use it, in that function. hinfo is populated in the > > function - hash, minor-hash, seed - but it never uses the seed to > > manipulate the hash. The seed is used to initialize the buf array, so long as the seed is not all zero's. If it is all zeros, then the default seed is used instead (right above this bit of code: if (hinfo->seed) { for (i = 0; i < 4; i++) { if (hinfo->seed[i]) { memcpy(buf, hinfo->seed, sizeof(buf)); break; } } } The legacy hash doesn't use the seed, yes. But for the other hash types (hash_version), they mix the filename (in different ways depending on the hash type. For example, for half md4: case DX_HASH_HALF_MD4: p = name; while (len > 0) { (*str2hashbuf)(p, len, in, 8); half_md4_transform(buf, in); ^^^ len -= 32; p += 32; } minor_hash = buf[2]; hash = buf[1]; break; When the hash seed is different, that means the initial state of the buf array will different, and this influences the resulting hash. Cheers, - Ted