[devel] RFC: girar: optimize rebuild

Alexey V. Vissarionov gremlin на altlinux.org
Вс Апр 12 02:31:43 MSK 2020


On 2020-04-11 13:36:31 +0300, Andrey Savchenko wrote:

 >> The first part of rebuilt packages optimization for girar.
 >> It introduces pkg_identity() and simple optimization of the
 >> rebuilt sourcerpm.
 >> pkg_identity() takes RPM package and returns a value called
 >> package identity, a hash of subset of RPM package header.
 >> That subset is the entire header without some nonessential
 >> artifacts like buildhost, buildtime, header hashsum, etc.
 > I see two problems with proposed approach:
 > 1) It assumes there will be not pkg_identity hash collisions.
 > This is wrong. They may occur sooner or later and the code
 > *must* correctly deal with such collisions.

The solution is well known: prefix the hash with a time_t value
to let it grow monotonously while still being strictly dependent
on sensitive data.

Whether we'd face a hash collision, we could check whether the
timestamps differ significantly.

 > 2) The hash function choise — sha256 ­— is very unfortunate:
 > it has longer digest than sha1, but otherwise is vulnerable
 > to the same attack; so right now it is still marginally secure,
 > but it will not last long.
We don't really need any cryptographic-grade hash function here:
all we need is just a checksum with a good distribution to detect
whether something had changed - obviously enough, nobody would
try to build and exploit collisions here. Said that, we can use
almost any polynomial.

 > Moreover sha256 is quite slow.

SHA2 is implemented in the hardware in some modern CPUs, so it's
quite fast there.

 > It is better to use newer generation of hash functions, e.g.
 > blake2b based on the chacha stream cipher.

Both are still quite marginal... but, once again, we should not
care of that too much - any hash function would do the job. Even
if we'd switch to another polynomial in the future.


-- 
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net


Подробная информация о списке рассылки Devel