<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src-test2/sys/libkern/arc4random.c, branch releng/11.2</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src-test2/atom?h=releng%2F11.2</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src-test2/atom?h=releng%2F11.2'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/'/>
<updated>2017-03-18T22:04:20Z</updated>
<entry>
<title>MFC r304572 (by bz):</title>
<updated>2017-03-18T22:04:20Z</updated>
<author>
<name>Andrey V. Elsukov</name>
<email>ae@FreeBSD.org</email>
</author>
<published>2017-03-18T22:04:20Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=8e5a48ff55c7fcb7102b97764044039118a176a4'/>
<id>urn:sha1:8e5a48ff55c7fcb7102b97764044039118a176a4</id>
<content type='text'>
  Remove the kernel optoion for IPSEC_FILTERTUNNEL, which was deprecated
  more than 7 years ago in favour of a sysctl in r192648.

MFC r305122:
  Remove redundant sanity checks from ipsec[46]_common_input_cb().

  This check already has been done in the each protocol callback.

MFC r309144,309174,309201 (by fabient):
  IPsec RFC6479 support for replay window sizes up to 2^32 - 32 packets.

  Since the previous algorithm, based on bit shifting, does not scale
  with large replay windows, the algorithm used here is based on
  RFC 6479: IPsec Anti-Replay Algorithm without Bit Shifting.
  The replay window will be fast to be updated, but will cost as many bits
  in RAM as its size.

  The previous implementation did not provide a lock on the replay window,
  which may lead to replay issues.

  Obtained from:	emeric.poupon@stormshield.eu
  Sponsored by:	Stormshield
  Differential Revision:	https://reviews.freebsd.org/D8468

MFC r309143,309146 (by fabient):
  In a dual processor system (2*6 cores) during IPSec throughput tests,
  we see a lot of contention on the arc4 lock, used to generate the IV
  of the ESP output packets.

  The idea of this patch is to split this mutex in order to reduce the
  contention on this lock.

  Update r309143 to prevent false sharing.

  Reviewed by:	delphij, markm, ache
  Approved by:	so
  Obtained from: emeric.poupon@stormshield.eu
  Sponsored by:	Stormshield
  Differential Revision:	https://reviews.freebsd.org/D8130

MFC r313330:
  Merge projects/ipsec into head/.

   Small summary
   -------------

  o Almost all IPsec releated code was moved into sys/netipsec.
  o New kernel modules added: ipsec.ko and tcpmd5.ko. New kernel
    option IPSEC_SUPPORT added. It enables support for loading
    and unloading of ipsec.ko and tcpmd5.ko kernel modules.
  o IPSEC_NAT_T option was removed. Now NAT-T support is enabled by
    default. The UDP_ENCAP_ESPINUDP_NON_IKE encapsulation type
    support was removed. Added TCP/UDP checksum handling for
    inbound packets that were decapsulated by transport mode SAs.
    setkey(8) modified to show run-time NAT-T configuration of SA.
  o New network pseudo interface if_ipsec(4) added. For now it is
    build as part of ipsec.ko module (or with IPSEC kernel).
    It implements IPsec virtual tunnels to create route-based VPNs.
  o The network stack now invokes IPsec functions using special
    methods. The only one header file &lt;netipsec/ipsec_support.h&gt;
    should be included to declare all the needed things to work
    with IPsec.
  o All IPsec protocols handlers (ESP/AH/IPCOMP protosw) were removed.
    Now these protocols are handled directly via IPsec methods.
  o TCP_SIGNATURE support was reworked to be more close to RFC.
  o PF_KEY SADB was reworked:
    - now all security associations stored in the single SPI namespace,
      and all SAs MUST have unique SPI.
    - several hash tables added to speed up lookups in SADB.
    - SADB now uses rmlock to protect access, and concurrent threads
      can do SA lookups in the same time.
    - many PF_KEY message handlers were reworked to reflect changes
      in SADB.
    - SADB_UPDATE message was extended to support new PF_KEY headers:
      SADB_X_EXT_NEW_ADDRESS_SRC and SADB_X_EXT_NEW_ADDRESS_DST. They
      can be used by IKE daemon to change SA addresses.
  o ipsecrequest and secpolicy structures were cardinally changed to
    avoid locking protection for ipsecrequest. Now we support
    only limited number (4) of bundled SAs, but they are supported
    for both INET and INET6.
  o INPCB security policy cache was introduced. Each PCB now caches
    used security policies to avoid SP lookup for each packet.
  o For inbound security policies added the mode, when the kernel does
    check for full history of applied IPsec transforms.
  o References counting rules for security policies and security
    associations were changed. The proper SA locking added into xform
    code.
  o xform code was also changed. Now it is possible to unregister xforms.
    tdb_xxx structures were changed and renamed to reflect changes in
    SADB/SPDB, and changed rules for locking and refcounting.

  Obtained from:	Yandex LLC
  Relnotes:	yes
  Sponsored by:	Yandex LLC
  Differential Revision:	https://reviews.freebsd.org/D9352

MFC r313331:
  Add removed headers into the ObsoleteFiles.inc.

MFC r313561 (by glebius):
  Move tcp_fields_to_net() static inline into tcp_var.h, just below its
  friend tcp_fields_to_host(). There is third party code that also uses
  this inline.

MFC r313697:
  Remove IPsec related PCB code from SCTP.

  The inpcb structure has inp_sp pointer that is initialized by
  ipsec_init_pcbpolicy() function. This pointer keeps strorage for IPsec
  security policies associated with a specific socket.
  An application can use IP_IPSEC_POLICY and IPV6_IPSEC_POLICY socket
  options to configure these security policies. Then ip[6]_output()
  uses inpcb pointer to specify that an outgoing packet is associated
  with some socket. And IPSEC_OUTPUT() method can use a security policy
  stored in the inp_sp. For inbound packet the protocol-specific input
  routine uses IPSEC_CHECK_POLICY() method to check that a packet conforms
  to inbound security policy configured in the inpcb.

  SCTP protocol doesn't specify inpcb for ip[6]_output() when it sends
  packets. Thus IPSEC_OUTPUT() method does not consider such packets as
  associated with some socket and can not apply security policies
  from inpcb, even if they are configured. Since IPSEC_CHECK_POLICY()
  method is called from protocol-specific input routine, it can specify
  inpcb pointer and associated with socket inbound policy will be
  checked. But there are two problems:
  1. Such check is asymmetric, becasue we can not apply security policy
  from inpcb for outgoing packet.
  2. IPSEC_CHECK_POLICY() expects that caller holds INPCB lock and
  access to inp_sp is protected. But for SCTP this is not correct,
  becasue SCTP uses own locks to protect inpcb.

  To fix these problems remove IPsec related PCB code from SCTP.
  This imply that IP_IPSEC_POLICY and IPV6_IPSEC_POLICY socket options
  will be not applicable to SCTP sockets. To be able correctly check
  inbound security policies for SCTP, mark its protocol header with
  the PR_LASTHDR flag.

  Differential Revision:	https://reviews.freebsd.org/D9538

MFC r313746:
  Add missing check to fix the build with IPSEC_SUPPORT and without MAC.

MFC r313805:
  Fix LINT build for powerpc.

  Build kernel modules support only when both IPSEC and TCP_SIGNATURE
  are not defined.

MFC r313922:
  For translated packets do not adjust UDP checksum if it is zero.

  In case when decrypted and decapsulated packet is an UDP datagram,
  check that its checksum is not zero before doing incremental checksum
  adjustment.

MFC r314339:
  Document that the size of AH ICV for HMAC-SHA2-NNN should be half of
  NNN bits as described in RFC4868.

  PR:		215978

MFC r314812:
  Introduce the concept of IPsec security policies scope.

  Currently are defined three scopes: global, ifnet, and pcb.
  Generic security policies that IKE daemon can add via PF_KEY interface
  or an administrator creates with setkey(8) utility have GLOBAL scope.
  Such policies can be applied by the kernel to outgoing packets and checked
  agains inbound packets after IPsec processing.
  Security policies created by if_ipsec(4) interfaces have IFNET scope.
  Such policies are applied to packets that are passed through if_ipsec(4)
  interface.
  And security policies created by application using setsockopt()
  IP_IPSEC_POLICY option have PCB scope. Such policies are applied to
  packets related to specific socket. Currently there is no way to list
  PCB policies via setkey(8) utility.

  Modify setkey(8) and libipsec(3) to be able distinguish the scope of
  security policies in the `setkey -DP` listing. Add two optional flags:
  '-t' to list only policies related to virtual *tunneling* interfaces,
  i.e. policies with IFNET scope, and '-g' to list only policies with GLOBAL
  scope. By default policies from all scopes are listed.

  To implement this PF_KEY's sadb_x_policy structure was modified.
  sadb_x_policy_reserved field is used to pass the policy scope from the
  kernel to userland. SADB_SPDDUMP message extended to support filtering
  by scope: sadb_msg_satype field is used to specify bit mask of requested
  scopes.

  For IFNET policies the sadb_x_policy_priority field of struct sadb_x_policy
  is used to pass if_ipsec's interface if_index to the userland. For GLOBAL
  policies sadb_x_policy_priority is used only to manage order of security
  policies in the SPDB. For IFNET policies it is not used, so it can be used
  to keep if_index.

  After this change the output of `setkey -DP` now looks like:
  # setkey -DPt
  0.0.0.0/0[any] 0.0.0.0/0[any] any
  	in ipsec
  	esp/tunnel/87.250.242.144-87.250.242.145/unique:145
  	spid=7 seq=3 pid=58025 scope=ifnet ifname=ipsec0
  	refcnt=1
  # setkey -DPg
  ::/0 ::/0 icmp6 135,0
  	out none
  	spid=5 seq=1 pid=872 scope=global
  	refcnt=1

  Obtained from:	Yandex LLC
  Sponsored by:	Yandex LLC
  Differential Revision:	https://reviews.freebsd.org/D9805

PR:		212018
Relnotes:	yes
Sponsored by:	Yandex LLC
</content>
</entry>
<entry>
<title>MFC r315225:</title>
<updated>2017-03-14T06:10:40Z</updated>
<author>
<name>Xin LI</name>
<email>delphij@FreeBSD.org</email>
</author>
<published>2017-03-14T06:10:40Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=ea440f6a23ced655004a5676f96d13986651f1ac'/>
<id>urn:sha1:ea440f6a23ced655004a5676f96d13986651f1ac</id>
<content type='text'>
Discard first 3072 bytes of RC4 keystream, this is a bandaid
that allows us to work on switching to a more modern PRNG.

Submitted by:	Steven Chamberlain &lt;steven pyro eu org&gt;
Approved by:	so
</content>
</entry>
<entry>
<title>Huge cleanup of random(4) code.</title>
<updated>2015-06-30T17:00:45Z</updated>
<author>
<name>Mark Murray</name>
<email>markm@FreeBSD.org</email>
</author>
<published>2015-06-30T17:00:45Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=d1b06863fbc7b142d7afdf2d399087e2fab40f16'/>
<id>urn:sha1:d1b06863fbc7b142d7afdf2d399087e2fab40f16</id>
<content type='text'>
* GENERAL
- Update copyright.
- Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set
  neither to ON, which means we want Fortuna
- If there is no 'device random' in the kernel, there will be NO
  random(4) device in the kernel, and the KERN_ARND sysctl will
  return nothing. With RANDOM_DUMMY there will be a random(4) that
  always blocks.
- Repair kern.arandom (KERN_ARND sysctl). The old version went
  through arc4random(9) and was a bit weird.
- Adjust arc4random stirring a bit - the existing code looks a little
  suspect.
- Fix the nasty pre- and post-read overloading by providing explictit
  functions to do these tasks.
- Redo read_random(9) so as to duplicate random(4)'s read internals.
  This makes it a first-class citizen rather than a hack.
- Move stuff out of locked regions when it does not need to be
  there.
- Trim RANDOM_DEBUG printfs. Some are excess to requirement, some
  behind boot verbose.
- Use SYSINIT to sequence the startup.
- Fix init/deinit sysctl stuff.
- Make relevant sysctls also tunables.
- Add different harvesting "styles" to allow for different requirements
  (direct, queue, fast).
- Add harvesting of FFS atime events. This needs to be checked for
  weighing down the FS code.
- Add harvesting of slab allocator events. This needs to be checked for
  weighing down the allocator code.
- Fix the random(9) manpage.
- Loadable modules are not present for now. These will be re-engineered
  when the dust settles.
- Use macros for locks.
- Fix comments.

* src/share/man/...
- Update the man pages.

* src/etc/...
- The startup/shutdown work is done in D2924.

* src/UPDATING
- Add UPDATING announcement.

* src/sys/dev/random/build.sh
- Add copyright.
- Add libz for unit tests.

* src/sys/dev/random/dummy.c
- Remove; no longer needed. Functionality incorporated into randomdev.*.

* live_entropy_sources.c live_entropy_sources.h
- Remove; content moved.
- move content to randomdev.[ch] and optimise.

* src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h
- Remove; plugability is no longer used. Compile-time algorithm
  selection is the way to go.

* src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h
- Add early (re)boot-time randomness caching.

* src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h
- Remove; no longer needed.

* src/sys/dev/random/uint128.h
- Provide a fake uint128_t; if a real one ever arrived, we can use
  that instead. All that is needed here is N=0, N++, N==0, and some
  localised trickery is used to manufacture a 128-bit 0ULLL.

* src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h
- Improve unit tests; previously the testing human needed clairvoyance;
  now the test will do a basic check of compressibility. Clairvoyant
  talent is still a good idea.
- This is still a long way off a proper unit test.

* src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h
- Improve messy union to just uint128_t.
- Remove unneeded 'static struct fortuna_start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
  it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
  functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])

* src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h
- Improve messy union to just uint128_t.
- Remove unneeded 'staic struct start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
  it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
  functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
- Fix some magic numbers elsewhere used as FAST and SLOW.

Differential Revision: https://reviews.freebsd.org/D2025
Reviewed by: vsevolod,delphij,rwatson,trasz,jmg
Approved by: so (delphij)
</content>
</entry>
<entry>
<title>Attempt to mitigate poor initialization of arc4 by one-shot</title>
<updated>2013-04-19T00:30:52Z</updated>
<author>
<name>Andrey A. Chernov</name>
<email>ache@FreeBSD.org</email>
</author>
<published>2013-04-19T00:30:52Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=2b50ce65be6c97b3507d45275133df39e95752e8'/>
<id>urn:sha1:2b50ce65be6c97b3507d45275133df39e95752e8</id>
<content type='text'>
reinitialization from yarrow right after good entropy is harvested.

Approved by:    secteam (delphij)
MFC after:      1 week
</content>
</entry>
<entry>
<title>Return arc4_i = arc4_j = 0; line from previous backing out since</title>
<updated>2008-07-26T16:42:45Z</updated>
<author>
<name>Andrey A. Chernov</name>
<email>ache@FreeBSD.org</email>
</author>
<published>2008-07-26T16:42:45Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=b834665cd5ce6141136f2f7c63d1e495790cf82a'/>
<id>urn:sha1:b834665cd5ce6141136f2f7c63d1e495790cf82a</id>
<content type='text'>
just found it in OpenBSD, see their sys/crypto/arc4.c, function
rc4_keysetup, line ctx-&gt;x = ctx-&gt;y = 0;

Obtained from:  OpenBSD
</content>
</entry>
<entry>
<title>Per rwatson's request:</title>
<updated>2008-07-25T15:53:32Z</updated>
<author>
<name>Andrey A. Chernov</name>
<email>ache@FreeBSD.org</email>
</author>
<published>2008-07-25T15:53:32Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=fff6495ea645e54b761d6d0eb9c7137e64c756b7'/>
<id>urn:sha1:fff6495ea645e54b761d6d0eb9c7137e64c756b7</id>
<content type='text'>
"If you don't get a review within a day or two, I would firmly recommend
backing out the changes"

back out all my changes as unreviewed by secteam@ yet.
</content>
</entry>
<entry>
<title>1) Initialize arc4_i and arc4_j to 0 after key mixing as recommended in</title>
<updated>2008-07-22T16:16:51Z</updated>
<author>
<name>Andrey A. Chernov</name>
<email>ache@FreeBSD.org</email>
</author>
<published>2008-07-22T16:16:51Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=d16863efa66ca857d48eeb1b1918457a7556eadb'/>
<id>urn:sha1:d16863efa66ca857d48eeb1b1918457a7556eadb</id>
<content type='text'>
draft-kaukonen-cipher-arcfour-03.txt (3.1.5)

2) Drop first 768 bytes as standard RC4-drop(768)
</content>
</entry>
<entry>
<title>Lock down arc4random so it can be safely called w/o Giant.</title>
<updated>2003-08-15T06:34:47Z</updated>
<author>
<name>Mike Silbersack</name>
<email>silby@FreeBSD.org</email>
</author>
<published>2003-08-15T06:34:47Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=2f823fa326f4b593bb8b9e74606e70a864c25426'/>
<id>urn:sha1:2f823fa326f4b593bb8b9e74606e70a864c25426</id>
<content type='text'>
Minor code reorganization was required, but the only functional
change was that the first 1024 bytes of output are thrown out
after each reseed, rather than just the initial seed.
</content>
</entry>
<entry>
<title>Use __FBSDID().</title>
<updated>2003-06-11T05:37:42Z</updated>
<author>
<name>David E. O'Brien</name>
<email>obrien@FreeBSD.org</email>
</author>
<published>2003-06-11T05:37:42Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=ab0de15baf7234734b1b64c3145cd36f867c98ea'/>
<id>urn:sha1:ab0de15baf7234734b1b64c3145cd36f867c98ea</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Slight overhaul of arc4random() and friends.</title>
<updated>2002-10-11T13:13:08Z</updated>
<author>
<name>Poul-Henning Kamp</name>
<email>phk@FreeBSD.org</email>
</author>
<published>2002-10-11T13:13:08Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=2c38619b524c7d3ada336fc2aa3afcbb7dbff0f5'/>
<id>urn:sha1:2c38619b524c7d3ada336fc2aa3afcbb7dbff0f5</id>
<content type='text'>
One bug fixed:  Use getmicrouptime() to trigger reseeds so that we
cannot be tricked by a clock being stepped backwards.

Express parameters in natural units and with natural names.

Don't use struct timeval more than we need to.

Various stylistic and readability polishing.

Introduce arc4rand(void *ptr, u_int len, int reseed) function which
returns a stream of pseudo-random bytes, observing the automatic
reseed criteria as well as allowing forced reseeds.

Rewrite arc4random() in terms of arc4rand().

Sponsored by:   DARPA &amp; NAI Labs.
</content>
</entry>
</feed>
