about summary refs log tree commit diff
path: root/src/libutil/hash.cc
AgeCommit message (Collapse)AuthorFilesLines
2017-07-30 Replace Unicode quotes in user-facing strings by ASCIIJörg Thalheim1-9/+9
Relevant RFC: NixOS/rfcs#4 $ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
2017-07-28 nix-prefetch-url: Fix regression in hash printingEelco Dolstra1-1/+1
2017-07-10 Merge pull request #1422 from nh2/fix-potential-hash-comparison-crashEelco Dolstra1-0/+2
Fix potential crash/wrong result two hashes of unequal length are compared
2017-07-04 Support base-64 hashesEelco Dolstra1-97/+88
Also simplify the Hash API. Fixes #1437.
2017-06-24 Fix potential crash/wrong result two hashes of unequal length are comparedNiklas Hambüchen1-0/+2
2017-04-28 Fix hash computation when importing NARs greater than 4 GiBEelco Dolstra1-1/+1
This caused "nix-store --import" to compute an incorrect hash on NARs that don't fit in an unsigned int. The import would succeed, but "nix-store --verify-path" or subsequent exports would detect an incorrect hash. A deeper issue is that the export/import format does not contain a hash, so we can't detect such issues early. Also, I learned that -Wall does not warn about this.
2017-03-21 Move istringstream_nocopy to a separate fileEelco Dolstra1-1/+1
2017-03-06 istringstream_nocopy: Implement in a standards-compliant way.Shea Levy1-1/+1
Fixes the problem mentioned in e6a61b8da788efbbbb0eb690c49434b6b5fc9741 See #1135
2017-02-08 Include config.h implicitly with '-include config.h' in CFLAGSTuomas Tynkkynen1-2/+0
Because config.h can #define things like _FILE_OFFSET_BITS=64 and not every compilation unit includes config.h, we currently compile half of Nix with _FILE_OFFSET_BITS=64 and other half with _FILE_OFFSET_BITS unset. This causes major havoc with the Settings class on e.g. 32-bit ARM, where different compilation units disagree with the struct layout. E.g.: diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc @@ -166,6 +166,8 @@ void Settings::update() _get(useSubstitutes, "build-use-substitutes"); + fprintf(stderr, "at Settings::update(): &useSubstitutes = %p\n", &nix::settings.useSubstitutes); _get(buildUsersGroup, "build-users-group"); diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -138,6 +138,8 @@ void RemoteStore::initConnection(Connection & conn) void RemoteStore::setOptions(Connection & conn) { + fprintf(stderr, "at RemoteStore::setOptions(): &useSubstitutes = %p\n", &nix::settings.useSubstitutes); conn.to << wopSetOptions Gave me: at Settings::update(): &useSubstitutes = 0xb6e5c5cb at RemoteStore::setOptions(): &useSubstitutes = 0xb6e5c5c7 That was not a fun one to debug!
2016-11-06 Detect and disallow base32 hash overflowVladimír Čunát1-1/+7
Example (before this commit): $ nix-hash --type sha256 --to-base16 4n0igfxbd3kqvvj2k2xgysrp63l4v2gd110fwkk4apfpm0hvzwh0 \ | xargs nix-hash --type sha256 --to-base32 0n0igfxbd3kqvvj2k2xgysrp63l4v2gd110fwkk4apfpm0hvzwh0 It's a real-life example: https://github.com/NixOS/nixpkgs/pull/20208/files#r86695567
2016-07-21 Fix assertion failureEelco Dolstra1-1/+1
2016-07-21 NarInfo::NarInfo(): Ensure that we get a NAR size/hashEelco Dolstra1-0/+1
2016-07-11 Modernize AutoCloseFDShea Levy1-2/+2
2016-06-09 Use O_CLOEXEC in most placesEelco Dolstra1-1/+1
2016-04-20 Cache path info lookups in SQLiteEelco Dolstra1-6/+26
This re-implements the binary cache database in C++, allowing it to be used by other Store backends, in particular the S3 backend.
2016-01-27 Make hashLength32() a method of HashEelco Dolstra1-9/+3
2015-11-04 Support SHA-512 hashesEelco Dolstra1-0/+7
Fixes #679. Note: on x86_64, SHA-512 is considerably faster than SHA-256 (198 MB/s versus 131 MB/s).
2015-11-04 Require OpenSSLEelco Dolstra1-8/+0
2015-09-18 Shut up clang warningsEelco Dolstra1-1/+0
2015-02-03 Simplify parseHash32Eelco Dolstra1-37/+10
2015-02-03 Simplify printHash32Eelco Dolstra1-35/+17
2014-08-20 Use proper quotes everywhereEelco Dolstra1-7/+7
2012-10-23 If hashes do not match, print them in base-32 for SHA-1/SHA-256Eelco Dolstra1-0/+6
Fixes #57.
2012-02-09 Use data() instead of c_str() where appropriateEelco Dolstra1-3/+3
2011-12-15 * Refactoring: move sink/source buffering into separate classes.Eelco Dolstra1-10/+12
* Buffer the HashSink. This speeds up hashing a bit because it prevents lots of calls to the hash update functions (e.g. nix-hash went from 9.3s to 8.7s of user time on the closure of my /var/run/current-system).
2011-12-02 * Move parseHash16or32 into libutil, and use in nix-hash.Eelco Dolstra1-0/+16
2010-11-16 * Store the size of a store path in the database (to be precise, theEelco Dolstra1-3/+7
size of the NAR serialisation of the path, i.e., `nix-store --dump PATH'). This is useful for Hydra.
2010-03-09 * In `nix-store --export', abort if the contents of a path hasEelco Dolstra1-0/+7
changed. This prevents corrupt paths from spreading to other machines. Note that checking the hash is cheap because we're hashing anyway (because of the --sign feature).
2008-12-03 * Pass HashType values instead of strings.Eelco Dolstra1-0/+9
2008-08-25 * Doh.Eelco Dolstra1-1/+0
2008-08-25 * Strip off the `.nix' suffix from the attribute name for files inEelco Dolstra1-0/+1
~/.nix-defexpr, otherwise the attribute cannot be selected with the `-A' option. Useful if you want to stick a Nix expression directly in ~/.nix-defexpr.
2008-05-21 * GCC 4.3.0 (Fedora 9) compatibility fixes. Reported by Gour andEelco Dolstra1-0/+1
Armijn Hemel.
2007-02-21 * `nix-store --export --sign': sign the Nix archive using the RSA keyEelco Dolstra1-15/+24
in /nix/etc/nix/signing-key.sec
2006-12-12 * New primop builtins.filterSource, which can be used to filter filesEelco Dolstra1-2/+2
from a source directory. All files for which a predicate function returns true are copied to the store. Typical example is to leave out the .svn directory: stdenv.mkDerivation { ... src = builtins.filterSource (path: baseNameOf (toString path) != ".svn") ./source-dir; # as opposed to # src = ./source-dir; } This is important because the .svn directory influences the hash in a rather unpredictable and variable way.
2006-11-30 * Skeleton of the privileged worker program.Eelco Dolstra1-1/+1
* Some refactoring: put the NAR archive integer/string serialisation code in a separate file so it can be reused by the worker protocol implementation.
2006-09-20 * Print a better error message for wrong hashes (NIX-49).Eelco Dolstra1-1/+7
2006-09-04 * Use a proper namespace.Eelco Dolstra1-2/+9
* Optimise header file usage a bit. * Compile the parser as C++.
2006-03-09 * Ugh, printHash() was very inefficient because it usedEelco Dolstra1-5/+7
ostringstreams. Around 11% of execution time was spent here (now it's 0.5%).
2006-03-01 * Ouch, parseHash32 was completely broken. All digits >= 4 wereEelco Dolstra1-1/+1
parsed as 4. For a moment I worried that printHash32 was broken, and that would have been really, *really* bad ;-)
2006-02-13 * Optional switch "--with-openssl=<PATH>" to use OpenSSL'sEelco Dolstra1-11/+15
implementations of MD5, SHA-1 and SHA-256. The main benefit is that we get assembler-optimised implementations of MD5 and SHA-1 (though not SHA-256 (at least on x86), unfortunately). OpenSSL's SHA-1 implementation on Intel is twice as fast as ours.
2006-02-13 * Use a union.Eelco Dolstra1-2/+1
2005-11-16 * Did something useful while waiting at IAD: reference scanning is nowEelco Dolstra1-1/+5
much faster.
2005-03-23 * Fix endianness bug.Eelco Dolstra1-18/+18
2005-01-17 * Removed the `id' attribute hack.Eelco Dolstra1-3/+61
* Formalise the notion of fixed-output derivations, i.e., derivations for which a cryptographic hash of the output is known in advance. Changes to such derivations should not propagate upwards through the dependency graph. Previously this was done by specifying the hash component of the output path through the `id' attribute, but this is insecure since you can lie about it (i.e., you can specify any hash and then produce a completely different output). Now the responsibility for checking the output is moved from the builder to Nix itself. A fixed-output derivation can be created by specifying the `outputHash' and `outputHashAlgo' attributes, the latter taking values `md5', `sha1', and `sha256', and the former specifying the actual hash in hexadecimal or in base-32 (auto-detected by looking at the length of the attribute value). MD5 is included for compatibility but should be considered deprecated. * Removed the `drvPath' pseudo-attribute in derivation results. It's no longer necessary. * Cleaned up the support for multiple output paths in derivation store expressions. Each output now has a unique identifier (e.g., `out', `devel', `docs'). Previously there was no way to tell output paths apart at the store expression level. * `nix-hash' now has a flag `--base32' to specify that the hash should be printed in base-32 notation. * `fetchurl' accepts parameters `sha256' and `sha1' in addition to `md5'. * `nix-prefetch-url' now prints out a SHA-1 hash in base-32. (TODO: a flag to specify the hash.)
2005-01-14 * Shorten SHA-256 hashes used in store path name generation to 160Eelco Dolstra1-6/+66
bits, then encode them in a radix-32 representation (using digits and letters except e, o, u, and t). This produces store paths like /nix/store/4i0zb0z7f88mwghjirkz702a71dcfivn-aterm-2.3.1. The nice thing about this is that the hash part of the file name is still 32 characters, as before with MD5. (Of course, shortening SHA-256 to 160 bits makes it no better than SHA-160 in theory, but hopefully it's a bit more resistant to attacks; it's certainly a lot slower.)
2005-01-14 * Start move towards SHA-256 hashes instead of MD5.Eelco Dolstra1-0/+1
* Start cleaning up unique store path generation (they weren't always unique; in particular the suffix ("-aterm-2.2", "-builder.sh") was not part of the hash, therefore changes to the suffix would cause multiple store objects with the same hash).
2005-01-14 * Add SHA-256.Eelco Dolstra1-0/+6
* Tests for the various hashes.
2005-01-13 * Added SHA-1 support. `nix-hash' now has an option `--type sha1' toEelco Dolstra1-17/+70
select SHA-1 hashing.
2005-01-13 * Refactoring to support SHA-1.Eelco Dolstra1-8/+12
2003-11-18 * Source tree refactoring.Eelco Dolstra1-0/+124