[swift-evolution] [Proposal] Random Unification

Greg Parker gparker at apple.com
Sat Dec 2 19:02:01 CST 2017

> On Dec 2, 2017, at 1:09 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> On Sat, Dec 2, 2017 at 6:00 AM, Brent Royal-Gordon <brent at architechies.com <mailto:brent at architechies.com>> wrote:
>> On Dec 1, 2017, at 10:37 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> That said, I am not sure that this proposal should give any pretense of being suitable for cryptographic use. On implementation, the code will not have been audited for that purpose, although the author very rightly attempts to use the "best" possible sources of entropy available for each platform. Perhaps explicitly _not_ supporting cryptographic operations is the more Swifty way to go (in the sense that, where possible, Swift API design aims to help users avoid footguns).
> People will use it for crypto whether we want them to or not.
> People are going to do all sorts of unanticipated things, sure. But this doesn't mean that we shouldn't consider how we may best encourage users to avoid _unintentional_ common pitfalls.
> There are options to explore here. Consider, for example--and I'm not suggesting that we be this verbose, but it is illustrative of the trade-offs which are possible to keep in mind--if certain methods were very clear that the result is *pseudorandom* and potentially *insecure*: `(0..<9).insecurePseudorandomElement`. Clearly, fewer people would use this method for crypto.

But what *should* they use instead of our API? The OS-provided CSPRNG is almost certainly going to be the most secure thing available in the absence of specialized hardware. We should not deliberately scare users away from our API if there is nothing better on offer.

Greg Parker     gparker at apple.com     Runtime Wrangler

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171202/4eccf096/attachment.html>

More information about the swift-evolution mailing list