New issue
Advanced search Search tips

Issue 858194 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Fuchsia
Pri: 3
Type: Task



Sign in to add a comment

RandBytes could be simpler on Fuchsia

Project Member Reported by abarth@chromium.org, Jun 28 2018

Issue description

Current:

void RandBytes(void* output, size_t output_length) {
  size_t remaining = output_length;
  unsigned char* cur = reinterpret_cast<unsigned char*>(output);
  while (remaining > 0) {
    // The syscall has a maximum number of bytes that can be read at once.
    size_t read_len =
        std::min(remaining, static_cast<size_t>(ZX_CPRNG_DRAW_MAX_LEN));
    zx_cprng_draw(cur, read_len);
    remaining -= read_len;
    cur += read_len;
  }
}

Better:

void RandBytes(void* output, size_t output_length) {
  zx_cprng_draw(output, output_length);
}

 

Comment 2 by w...@chromium.org, Jun 28 2018

Owner: w...@chromium.org
Status: Started (was: Untriaged)
Project Member

Comment 3 by bugdroid1@chromium.org, Jun 29 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5304962d65497696f9e0ca65e888827eab207d3a

commit 5304962d65497696f9e0ca65e888827eab207d3a
Author: Wez <wez@chromium.org>
Date: Fri Jun 29 05:46:49 2018

[fuchsia] Reduce RandBytes() to a single zx_cprng_draw() call.

Bug:  858194 
Change-Id: I051084347da2f395e25b090ba54439c866b0c044
Reviewed-on: https://chromium-review.googlesource.com/1119357
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571396}
[modify] https://crrev.com/5304962d65497696f9e0ca65e888827eab207d3a/base/rand_util_fuchsia.cc

Comment 4 by w...@chromium.org, Jun 29 2018

Status: Fixed (was: Started)

Sign in to add a comment