Austin Group Bug Tracker
2014-07-18 13:59:17 UTC
The following issue has been SUBMITTED.
======================================================================
http://austingroupbugs.net/view.php?id=859
======================================================================
Reported By: tedu
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 859
Category: System Interfaces
Type: Enhancement Request
Severity: Comment
Priority: normal
Status: New
Name: Ted Unangst
Organization: OpenBSD
User Reference:
Section: posix_random
Page Number: 0
Line Number: 0
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-07-18 13:59 UTC
Last Modified: 2014-07-18 13:59 UTC
======================================================================
Summary: Add posix_random family of interfaces
Description:
Cryptographic software requires a source of unpredictable (pseduo) random
numbers. Various nonstandard system interfaces exist for this purpose, but
they have subtle differences in behavior between platforms. Attempts to
build reliable portable software often fail due to this variation.
The interfaces below are adapted from the arc4random family of interfaces
first introduced in OpenBSD in 1996 and experiences gained since then. They
have been renamed to be more standard like, although the OpenBSD project
would not object to standardizing the existing names.
Desired Action:
SYNOPSIS
#include <stdlib.h>
uint32_t posix_random(void);
void posix_random_buffer(void *buf, size_t nbytes);
uint32_t posix_random_uniform(uint32_t upper_bound);
DESCRIPTION
This family of functions provides higher quality data than those
described in rand(3), random(3), and drand48(3). The generated
numbers
must be unpredictable. In particular, the sequence must not be shared
between processes after fork().
The arc4random() function returns a single 32-bit value.
arc4random_buf() fills the region buf of length nbytes with random
data.
arc4random_uniform() will return a single 32-bit value, uniformly
distributed but less than upper_bound. This is recommended over
constructions like "arc4random() % upper_bound" as it avoids "modulo
bias" when the upper bound is not a power of two.
All of these functions are thread safe.
RETURN VALUES
These functions are always successful, and no return value is reserved
to
indicate an error.
RATIONALE
The standard does not specify a required algorithm, leaving
implementations
some flexibility so long as they meet the interface requirements.
No mechanism is provided to seed or reseed these functions, which
places
an unnecessary burden on application developers. The implementation
is
responsible for ensuring correct operation at all times.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-07-18 13:59 tedu New Issue
2014-07-18 13:59 tedu Name => Ted Unangst
2014-07-18 13:59 tedu Organization => OpenBSD
2014-07-18 13:59 tedu Section => posix_random
2014-07-18 13:59 tedu Page Number => 0
2014-07-18 13:59 tedu Line Number => 0
======================================================================
======================================================================
http://austingroupbugs.net/view.php?id=859
======================================================================
Reported By: tedu
Assigned To:
======================================================================
Project: 1003.1(2013)/Issue7+TC1
Issue ID: 859
Category: System Interfaces
Type: Enhancement Request
Severity: Comment
Priority: normal
Status: New
Name: Ted Unangst
Organization: OpenBSD
User Reference:
Section: posix_random
Page Number: 0
Line Number: 0
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2014-07-18 13:59 UTC
Last Modified: 2014-07-18 13:59 UTC
======================================================================
Summary: Add posix_random family of interfaces
Description:
Cryptographic software requires a source of unpredictable (pseduo) random
numbers. Various nonstandard system interfaces exist for this purpose, but
they have subtle differences in behavior between platforms. Attempts to
build reliable portable software often fail due to this variation.
The interfaces below are adapted from the arc4random family of interfaces
first introduced in OpenBSD in 1996 and experiences gained since then. They
have been renamed to be more standard like, although the OpenBSD project
would not object to standardizing the existing names.
Desired Action:
SYNOPSIS
#include <stdlib.h>
uint32_t posix_random(void);
void posix_random_buffer(void *buf, size_t nbytes);
uint32_t posix_random_uniform(uint32_t upper_bound);
DESCRIPTION
This family of functions provides higher quality data than those
described in rand(3), random(3), and drand48(3). The generated
numbers
must be unpredictable. In particular, the sequence must not be shared
between processes after fork().
The arc4random() function returns a single 32-bit value.
arc4random_buf() fills the region buf of length nbytes with random
data.
arc4random_uniform() will return a single 32-bit value, uniformly
distributed but less than upper_bound. This is recommended over
constructions like "arc4random() % upper_bound" as it avoids "modulo
bias" when the upper bound is not a power of two.
All of these functions are thread safe.
RETURN VALUES
These functions are always successful, and no return value is reserved
to
indicate an error.
RATIONALE
The standard does not specify a required algorithm, leaving
implementations
some flexibility so long as they meet the interface requirements.
No mechanism is provided to seed or reseed these functions, which
places
an unnecessary burden on application developers. The implementation
is
responsible for ensuring correct operation at all times.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-07-18 13:59 tedu New Issue
2014-07-18 13:59 tedu Name => Ted Unangst
2014-07-18 13:59 tedu Organization => OpenBSD
2014-07-18 13:59 tedu Section => posix_random
2014-07-18 13:59 tedu Page Number => 0
2014-07-18 13:59 tedu Line Number => 0
======================================================================