diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-14T16·04+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-14T16·04+0000 |
commit | d58a11e019813902b6c4547ca61a127938b2cc20 (patch) | |
tree | ddaff27d1a3c0604ffac989867cf63fbf8ce94ff /src/libstore/references.cc | |
parent | 9530cc31700f68fd229eee69eabd2baa099f404a (diff) |
* Shorten SHA-256 hashes used in store path name generation to 160
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.)
Diffstat (limited to 'src/libstore/references.cc')
-rw-r--r-- | src/libstore/references.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstore/references.cc b/src/libstore/references.cc index 9b20b980a1b2..5ceae6427617 100644 --- a/src/libstore/references.cc +++ b/src/libstore/references.cc @@ -81,8 +81,12 @@ Strings filterReferences(const string & path, const Strings & paths) for (Strings::const_iterator i = paths.begin(); i != paths.end(); i++) { - string s = string(baseNameOf(*i), 0, 32); - parseHash(s); + string baseName = baseNameOf(*i); + unsigned int pos = baseName.find('-'); + if (pos == string::npos) + throw Error(format("bad reference `%1%'") % *i); + string s = string(baseName, 0, pos); + // parseHash(htSHA256, s); ids.push_back(s); backMap[s] = *i; } |