MERKLETREE(1)

NAME
merkletree - Calculate and verify Merkle tree information

SYNOPSIS
merkletree -V [-a digest-algorithm] [-b blocksize] [-m max-input-size] [-o output-file] [-v sum-file] [file ...]

DESCRIPTION
The merkletree command performs Merkle tree calculation and verification on the input data. This allows the establishment of the block positions (i.e. relative neighbourhood) of any changed data. The merkletree utility uses the libmerkletree(3) library. For a more in-depth description of Merkle trees, please see libmerkletree(3).

The following options are available:

-V sumfile
    Verify the information found in the previously-generated Merkle tree sum-file against the file named on the command line.

-a digest
    Use the digest algorithm in the operand. The full list of digests available is given in libmultigest(3), which is used internally in libmerkletree(3) to calculate digests.

-b blocksize
    Use the blocksize specified in the operand. Block sizes can be arbitrarily large or small, but may not be 0.

-m maxsize
    If data is to be read on standard input, resources are allocated to hold the data being used to calculate the Merkle tree sums. In order to avoid exhaustion of resources, the amount of data which can be specified by default is 10 Megabytes. This argument allows this amount to be varied on the command line.

-o outputfile
    Output results to the outputfile name specified as the operand.

-v  Print the version information of merkletree on stdout and exit.

When verifying, for obvious reasons, the digest algorithm and the blocksize used to calculate the stored tree are used when verifying the data.

During verification, if a mismatch is found, the block number will be printed on the standard output, along with the byte offsets of the start and end of the block. This is repeated for each block in which a mismatch is found.

RETURN VALUES
The merkletree utility will return 0 for success, and 1 for failure.

EXAMPLES

    % merkletree Makefile
    merkletree sha1 1 144 512 (Makefile) = f2f61cbd72f16d10bf83f5a952dffc28f5addd83
    % merkletree -b 60 Makefile
    merkletree sha1 2 144 60 (Makefile) = a7ca944a6f7edc6a0ce60038e9d8c2899baeaf55c63987e6049abe2096c3bc0e4811b8112714a0f369666ab31e2fd8f4900444e1b001e3debba8e8f196a50d7648660b2dc441e0757465786921ecca4e8ab0b6353e5992c59e70b724a3cc0c527cda3edc
    % merkletree -a rmd160,sha1 Makefile
    merkletree rmd160,sha1 1 144 512 (Makefile) = f96c883de70b5bb3b3ad3d207b00ce174131f523f2f61cbd72f16d10bf83f5a952dffc28f5addd83
    % merkletree -a rmd160,sha1 -o Makefile.sum Makefile
    % merkletree -v Makefile.sum Makefile
    % echo "# comment" >> Makefile
    % merkletree -v Makefile.sum Makefile
    [0] 0, 511
    %

SEE ALSO
libmerkletree(3), libmultigest(3)

HISTORY
The merkletree command first appeared in NetBSD 7.0.

AUTHORS
-nosplit Alistair Crooks <agc@netbsd.org>.