Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91966 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99782 invoked from network); 27 Mar 2016 02:04:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Mar 2016 02:04:28 -0000 Authentication-Results: pb1.pair.com header.from=scott@paragonie.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=scott@paragonie.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain paragonie.com designates 209.85.218.41 as permitted sender) X-PHP-List-Original-Sender: scott@paragonie.com X-Host-Fingerprint: 209.85.218.41 mail-oi0-f41.google.com Received: from [209.85.218.41] ([209.85.218.41:33197] helo=mail-oi0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/A3-03797-8AF37F65 for ; Sat, 26 Mar 2016 21:04:26 -0500 Received: by mail-oi0-f41.google.com with SMTP id d205so134490706oia.0 for ; Sat, 26 Mar 2016 19:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragonie-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=H0FFgG9tLrxlKA6jP6+/z6cvyrv2SPw3td65QdaKOrg=; b=uLFMqQep3nPRzzBIYHY9S+sWxJQH1K+FOECzSDxN0FlwDQrXvFp3tSdweC8RRvHIWS +k2OyFMWLeI9XA2JItl3y6zVqeKunxT3oYgxHrAqaQ6+Md7/VyAOnnaWkGMIM2KRnT8Z 3V5veDtwxRFZRZTBxN4ukdlv4FgGIII1AG4+u4NCitiB2pn0B+0oF/S5LjL0ZFPAkoke /Lhz+iOQWhz1pSzX+s3bNk3lX8tf3u5cQ/8JPVuo9K9LHQ649A68nhCJM1V/Ij1fEdom iG1sAGFDr5SHEqJT94iGVff96iKCzuaY8jGwLcaHMpZQSCtDzLUFZ+vriUGxQaBwbbFn hKpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=H0FFgG9tLrxlKA6jP6+/z6cvyrv2SPw3td65QdaKOrg=; b=BHnvWS/yABKS6t2jPTTCxeE2VybYVrkwSRn4SD8AZEgeUf+s3vcPVrqakbikwuMnc7 U7oahrf0NGUmfujPdW8RDC5kpJYDvjwNXSMlkf7TBwoEBHkvoPC1Sg184e86zUNAR6Tw kv70V/4sIfMBw/14/6Rzqxjj9pSYiKtdkqJL2fdg62Tu/HKzx4ADhfMmQmnRQFFgrXjA ABxR3QdL2NZXWuNRKaPMAyvYVzaO2Pcy4g+yC8BYL0CmgavM6y5CYqsu8D6abOeTms2B SIwvWmkqtXtGfzF/qP7/NGiuVOKwp5TN4CE4vqsXy6MWGoMKQLQgj/q+deIPYtdIiRDu Wa9A== X-Gm-Message-State: AD7BkJKAwOHcTLk8oIirZ/sTynEJMSYfXYKWQ0NPS7iHtDHBo0MaBKXJzlDjtbFLp4N9oZ8ht+OW0BIR3gobzA== MIME-Version: 1.0 X-Received: by 10.202.74.132 with SMTP id x126mr2243194oia.45.1459044262157; Sat, 26 Mar 2016 19:04:22 -0700 (PDT) Received: by 10.157.14.42 with HTTP; Sat, 26 Mar 2016 19:04:22 -0700 (PDT) In-Reply-To: <105488689.506.427e4c07-ed66-4bbb-aea2-097c92d2538e.open-xchange@myra232.schumann.net> References: <56F7398A.5050002@gmail.com> <105488689.506.427e4c07-ed66-4bbb-aea2-097c92d2538e.open-xchange@myra232.schumann.net> Date: Sat, 26 Mar 2016 22:04:22 -0400 Message-ID: To: Sascha Schumann Cc: Stanislav Malyshev , PHP Internals Content-Type: multipart/alternative; boundary=001a113dc710f53943052efe3679 Subject: Re: [PHP-DEV] [RFC] RFC4648 encoding From: scott@paragonie.com (Scott Arciszewski) --001a113dc710f53943052efe3679 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Mar 26, 2016 at 9:55 PM, Sascha Schumann < sascha.schumann@myrasecurity.com> wrote: > > > PHP already offers bin2hex()/hex2bin() and > base64_encode()/base64_decode(). > > > This covers part, but not all, of RFC 4648. > > > > > > I'd like to extend the coverage to include, at minimum, Base32. > > > > What's the use case for it? Is anybody using base32 now? > > I'd have a few times if the functionality had been easily available. > =E2=80=8B=E2=80=8B > > Please make this a single call: > > str_convert_base($in, $old_base, $new_base); > > "str_" because it applies in most cases to stuff not representable as a P= HP > float/int. > > > > I'd also like to make these functions to be written to resist > cache-timing > > > attacks (i.e. when used to encode/decode encryption keys for long-ter= m > =E2=80=8B=E2=80=8B > > As this requires slowing things down, this should be an extra, optional > feature. > Either to the relevant functions, or more likely globally, as it does not > make > much sense on a per-function level. > > Sascha > =E2=80=8BHi Sascha, =E2=80=8B Please make this a single call: > str_convert_base($in, $old_base, $new_base); > "str_" because it applies in most cases to stuff not representable as a P= HP > float/int. T=E2=80=8Bhat would be ill-advised. What I'm proposing is to cover RFC 4648= . https://tools.ietf.org/html/rfc4648 These are specific base-{2^n} encoding schemes that are easy to implement in constant time. An arbitrary change-of-base function just _begs_ people to port Base62 or Base58 which is much more difficult to reason about when it comes to timing safety. Also: We already have base_convert(). If you'd like to write a wholly separate RFC to make a function cover bases > 36, that might be useful. I'm specifically focusing on the "let's prevent cache-timing leaks when people encode-then-store/load-then-decode cryptographic secrets in PHP" problem here. =E2=80=8B As this requires slowing things down, this should be an extra, optional > feature. > Either to the relevant functions, or more likely globally, as it does not > make > much sense on a per-function level. That's something to consider, but please keep in mind a sense of perspective: Anthony measured a _negligible_ performance hit (5 * 10^-6 seconds). Are there any real-world applications that would suffer tremendously from this academic slow-down? If so, we should discuss how to proceed. If not, we might want to consider disregarding the penalty entirely. Scott Arciszewski Chief Development Officer Paragon Initiative Enterprises --001a113dc710f53943052efe3679--