Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id 5190E781A6C for <~alpine/apk-tools@lists.alpinelinux.org>; Sun, 11 Oct 2020 07:00:36 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id d24so15052875lfa.8 for <~alpine/apk-tools@lists.alpinelinux.org>; Sun, 11 Oct 2020 00:00:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nVcC0YtUtEZcguDKOsg+DWggak1Y7tcUr5KtrfNk/i0=; b=s57wWdaCp8BFbFcOESkm6ioLC9TIHQAPElBd3okDh1CtDcgJfXHLO9HC28DS7FUFth sd3G0EemUEdZCiDq3USrZBRffJLMM3auHBPeJMyFP+tOtLgiKAwEEqg4qMUhJ2h6dQVK 4Ok/VkfOEiP8uK+Dne+vPfizyj0l42FcGqij0UsNZ+kkyZVCg5MShcy4u5xD+FfjdVNJ AGTnBwCxvCocRRscGT9x6eISCWkcMyrW11/fU/VjfmM066fxGDI9HCtkzGCO5NTArLLp kOaSPLOr6h8UUjfPj3FXRBXF78WMMmSCsVmJTTnvOkxohO+DX4dEwKhnmrPFteNdzgmR KvEg== X-Gm-Message-State: AOAM532EphwAiZs0nyoOCvmSnsJAbstvK3jlA3jmWjsaWAyFEDAJmNf/ Ut0W8B7Tj6e39+yhJx99a4A= X-Google-Smtp-Source: ABdhPJwe1j74rZgOdT0ZPVYkFljaW78OYCbPXKLZ55BLIDUa0E/hYGgPzTRt9naeZgsZqGOvn5X8wQ== X-Received: by 2002:ac2:59d9:: with SMTP id x25mr5980137lfn.4.1602399634511; Sun, 11 Oct 2020 00:00:34 -0700 (PDT) Received: from vostro.wlan (dzyzbhyy848f9vd7ffxvt-3.rev.dnainternet.fi. [2001:14ba:a028:1300:1cc7:9d8:8f64:24e3]) by smtp.gmail.com with ESMTPSA id t17sm2315385lft.104.2020.10.11.00.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Oct 2020 00:00:34 -0700 (PDT) Date: Sun, 11 Oct 2020 10:00:31 +0300 From: Timo Teras To: "Paul Spooren" Cc: <~alpine/apk-tools@lists.alpinelinux.org> Subject: Re: Support for alternative crypto libraries Message-ID: <20201011100031.005fbd8c@vostro.wlan> In-Reply-To: References: X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-alpine-linux-musl) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi, On Sat, 10 Oct 2020 10:40:48 -1000 "Paul Spooren" wrote: > I'm new to this list and hope this RFC like question is fine! > > >From my understanding APKs security is entirely based on > >`libopenssl`, > used for both HTTPS in `libfetch` and for package signature validation > via public keys. Correct. openssl (or libressl) has been de facto standard for the targets we've had so far. > Are there any intentions or interest to allow different libraries for > either use case? I'm asking because I'd like to see APK as a > replacement for OpenWrts current package manager (`opkg`), but the > libssl/libcrypto combination is to heavy for most WiFi routers. Nice! So far our "embedded" has been low end ARMv6+ chips. Generally RPI1/2 being the target. And in fact running apk with full alpine indexes there is starting to be slowing down. So this was another motivation for the v3 changes. I understand you are interested running on even more resource constrained environment. And I'd be happy to support where possible. I understand this might also mean additional options to reduce index size etc. > OpenWrt traditionally uses unencrypted HTTP to download packages and > verifies them via a `signify`[1] fork called `usign`[2]. Both public > keys and signatures are extremely small, ideal for embedded devices. > > To be *OpenWrt compatible* I'd like to integrate a curve based > signature method, e.g. Ed25519 like `signify` or Curve25519/Gimli > based like `libhydrogen`[3]. The latter comes with its own secure > hashing mechanism and takes about 50Kb as a shared library. Which hash? Would it make sense then to use that hash for file integrity checks during extraction and 'audit' command? It might make sense to make Ed25519 the default for both builds. I assume the same crypto primitives are available also from openssl? Preferable then the openssl would be exetended to support also these. > Looking at the APK code some wrappers around the hashing/verifying > could do the trick, some `ifndef` within `libfetch` could disable > HTTPS support (and thereby lose the `libopenssl` dependency. > > As v3 seems to be changing quite some things, if now is the right time > to discuss such changes. Yes. Thin wrappers in separate file, perhaps in the new apk_trust.h or separate apk_crypto.h depending how much it ends up being in code lines. Optionally disabling https in libfetch also sounds acceptable. As noted the v3 is currently in state of flux, and I'm hoping to next start reworking the info/search/list type applets that do read-only operations. So for the adb format these are welcome now. I still need let some time to pass to see if we can make the new package format (Adb based) happen sooner than later, and the adb changes alone would be enough. Depending on time pressure and how things go, we can consider also amending the current .apk format (but obviously I'd want to avoid that if possible). Cheers, Timo