Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cryptlib: add default CA path for Android #116

Open
wants to merge 8,192 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
8192 commits
Select commit Hold shift + click to select a range
b8a0aea
Import openssl-1.1.1d test data to base64test.c
Mar 10, 2020
cf395e0
Remove the enc function pointers.
Mar 10, 2020
7c13fb8
Add a return value check to tls13_buffer_extend().
Mar 10, 2020
7d32006
Remove some unnecessary handshake enums/functions.
Mar 10, 2020
d31e9ae
Update to follow handshake enum removal.
Mar 10, 2020
e9e6e23
Use ctx->hs->secrets rather than the S3I(s) version.
Mar 10, 2020
f27ea16
Use internal versions of SSL3_BUFFER, SSL3_RECORD and DTLS1_RECORD_DATA.
Mar 12, 2020
8a6444d
Stop overloading the record type for padding length.
Mar 12, 2020
3d4b6fc
Use calloc() rather than malloc() when allocating buffers.
Mar 12, 2020
6012678
Use calloc() rather than malloc() when allocating initial CBB buffer.
Mar 12, 2020
8e87a60
Ensure that CBB_add_space() always provides zeroed memory.
Mar 13, 2020
c21fcc8
Add regress for CBB_add_space().
Mar 13, 2020
66ebd7c
Add missing $OpenBSD$ tag.
Mar 13, 2020
441b3ec
Correct TLSv1.3 sequence number increment and wrapping check.
Mar 13, 2020
4bd0ba7
Add regress for TLSv1.3 sequence number handling.
Mar 13, 2020
af0218e
Remove dtls1_enc().
Mar 13, 2020
1203000
Increment a few more sequence numbers where the carry is close to
Mar 13, 2020
ab32c99
The RFC is clear (section 5.3) that sequence number should never wrap.
Mar 16, 2020
7cce221
Adapt to tls13_record_layer.c r1.30 (the sequence number shouldn't wr…
Mar 16, 2020
da41a74
Consistently spell 'unsigned' as 'unsigned int', as style(9) seems
Mar 16, 2020
596bcfd
Add a test program for getopt(3) that is adequate for manual testing
Mar 23, 2020
1e00ba8
Fix ASN1 print functions
Mar 24, 2020
0583654
Be concise: do not say that void functions return no values, that's o…
Mar 28, 2020
1fae6ca
Void functions obviously do not return values; no need to elaborate.
Mar 29, 2020
c51b1e6
Void functions obviously do not return values; no need to elaborate.
Mar 30, 2020
dbf5532
"eventually" came and went back in 2004.
Mar 30, 2020
16d92d3
Send a zero-length session identifier if TLSv1.3 is not enabled.
Apr 6, 2020
fe79641
Use errx() if we fail to build the client hello.
Apr 6, 2020
dcdd9c6
Dump the test data when the lengths differ in order to aid debugging.
Apr 6, 2020
ef10601
Improve comparision with test data.
Apr 6, 2020
cc8f3b8
Zero the client random field in the TLSv1.2 golden value.
Apr 6, 2020
739a578
Add tests that cover TLSv1.2 and disable those that trigger TLSv1.3.
Apr 6, 2020
7df811d
Minor code improvements.
Apr 6, 2020
cf2b853
Re-enable the client test now that it passes again.
Apr 6, 2020
39ee86f
Ensure legacy session ID is persistent during client TLS session.
Apr 8, 2020
3e619fc
ssl_aes_is_accelerated() returns a boolean - treat it as such, rather…
Apr 9, 2020
3d9c365
Tidy line wrapping and remove an extra blank line.
Apr 9, 2020
6a6bbb2
Test both SSLv3 (aka pre-TLSv1.2) and TLSv1.2 cipher suites with TLS.
Apr 9, 2020
72ba2cf
Include TLSv1.3 cipher suites unless cipher string references TLSv1.3.
Apr 9, 2020
1c7e766
Revise test to handle the fact that TLSv1.3 cipher suites are now being
Apr 9, 2020
ed1ac7c
When printing the serialNumber, fall back to the colon separated hex
Apr 10, 2020
49dfd4a
sync cert.pem with Mozilla's root ca list, ok beck@
Apr 10, 2020
96bda54
Document the TLSv1.3 control word, update the description of the
Apr 11, 2020
8bae5a7
Delete the three sentences listing the ciphers currently included
Apr 14, 2020
d20a0ce
add the missing sentence "LibreSSL no longer provides any such
Apr 14, 2020
6b1a77e
Update in several respects:
Apr 14, 2020
8e9980b
Resync our strstr.c with the musl version. Removes some debug code and
Apr 16, 2020
ba8e802
Replace the simple memmem() implementation with a version that is O(n)
Apr 16, 2020
cd3466f
Remove AUTHORS section. This follows what is done in strstr.3
Apr 16, 2020
fd23a88
Generate client key share using our preferred group.
Apr 17, 2020
e2b397e
Update key share regress to match previous change.
Apr 17, 2020
b26bcec
Only include TLSv1.3 cipher suites if there are active cipher suites.
Apr 17, 2020
81d0d4c
Allow more key share groups for TLSv1.3.
Apr 18, 2020
376f6c2
Tweak previous active cipher suite code.
Apr 18, 2020
2696b5d
Expose the peer ephemeral public key used for TLSv1.3 key exchange.
Apr 18, 2020
4d08f99
Fix wrapping/indentation.
Apr 18, 2020
13f8bd6
Provide TLSv1.3 cipher suite aliases to match the names used in RFC 8…
Apr 19, 2020
57061b3
Add -groups option to openssl(1) s_server.
Apr 19, 2020
ec5c35b
Consolidate TLSv1.3 constants.
Apr 21, 2020
a1ce766
Handle TLSv1.3 key shares other than X25519 on the server side.
Apr 21, 2020
43438bc
Improve TLSv1.3 state machine for HelloRetryRequest handling.
Apr 22, 2020
9ae94c8
Revise regress to match state transition changes.
Apr 22, 2020
1c42dbb
tweak the wording to make it clearer under which conditions exactly
Apr 25, 2020
fd3a571
Move unsupported, obsolete ciphers and deprecated aliases out of
Apr 25, 2020
4126509
Fix RES_USE_INET6 description
Apr 25, 2020
4bc1fd2
Discourage use of RES_USE_INET6
Apr 25, 2020
10dabf4
Switch to NEGOTIATED when using WITHOUT_HRR.
Apr 25, 2020
3ed0b5b
In s_server.c rev. 1.33, jsing added support for "openssl s_server -g…
Apr 25, 2020
a70a8ee
A comma is not appropriate here, use a semicolon
Apr 25, 2020
b2d6986
s_client: fix use of possibly uninitialized values
Apr 26, 2020
52111ad
Display TLSv1.3 extension type with openssl(1) -tlsextdebug
Apr 26, 2020
6c6ab1d
fix the description; from andras farkas
Apr 26, 2020
324730b
Minimal maintenance to make this mess slightly less confusing:
Apr 26, 2020
f2abd8a
Disallow the use of zero length IVs in AES-GCM via
Apr 27, 2020
f67411f
Fix a logic error that hid the failing ZeroLengthIv tests.
Apr 27, 2020
6b6c7eb
Fix two bugs in the AES-CBC-PKCS5 tests that didn't hide failing tests:
Apr 27, 2020
2449bd1
Shuffle some functions around.
Apr 27, 2020
6665dfd
Rename tls13_client_synthetic_handshake_message() and move to tls13_l…
Apr 28, 2020
116e563
Move legacy stack interfacing functions into tls13_legacy.c.
Apr 28, 2020
3c2b46d
tls13_handshake internal functions to static in libssl
Apr 29, 2020
6aa50f3
tls13_record_layer internal functions to static in libssl
Apr 29, 2020
d886a72
Disallow setting the AES-GCM IV length to 0
Apr 30, 2020
0bcfdc0
Add const to TLS1.3 internal vectors
May 2, 2020
9887354
Accept two ChangeCipherSpec messages during a TLSv1.3 handshake.
May 3, 2020
7f79544
Fix out-of-bounds access in tables[][] that was exposed in bluhm's
May 4, 2020
97447fd
Use a larger (2048 bit) RSA test key.
May 4, 2020
3a31614
Bump LibreSSL version to 3.1.1
May 6, 2020
8882dd4
On receiving a handshake or alert record with empty inner plaintext,
May 7, 2020
05f664c
Refactor tls13_server_hello_sent().
May 9, 2020
2f366ba
Pull the sending of alerts up into tls13_handshake_perform().
May 9, 2020
b222ddd
crazy whitespace on one line
May 9, 2020
2794e2b
Add support for HelloRetryRequests in the TLSv1.3 server.
May 9, 2020
994180b
On receiving an overlong session ID terminate with an illegal_parameter
May 9, 2020
d83dcb7
Drop a redundant test. It's effectively doing the same test twice
May 9, 2020
64a6cf0
Make the test for the legacy_compression_method vector in the ClientH…
May 9, 2020
d37324d
Add support for certificate status requests in TLS 1.3 client
May 9, 2020
3844ecc
now that 3.1.1 is out the door as a stable release bump the development
May 9, 2020
c3bcb68
catch the other place this needs to change
May 9, 2020
45badc2
Add a middlebox_compat flag and condition session ID randomisation on…
May 9, 2020
2847ac8
Correct return value check to handle TLS13_IO_EOF case.
May 9, 2020
087ac23
Send dummy ChangeCipherSpec messages from the TLSv1.3 client.
May 9, 2020
f65a255
Send dummy ChangeCipherSpec messages from the TLSv1.3 server
May 9, 2020
512c3e7
Forcibly ensure that only PSS may be used with RSA in TLS 1.3.
May 9, 2020
047b64d
Back out server side CCS sending. It breaks TLSv1.3 client communication
May 9, 2020
0243918
Correct tlsext_ocsp_resplen check.
May 10, 2020
e7e838b
Only reset TLS extension state when parsing client hello or server he…
May 10, 2020
1bd234b
Use size_t for OCSP response length.
May 10, 2020
f7bcaf9
Provide an easy way to get debug information from TLSv1.3 handshakes.
May 10, 2020
a5155c5
Conditionalize sleep-before-retry in server code to only be done when
May 10, 2020
98e93fa
Provide alert defines for TLSv1.3 and use in the TLSv1.3 code.
May 10, 2020
5fc8ba3
Honour SSL_VERIFY_FAIL_IF_NO_PEER_CERT in the TLSv1.3 server.
May 10, 2020
a713e7e
Send dummy ChangeCipherSpec messages from the TLSv1.3 server
May 10, 2020
4003c49
Make openssl X509 handle the failure case return code from X509_time_…
May 10, 2020
7b18ec3
Use ssl_get_new_session() in the TLSv1.3 server.
May 11, 2020
0e9a289
Move the record layer callbacks into a struct.
May 11, 2020
1ead72d
Provide an alert sent record layer callback.
May 11, 2020
7c95f6d
Set the record layer legacy version from the TLSv1.3 server.
May 11, 2020
c3a26bf
Add record version checks.
May 11, 2020
2a1a4d7
Propagate record overflows to the record layer and alert.
May 11, 2020
3e1ec0e
Revise regress now that record overflows are propagated.
May 11, 2020
e18e0b6
Use tls_legacy_server_method() for SSLv2 record tests.
May 11, 2020
39c8dbc
Enable the TLSv1.3 server.
May 11, 2020
c81a57a
Revise regress for TLSv1.3 server being enabled.
May 11, 2020
a64e8b1
there should only be one i in gratuitous
May 12, 2020
5492fce
Add -tls1_3 and -no_tls1_3 options to openssl(1) s_server
May 13, 2020
97fd998
Add description for -tls1_3 and -no_tls1_3 options to openssl(1) s_se…
May 13, 2020
478ea12
Switch the legacy version to TLS1_2_VERSION when processing server he…
May 13, 2020
b87ab2f
Switch back to the legacy stack where the maximum is less than TLSv1.3.
May 13, 2020
030257b
Remove a no longer relevant XXX comment.
May 13, 2020
8368f1f
Fix pesky whitespace.
May 13, 2020
714370f
Add TLS versioning tests.
May 13, 2020
0b099c0
Factor out the protocol version test in appstest.sh
May 14, 2020
87e9111
Skip protocol version message check in appstest.sh
May 14, 2020
67aa432
move a #define after the last #include line
May 14, 2020
8f7761a
reinstate an error check that was commented out while waiting for arm
May 14, 2020
4b2b846
go fmt whitespace nit
May 14, 2020
425de9f
Add ECDSA certificate test in appstest.sh
May 15, 2020
dbc55f6
Factor out the test for all available ciphers and add TLSv1.3 case
May 15, 2020
d7e32ab
Factor out session reuse test and verification test
May 15, 2020
5c8c0a3
document PKCS7_set_type(3);
May 16, 2020
7967d15
Avoid sending an empty certificate list from the TLSv1.3 server.
May 16, 2020
7a82533
Add TLS13_ERR_NO_CERTIFICATE.
May 16, 2020
98069b6
Ensure that a TLSv1.3 server has provided a certificate.
May 16, 2020
1e2e5cb
Return TLS13_IO_WANT_POLLIN after processing post-handshake messages.
May 16, 2020
d381a14
Fix server client test with TLSv1.3 in appstest.sh
May 17, 2020
09837ff
Suppress display output and reduce s_time to 1 sec in appstest.sh
May 17, 2020
091eb19
Add GOST certificate test in appstest.sh
May 17, 2020
7e7a746
Send a decode error alert if a server provides an empty certificate l…
May 17, 2020
ee28dd0
As done everywhere else, use a local version of MINIMUM() and avoid
May 17, 2020
4b3c1d0
Free handshake message correctly, noticed by tb@
May 17, 2020
786a81f
Send alerts back correctly when handling key shares, including
May 17, 2020
3a107e5
Rename variables for key, csr, pass, cert
May 18, 2020
0324bba
Add client certificate test in appstest.sh
May 18, 2020
3532783
Add support for TLS 1.3 server to send certificate status
May 19, 2020
0d6ae03
Only send ocsp staples if the client asked for ocsp certificate status.
May 19, 2020
9b19fea
Add -groups test for s_server and s_client in appstest.sh
May 19, 2020
732cb4d
Add -status and -servername test for s_server and s_client in appstes…
May 19, 2020
52a1243
Replace SSL_PKEY_RSA_ENC/SSL_PKEY_RSA_SIGN with SSL_PKEY_RSA.
May 19, 2020
ebd0fff
new manual page for PKCS7_set_content(3) and PKCS7_content_new(3);
May 20, 2020
dc4785f
Revert 1.43 - this fix for PHH in blocking mode breaks SSL_accept and
May 20, 2020
45ee2b7
Add a harness that runs tests from tlsfuzzer
May 21, 2020
4a80b2b
hook tlsfuzzer to regress
May 21, 2020
43f4bc8
Actually set the hrr flag when sending a HelloRetryRequest.
May 21, 2020
fe13a0d
beck fixed most of the keyupdate tests. update annotation
May 21, 2020
a349d05
A failure of tls13_handshake_msg_new() could lead to a NULL deref
May 21, 2020
6949d95
Avoid a shadowing issue by renaming cbs and cbb to cbb_hs and cbb_hs,
May 21, 2020
1e610e8
Make ssl_set_cert_masks() more consistent and closer to readable.
May 21, 2020
bfdbf0e
Simplify: transform a dangling else into an early return and
May 21, 2020
b518f1f
Ensure we only attach an ocsp staple to a leaf certificate, because
May 22, 2020
dfd8054
sockaddr should be sockaddr_storage, otherwise "openssl s_client -6 -…
May 22, 2020
8712ece
Do not assume that server_group != 0 or tlsext_supportedgroups != NULL
May 23, 2020
b431128
Avoid an out-of-bounds array access in the s_server.
May 23, 2020
63359df
fix a confusingly wrapped line
May 23, 2020
424d9c5
Provide the option to retry or return after post-handshake messages.
May 23, 2020
616b880
Wire up SSL_MODE_AUTO_RETRY mode to retrying after PHH messages.
May 23, 2020
d6e221d
Enable SSL_MODE_AUTO_RETRY by default.
May 23, 2020
c19f13e
In ssl_lib.c revision 1.217, jsing enabled SSL_MODE_AUTO_RETRY by
May 23, 2020
caf0483
While the second SSL_CTX in this code is only used on servername
May 23, 2020
099a52f
Enforce that SNI hostnames be correct as per rfc 6066 and 5980.
May 23, 2020
3e71299
Define REGRESS_TARGETS explicitly.
May 23, 2020
fa10021
The version detection doesn't work on bluhm's test machine, causing
May 24, 2020
e26f1bf
Briefly mention the obsolete function OPENSSL_init(3).
May 24, 2020
18aab0d
Minimally document PKCS7_dataInit(3).
May 24, 2020
16df084
address some nits from jsing
May 24, 2020
0fc2380
include newlines in FAIL messages
May 24, 2020
7be2a80
Clear SSL_MODE_AUTO_RETRY in libtls, since we handle WANT_POLLIN corr…
May 24, 2020
dd6291f
Fix some stylistic nits from jsing.
May 24, 2020
cd07d51
Previous commit caught a few errx() cases by accident. undo them.
May 24, 2020
2e84e37
Add additional length checks for TLSv1.3 plaintext and inner plaintext.
May 26, 2020
d22c9d8
minor cleanup ahead of the following work:
May 26, 2020
0301216
document PKCS7_dataFinal(3);
May 27, 2020
3dbe29e
This patch fixes one bug and one instance of undesirable behaviour.
May 27, 2020
cfc0dec
more tests after getopt_long.c rev. 1.32;
May 27, 2020
69b4785
Add checks for SH downgrade sentinel and HRR hash in appstest.sh
May 29, 2020
de7addc
Mop up servername_done, which is unused.
May 29, 2020
fe92345
Wire up the servername callback in the TLSv1.3 server.
May 29, 2020
58d1be8
Handle the case where we receive a valid 0 byte application data record.
May 29, 2020
06d982c
Improve server certificate selection for TLSv1.3.
May 29, 2020
4529226
Fix printing long doubles on architectures with hm and lm bits.
May 31, 2020
b1f4d0d
Correct downgrade sentinels when a version pinned method is in use.
May 31, 2020
3e1824f
When building a chain look for non-expired certificates first.
May 31, 2020
768c715
Replace ssl_max_server_version() with ssl_downgrade_max_version()
May 31, 2020
a177033
bump to LibreSSL 3.2.1
Jun 1, 2020
7da481f
Add a mechanism to set an alert in those parts of the read half of
Jun 1, 2020
4e75c74
Send an illegal_parameter alert if a client sends us invalid DH key
Jun 1, 2020
49b3cb3
Enable test-dhe-rsa-key-exchange-with-bad-messages.py
Jun 1, 2020
32e950b
Enable the test-tls13-zero-length-data.py test, skipping the
Jun 1, 2020
d3d6175
Remove expired certificate, ok tb@
Jun 1, 2020
5419bc3
Split the handling of post handshake handshake messages into its
Jun 1, 2020
a35ca2b
distracting whitespace
Jun 2, 2020
d3ab461
Remove const modifier in return type of tls13_handshake_active_state()
Jun 2, 2020
305df17
Enable the record layer limits test and mark two finished test cases as
Jun 3, 2020
0ee7ea6
Properly document PKCS7_final(3), which was already mentioned
Jun 3, 2020
e669390
new manual page PKCS7_add_attribute(3);
Jun 4, 2020
2d04691
Collapse the x509v3 directory into x509.
Jun 4, 2020
33a26bc
mention that TLS_method(3) also supports TLSv1.3;
Jun 4, 2020
85b5025
Improve client certificate selection for TLSv1.3
Jun 4, 2020
471e41d
Align tls13_server_select_certificate() with
Jun 4, 2020
702e1a7
minor polishing:
Jun 4, 2020
5af69a0
When X509_ATTRIBUTE_create() receives an invalid NID (e.g., -1), return
Jun 4, 2020
00b011e
One error file per directory is plenty.
Jun 5, 2020
f8258ce
Apply some style(9).
Jun 5, 2020
ff23cac
Remove remaining error *_str_functs[]
Jun 5, 2020
7d5f86f
Add support for additional GOST curves.
Jun 5, 2020
6b90325
Add a few more errors to help debugging.
Jun 5, 2020
3fc5854
Add OIDs for HMAC using Streebog (GOST R 34.11-2012) hash function.
Jun 5, 2020
ce6866b
Allow GOST R 34.11-2012 in PBE/PBKDF2/PKCS#5.
Jun 5, 2020
9597698
Enable GOST_SIG_FORMAT_RS_LE when verifying certificate signatures.
Jun 5, 2020
5b2a6c3
Handle GOST in ssl_cert_dup().
Jun 5, 2020
26c8695
Stop sending GOST R 34.10-94 as a CertificateType.
Jun 5, 2020
6ecd723
Use IANA allocated GOST ClientCertificateTypes.
Jun 5, 2020
d808a3e
Add a custom copy handler for AES key wrap
Jun 5, 2020
fed7cf2
Implement a rolling hash of the ClientHello message, Enforce RFC 8446
Jun 6, 2020
5cc6178
The check_includes step is incorrect dependency management model for
Jun 9, 2020
19f6c9d
describe six more PKCS7 attribute functions
Jun 10, 2020
3dba83b
document PKCS7_get_signer_info(3)
Jun 10, 2020
968b091
Add lucky13 and bleichenbacher-timing tests
Jun 10, 2020
231a1b8
wording tweaks from ross l richardson and tb;
Jun 11, 2020
61d44f8
document PEM_ASN1_read(3) and PEM_ASN1_read_bio(3);
Jun 12, 2020
acb6629
add a comment saying that name_cmp() is intentionally undocumented;
Jun 12, 2020
fa03bbb
add my Copyright and license, which i forgot when adding a significant
Jun 12, 2020
8a57df3
Document PEM_def_callback(3).
Jun 15, 2020
c1f02a4
Document EVP_read_pw_string_min(3)
Jun 15, 2020
9c5d044
Merge documentation of X509_get0_serialNumber(3) from OpenSSL-1.1.1
Jun 19, 2020
2c9265f
document error handling of X509_PUBKEY_get0(3) and X509_PUBKEY_get(3)
Jun 19, 2020
4e5461d
document X509_get0_pubkey_bitstr(3),
Jun 19, 2020
ca4f9a8
mark the functions documented in des_read_pw(3) as deprecated
Jun 19, 2020
b55dba4
We inherited the constant time CBC padding removal from BoringSSL, but
Jun 19, 2020
72ffaa3
Enable lucky 13 test.
Jun 19, 2020
b2570ec
cryptlib: add default CA path for Android
aberaud Jun 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 5 additions & 11 deletions src/lib/libc/crypt/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# $OpenBSD: Makefile.inc,v 1.13 1999/11/17 05:22:36 millert Exp $
# $OpenBSD: Makefile.inc,v 1.27 2016/03/30 06:38:41 jmc Exp $

.PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/crypt ${LIBCSRCDIR}/crypt
.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/crypt ${LIBCSRCDIR}/crypt

SRCS+= cast.c crypt.c morecrypt.c md5crypt.c arc4random.c blowfish.c
SRCS+= bcrypt.c skipjack.c
SRCS+= crypt.c cryptutil.c arc4random.c arc4random_uniform.c \
blowfish.c bcrypt.c

MAN+= crypt.3 blowfish.3 arc4random.3
MLINKS+=crypt.3 encrypt.3 crypt.3 setkey.3 crypt.3 des_cipher.3
MLINKS+=crypt.3 des_setkey.3 blowfish.3 blf_key.3 blowfish.3 blf_enc.3
MLINKS+=blowfish.3 blf_dec.3 blowfish.3 blf_ecb_encrypt.3
MLINKS+=blowfish.3 blf_ecb_decrypt.3 blowfish.3 blf_cbc_encrypt.3
MLINKS+=blowfish.3 blf_cbc_decrypt.3
MLINKS+=arc4random.3 arc4random_stir.3 arc4random.3 arc4random_addrandom.3
MAN+= crypt.3 crypt_checkpass.3 blowfish.3 arc4random.3
122 changes: 64 additions & 58 deletions src/lib/libc/crypt/arc4random.3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" $OpenBSD: arc4random.3,v 1.17 2000/12/21 14:07:41 aaron Exp $
.\" $OpenBSD: arc4random.3,v 1.37 2019/09/29 16:30:35 jmc Exp $
.\"
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
.\" All rights reserved.
Expand Down Expand Up @@ -30,81 +30,87 @@
.\"
.\" Manual page, using -mandoc macros
.\"
.Dd April 15, 1997
.Dd $Mdocdate: September 29 2019 $
.Dt ARC4RANDOM 3
.Os
.Sh NAME
.Nm arc4random ,
.Nm arc4random_stir ,
.Nm arc4random_addrandom
.Nd arc4 random number generator
.Nm arc4random_buf ,
.Nm arc4random_uniform
.Nd random number generator
.Sh SYNOPSIS
.Fd #include <stdlib.h>
.Ft u_int32_t
.In stdlib.h
.Ft uint32_t
.Fn arc4random "void"
.Ft void
.Fn arc4random_stir "void"
.Ft void
.Fn arc4random_addrandom "u_char *dat" "int datlen"
.Fn arc4random_buf "void *buf" "size_t nbytes"
.Ft uint32_t
.Fn arc4random_uniform "uint32_t upper_bound"
.Sh DESCRIPTION
The
.Fn arc4random
function provides a high quality 32-bit pseudo-random
number very quickly.
.Fn arc4random
seeds itself on a regular basis from the kernel strong random number
subsystem described in
.Xr random 4 .
On each call, an ARC4 generator is used to generate a new result.
The
.Fn arc4random
function uses the ARC4 cipher key stream generator,
which uses 8*8 8 bit S-Boxes.
The S-Boxes can be in about (2**1700) states.
.Pp
.Fn arc4random
fits into a middle ground not covered by other subsystems such as
the strong, slow, and resource expensive random
devices described in
.Xr random 4
versus the fast but poor quality interfaces described in
This family of functions provides higher quality data than those
described in
.Xr rand 3 ,
.Xr random 3 ,
and
.Xr drand48 3 .
.Xr rand48 3 .
.Pp
The
.Fn arc4random_stir
function reads data from
.Pa /dev/arandom
and uses it to permute the S-Boxes via
.Fn arc4random_addrandom .
Use of these functions is encouraged for almost all random number
consumption because the other interfaces are deficient in either
quality, portability, standardization, or availability.
These functions can be called in almost all coding environments,
including
.Xr pthreads 3
and
.Xr chroot 2 .
.Pp
There is no need to call
.Fn arc4random_stir
before using
.Fn arc4random ,
since
High quality 32-bit pseudo-random numbers are generated very quickly.
On each call, a cryptographic pseudo-random number generator is used
to generate a new result.
One data pool is used for all consumers in a process, so that consumption
under program flow can act as additional stirring.
The subsystem is re-seeded from the kernel
.Xr random 4
subsystem using
.Xr getentropy 2
on a regular basis, and also upon
.Xr fork 2 .
.Pp
The
.Fn arc4random
automatically initializes itself.
function returns a single 32-bit value.
.Pp
.Fn arc4random_buf
fills the region
.Fa buf
of length
.Fa nbytes
with random data.
.Pp
.Fn arc4random_uniform
will return a single 32-bit value, uniformly distributed but less than
.Fa upper_bound .
This is recommended over constructions like
.Dq Li arc4random() % upper_bound
as it avoids "modulo bias" when the upper bound is not a power of two.
In the worst case, this function may consume multiple iterations
to ensure uniformity; see the source code to understand the problem
and solution.
.Sh RETURN VALUES
These functions are always successful, and no return value is
reserved to indicate an error.
.Sh SEE ALSO
.Xr rand 3 ,
.Xr rand48 3 ,
.Xr random 3
.Sh HISTORY
An algorithm called
.Pa RC4
was designed by RSA Data Security, Inc.
It was considered a trade secret, but not trademarked.
Because it was a trade secret, it obviously could not be patented.
A clone of this was posted anonymously to USENET and confirmed to
be equivalent by several sources who had access to the original cipher.
Because of the trade secret situation, RSA Data Security, Inc. can do
nothing about the release of the ARC4 algorithm.
Since
.Pa RC4
used to be a trade secret, the cipher is now referred to as
.Pa ARC4 .
.Pp
These functions first appeared in
.Ox 2.1 .
.Pp
The original version of this random number generator used the
RC4 (also known as ARC4) algorithm.
In
.Ox 5.5
it was replaced with the ChaCha20 cipher, and it may be replaced
again in the future as cryptographic techniques advance.
A good mnemonic is
.Dq A Replacement Call for Random .
Loading