<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>239735</bug_id>
          
          <creation_ts>2022-04-25 11:29:19 -0700</creation_ts>
          <short_desc>[libpas] Implement secure random numbers</short_desc>
          <delta_ts>2022-04-27 10:32:14 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>bmalloc</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Brandon">brandonstewart</reporter>
          <assigned_to name="Brandon">brandonstewart</assigned_to>
          <cc>ggaren</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1864160</commentid>
    <comment_count>0</comment_count>
    <who name="Brandon">brandonstewart</who>
    <bug_when>2022-04-25 11:29:19 -0700</bug_when>
    <thetext>We currently have a cheesy random and secure random, which use the same implementation for generating random numbers. (We are going to ignore the mock testing code here).

This patch introduces a fast random and secure random.

The fast random maintains the same properties as the previous implementation, while secure random will use the cryptographically secure arc4random_uniform to give better randomness.

arc4random() can be quite an expensive operation and based on discussing with Yusuke he found heavy performance penalties when using this in JSC.

Our secure random shall only be used in cases where true randomness is needed.

We have 2 spots where we currently use secure random we shall just migrate those over to using fast random.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1864175</commentid>
    <comment_count>1</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2022-04-25 11:45:45 -0700</bug_when>
    <thetext>Can we re-use WTF::WeakRandom for this (or reuse the alogrithm)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1864179</commentid>
    <comment_count>2</comment_count>
    <who name="Brandon">brandonstewart</who>
    <bug_when>2022-04-25 11:54:07 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/379</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1864225</commentid>
    <comment_count>3</comment_count>
    <who name="Brandon">brandonstewart</who>
    <bug_when>2022-04-25 14:16:25 -0700</bug_when>
    <thetext>(In reply to Geoffrey Garen from comment #1)
&gt; Can we re-use WTF::WeakRandom for this (or reuse the alogrithm)?

We could probably reimplement the WeakRandom algorithm to replace the fast generator (just took a brief look at the code).

The main goal of this patch was to separate the fast and secure random generator, and provide a suitable secure random generator.

Replacing the fast random generator can be further investigated in a future patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1864236</commentid>
    <comment_count>4</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2022-04-25 14:49:03 -0700</bug_when>
    <thetext>OK, got it!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1864842</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-04-27 10:31:10 -0700</bug_when>
    <thetext>Committed r293518 (250049@main): &lt;https://commits.webkit.org/250049@main&gt;

Reviewed commits have been landed. Closing PR #379 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1864843</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-04-27 10:32:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/92406887&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>