Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src



Module Name:    src
Committed By:   riastradh
Date:           Tue May 31 13:42:59 UTC 2022

Modified Files:
        src/distrib/sets/lists/comp: mi
        src/distrib/sets/lists/debug: mi
        src/distrib/sets/lists/tests: mi
        src/include: limits.h unistd.h
        src/lib/libc/gen: Makefile.inc
        src/lib/libc/include: namespace.h
        src/tests/lib/libc/gen: Makefile
Added Files:
        src/lib/libc/gen: getentropy.3 getentropy.c
        src/tests/lib/libc/gen: t_getentropy.c

Log Message:
libc: Reintroduce getentropy.

This was introduced two years ago when the getrandom/getentropy API
question was still open, and removed because the discussion was
ongoing.  Now getentropy is more widely adopted and soon to be in
POSIX.  So reintroduce the symbol into libc since we'll be keeping it
anyway.  Discussion of details of the semantics, as interpreted by
NetBSD, is ongoing, but the symbol needs to get in before the
netbsd-10 branch.  The draft POSIX text is
(https://www.opengroup.org/austin/docs/austin_1110.pdf):

    SYNOPSIS
        #include <unistd.h>

        int getentropy(void *buffer, size_t length);

    DESCRIPTION
        The getentropy() function shall write length bytes of data
        starting at the location pointed to by buffer. The output
        shall be unpredictable high quality random data, generated by
        a cryptographically secure pseudo-random number
        generator. The maximum permitted value for the length
        argument is given by the {GETENTROPY_MAX} symbolic constant
        defined in <limits.h>.

    RETURN VALUES
        Upon successful completion, getentropy() shall return 0;
        otherwise, -1 shall be retunred and errno set to indicate the
        error.

    ERRORS
        The getentropy() function shall fail if:

        [EINVAL]        The value of length is greater than
                        {GETENTROPY_MAX}.

        The getentropy() function may fail if:

        [ENOSYS]        The system does not provide the necessary
                        source of entropy.

    RATIONALE
        The getentropy() function is not a cancellation point.

Minor changes from the previous introduction of getentropy into libc:

- Return EINVAL, not EIO, on buflen > 256.
- Define GETENTROPY_MAX in limits.h.

The declaration of getentropy in unistd.h and definition of
GETENTROPY_MAX in limits.h are currently conditional on
_NETBSD_SOURCE.  When the next revision of POSIX is finalized, we can
expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this
can be done as a pullup without breaking existing compiled programs.


To generate a diff of this commit:
cvs rdiff -u -r1.2414 -r1.2415 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.385 -r1.386 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.1208 -r1.1209 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.42 -r1.43 src/include/limits.h
cvs rdiff -u -r1.162 -r1.163 src/include/unistd.h
cvs rdiff -u -r1.215 -r1.216 src/lib/libc/gen/Makefile.inc
cvs rdiff -u -r0 -r1.4 src/lib/libc/gen/getentropy.3
cvs rdiff -u -r0 -r1.3 src/lib/libc/gen/getentropy.c
cvs rdiff -u -r1.202 -r1.203 src/lib/libc/include/namespace.h
cvs rdiff -u -r1.54 -r1.55 src/tests/lib/libc/gen/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/gen/t_getentropy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index