diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-02-21T14·31+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-02-21T14·31+0000 |
commit | 46e0919ced4646004cc0701b188d0a68e24e8924 (patch) | |
tree | 3262f8068c38489029753c528a123b2c685aea68 /src/libutil/hash.cc | |
parent | 6c9fdb17fbda181fc09a9ce1f49662ef522d006b (diff) |
* `nix-store --export --sign': sign the Nix archive using the RSA key
in /nix/etc/nix/signing-key.sec
Diffstat (limited to 'src/libutil/hash.cc')
-rw-r--r-- | src/libutil/hash.cc | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 262dbef20df2..3d20d2d50d50 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -282,30 +282,39 @@ Hash hashFile(HashType ht, const Path & path) } -struct HashSink : Sink +HashSink::HashSink(HashType ht) : ht(ht) { - HashType ht; - Ctx ctx; - virtual void operator () - (const unsigned char * data, unsigned int len) - { - update(ht, ctx, data, len); - } -}; + ctx = new Ctx; + start(ht, *ctx); +} + +HashSink::~HashSink() +{ + delete ctx; +} +void HashSink::operator () + (const unsigned char * data, unsigned int len) +{ + update(ht, *ctx, data, len); +} -Hash hashPath(HashType ht, const Path & path, PathFilter & filter) +Hash HashSink::finish() { - HashSink sink; - sink.ht = ht; Hash hash(ht); - start(ht, sink.ctx); - dumpPath(path, sink, filter); - finish(ht, sink.ctx, hash.hash); + nix::finish(ht, *ctx, hash.hash); return hash; } +Hash hashPath(HashType ht, const Path & path, PathFilter & filter) +{ + HashSink sink(ht); + dumpPath(path, sink, filter); + return sink.finish(); +} + + Hash compressHash(const Hash & hash, unsigned int newSize) { Hash h; |