================================================================================
Original work (MIT)
================================================================================

The R source and build glue in this package -- src/binding.c, src/init.c,
src/memio.c, src/platform.c, src/platform.h, src/fileio.c, src/agec/agecore.c,
src/agec/agecore.h, src/agec/agec.h, src/agec/memio.h, src/agec/fileio.h, and
everything under R/ --
are Copyright (c) 2026 Pedro Baltazar and licensed under the MIT licence, as
stated in DESCRIPTION and LICENSE.


================================================================================
Vendored work: agec (0BSD)
================================================================================

The remaining C sources under src/agec/ (base64, bech32, header, io, keyenc,
parse, payload, scrypt, util, x25519, common.h, and everything under
src/agec/crypto/) are vendored from "agec", a C implementation of the age file
encryption format.

    Upstream base:      https://git.sr.ht/~min/agec
                        commit 85ace80cc4137095ca204eba5e099be4e978d889
                        (git describe: 1.0.0-0-g85ace80, dated 2026-08-30)
    Vendored snapshot:  https://github.com/pedrobtz/agec, tag vendor-2026-09-30
                        commit 0b9532bd0133873947f3c2aa14b5198cf028ca41 -- the
                        upstream base above plus the fixes marked
                        "[in snapshot]" below.

agec is distributed under the following terms (0BSD), reproduced from its
LICENSE file:

    Permission to use, copy, modify, and/or distribute this software for
    any purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Not vendored: agec's CLI drivers (agec.c, agecgen.c) and its Unix/Plan 9
platform layers are not included; randomness and file helpers are provided by
this package's own src/platform.c and src/fileio.c instead.


Local modifications to the vendored agec sources
------------------------------------------------

These fall into two groups. The fixes marked [in snapshot] are committed in the
vendored snapshot (tag vendor-2026-09-30); each lives on its own fix/* branch
of the agec fork and is upstreamable. The ones marked [package-only] are
applied to src/agec/ in this package on top of that snapshot, and are marked
with a comment at the site in the source.

  * src/agec/io.c
      - [package-only] the read()/write() calls are routed through
        ageread()/agewrite() so the buffers can be backed by memory
        (src/memio.c) as well as file descriptors.
      - [in snapshot] bwrite(): cast before pointer arithmetic on the void *
        argument, a GNU extension that -pedantic reports.
      - [in snapshot] isarmor(): the armor-probe size check is a compile-time
        check rather than an assert(), and common.h no longer includes
        <assert.h>, so compiled code cannot call abort().
  * src/agec/parse.c
      - [in snapshot] skipargbody(): check a stanza body line's length before
        storing the next character. Upstream wrote a 65th character one byte
        past the end of the 64-byte stack buffer. Bug fix (memory safety),
        found by fuzzing.
  * src/agec/scrypt.c
      - [package-only] added scryptstanzacost(), a work-factor-parameterised
        variant of scryptstanza(), so the R-level log_n argument can be threaded
        through.
  * src/agec/payload.c
      - [in snapshot] renamed the static helper eof() to ateof(): on Windows the
        real <io.h> declares a CRT eof(int) that conflicts. File-local rename
        only.
      - [in snapshot] incnonce(): increment nonce[0..10] and report a full
        wrap. Upstream stops the loop at i == 1, so nonce[0] is never touched
        (a 10-byte counter rather than the 11 the age spec defines) and its
        `if(i == 0)` overflow guard is unreachable, so a wrap silently reused a
        nonce. No wire-format change for any reachable payload size.

Fixes carried by earlier snapshots that upstream has since adopted in its own
form: bwrite() output truncation at the 8 KiB buffer boundary, short
unarmored input reads, and the recappend()/hdrappend() allocation-failure
handling.


================================================================================
Third-party sources bundled within agec (public domain)
================================================================================

agec itself bundles the following implementations, all placed in the public
domain by their authors:

  src/agec/base64.c           Wei Zhicheng
                              https://github.com/zhicheng/base64 (81060e3)
  src/agec/bech32.c           Pascal S. de Kloe
                              https://github.com/pascaldekloe/bech32 (43757af)
  src/agec/crypto/curve25519.c ref10 implementation from SUPERCOP
  src/agec/crypto/chacha20poly1305.c  extracted from monocypher 4.0.2
  src/agec/crypto/sha256.c    based on FIPS 180-3
  src/agec/crypto/scrypt.c    scrypt-jane
                              https://github.com/floodyberry/scrypt-jane (0ab6125)

To update the vendored copy, see .agents/vendoring-agec.md.


================================================================================
Bundled test data
================================================================================

tests/testthat/fixtures/vectors/ contains a subset of the age test vectors from
the C2SP CCTV project (the age "testkit"), obtained via the vendored agec test
suite. They are Copyright (c) 2022 The age Authors and available under the
Zero-Clause BSD, CC0 1.0, or Unlicense licence (your choice).

    https://github.com/C2SP/CCTV/tree/main/age

tests/testthat/fixtures/interop/ contains ciphertexts and a throwaway key
generated locally with the reference age implementation
(https://github.com/FiloSottile/age); they are original test fixtures for this
package. See tests/testthat/fixtures/README.md.
