John Ericson
12bb8cdd38
Signer infrastructure: Prep for #9076
...
This sets up infrastructure in libutil to allow for signing other than
by a secret key in memory. #9076 uses this to implement remote signing.
(Split from that PR to allow reviewing in smaller chunks.)
Co-Authored-By: Raito Bezarius <masterancpp@gmail.com>
2024-01-03 16:13:55 -05:00
John Ericson
dfc876531f
Organize content addressing, use SourceAccessor
with Store::addToStore
...
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-12-18 10:41:54 -05:00
Peter Kolloch
fc6f29053a
Renamed HashFormat::Base32 to HashFormat::Nix32
...
...and also adjusted parsing accordingly.
Also added CLI completion for HashFormats.
https://github.com/NixOS/nix/issues/8876
2023-12-06 23:43:42 +01:00
Peter Kolloch
5334c9c792
HashType: Rename to HashAlgorithm
...
To be consistent with CLI, nix API
and many other references.
As part of this, we also converted it to a scoped enum.
https://github.com/NixOS/nix/issues/8876
2023-12-06 23:43:42 +01:00
Peter Kolloch
0c2d5f7673
nix hash convert: s/--type/--algo/ + more functional tests
...
https://github.com/NixOS/nix/issues/8876
2023-12-06 23:43:42 +01:00
Peter Kolloch
e7abf60a0c
hash.cc/hash.h: Minor C++ improvements
2023-12-06 23:41:07 +01:00
John Ericson
ac89bb064a
Split up util.{hh,cc}
...
All OS and IO operations should be moved out, leaving only some misc
portable pure functions.
This is useful to avoid copious CPP when doing things like Windows and
Emscripten ports.
Newly exposed functions to break cycles:
- `restoreSignals`
- `updateWindowSize`
2023-11-05 12:20:02 -05:00
Yueh-Shun Li
6b47635180
Add helper function parseHashFormat[Opt] printHashFormat
...
Add hash format analogy of
parseHashTypeOpt, parseHashType, and printHashType.
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-10-19 00:56:44 +08:00
Yueh-Shun Li
231b0fca6d
Migrate HashFormat to scoped enumeration (enum struct)
2023-10-19 00:56:44 +08:00
Yueh-Shun Li
e026f3e1ae
treewide: Reference HashFormat members with scope
...
Base* -> HashFormat::Base*
2023-10-19 00:56:41 +08:00
Yueh-Shun Li
5043e6cf4e
Document HashFormat
2023-10-19 00:38:32 +08:00
Yueh-Shun Li
838c70f621
treewide: Rename hashBase to hashFormat
...
hashBase is ambiguous, since it's not about the digital bases, but about
the format of hashes. Base16, Base32 and Base64 are all character maps
for binary encoding.
Rename the enum Base to HashFormat.
Rename variables of type HashFormat from [hash]Base to hashFormat,
including CmdHashBase::hashFormat and CmdToBase::hashFormat.
2023-10-19 00:38:32 +08:00
John Ericson
39ba81a4eb
Improve internal API docs for two file hashing functions
...
Co-Authored-By: Matthew Bauer <mjbauer95@gmail.com>
Co-Authored-By: Carlo Nucera <carlo.nucera@protonmail.com>
2023-09-22 09:10:32 -04:00
Théophane Hufschmitt
214f1d6791
Rename and protect BufferedSink::write
...
The `write` name is ambiguous and could lead to some funny bugs like
https://github.com/NixOS/nix/pull/8173#issuecomment-1500009480 . So
rename it to the more explicit `writeUnbuffered`.
Besides, this method shouldn't be (and isn't) used outside of the class
implementation, so mark it `protected`.
This makes it more symetrical to `BufferedSource` which uses a
`protected readUnbuffered` method.
2023-04-07 09:21:50 +02:00
John Ericson
f4ab297b31
Ensure all headers have #pragma once
and are in API docs
...
`///@file` makes them show up in the internal API dos. A tiny few were
missing `#pragma once`.
2023-03-31 23:19:44 -04:00
John Ericson
abd5e7dec0
Extend internal API docs, part 2
...
Picking up from #8111 .
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2023-03-31 23:01:40 -04:00
Vaci Koblizek
ccf7ce26fe
return string_view from printHashType rather than string
2023-03-29 10:44:22 +01:00
Kasper Gałkowski
2c2fd4946f
don't assume that rev is a SHA1 hash
...
This was a problem when writing a fetcher that uses e.g. sha256 hashes
for revisions. This doesn't actually do anything new, but allows for
creating such fetchers in the future (perhaps when support for Git's
SHA256 object format gains more popularity).
2022-04-07 19:49:47 +02:00
Eelco Dolstra
df552ff53e
Remove std::string alias (for real this time)
...
Also use std::string_view in a few more places.
2022-02-25 16:13:02 +01:00
pennae
41d70a2fc8
return string_views from forceString*
...
once a string has been forced we already have dynamic storage allocated for it,
so we can easily reuse that storage instead of copying.
2022-01-27 17:15:43 +01:00
Eelco Dolstra
faa31f4084
Sink: Use std::string_view
2020-12-02 14:17:27 +01:00
Carlo Nucera
8241e660ba
Remove Hash::operator bool ()
...
Since the hash is not optional anymore
2020-08-05 15:30:38 -04:00
Carlo Nucera
1ad6394b33
Add Hash::dummy to signal default value
...
We did this in the same spirit of the dummy value that's present in
libstore/path.hh
2020-08-05 15:11:49 -04:00
John Ericson
bc165e28ae
Embelish documentation of new Hash functions
2020-08-01 15:32:20 +00:00
John Ericson
3cbee1e840
Convert to C-style comments
2020-08-01 15:26:57 +00:00
Carlo Nucera
eee6ef86cd
Merge branch 'master' of github.com:NixOS/nix into better-ca-parse-errors
2020-07-30 18:27:25 -04:00
Eelco Dolstra
3f6e88a552
unsigned long long -> uint64_t
2020-07-30 13:34:04 +02:00
John Ericson
cc0d77f8c9
Merge branch 'hash-always-has-type' of github.com:obsidiansystems/nix into better-ca-parse-errors
2020-07-16 17:28:52 +00:00
John Ericson
5ea817dace
Merge remote-tracking branch 'upstream/master' into hash-always-has-type
2020-07-16 14:58:53 +00:00
Carlo Nucera
b6b10b1d4c
Write the implementation for parseNonSRIUnprefixed
2020-07-02 11:34:40 -04:00
Carlo Nucera
9462d8a50b
Rename fromSRI to parseSRI for constistency
2020-07-02 11:11:18 -04:00
Carlo Nucera
f61bc45d19
Get rid of the std::pair
2020-07-02 11:09:04 -04:00
Carlo Nucera
263ccdd489
Rename two hash constructors to proper functions
2020-07-01 18:34:18 -04:00
Carlo Nucera
c8c4bcf90e
Inline Hash::init()
2020-07-01 18:03:35 -04:00
Carlo Nucera
274a8136fb
Correct FIXMEs in libfetchers
2020-07-01 17:47:15 -04:00
Carlo Nucera
c2e7f7a712
Fixed build, we still have test errors
2020-07-01 17:32:06 -04:00
Carlo Nucera
b798efb829
WIP initial design
2020-06-30 14:10:30 -04:00
John Ericson
987a4a0be9
Merge remote-tracking branch 'upstream/master' into hash-always-has-type
2020-06-29 18:03:21 +00:00
Eelco Dolstra
adf2fbbdc2
Merge remote-tracking branch 'origin/master' into flakes
2020-06-26 08:46:46 +02:00
Eelco Dolstra
de2641ae99
Fix empty std::optional dereference in writeDerivation()
...
https://hydra.nixos.org/build/123017579
2020-06-25 15:50:30 +02:00
John Ericson
20799a5151
WIP: Make Hash always store a valid hash type
2020-06-19 19:32:29 +00:00
John Ericson
15abb2aa2b
Revert the enum struct
change
...
Not a regular git revert as there have been many merges and things.
2020-06-18 22:11:26 +00:00
John Ericson
bbbf3602a3
Merge branch 'enum-class' into no-hash-type-unknown
2020-06-18 22:11:19 +00:00
John Ericson
40526fbea5
Merge remote-tracking branch 'upstream/master' into enum-class
2020-06-18 21:38:15 +00:00
Eelco Dolstra
1524752c17
Merge remote-tracking branch 'origin/master' into flakes
2020-06-17 10:26:52 +02:00
John Ericson
f6f01416b7
Use std::string_view
in a few more places
2020-06-12 21:32:30 +00:00
Eelco Dolstra
00fa7e2205
Merge pull request #3674 from matthewbauer/allow-empty-hash2
...
Allow empty hash in derivations
2020-06-12 18:18:12 +02:00
Matthew Bauer
b260c9ee03
Add newHashAllowEmpty helper function
...
This replaces the copy&paste with a helper function in hash.hh.
2020-06-12 10:11:16 -05:00
zimbatm
6ee03b8444
libutils/hash: remove default encoding
...
This will make it easier to reason about the hash encoding and switch to
SRI everywhere where possible.
2020-06-03 13:49:51 +02:00
John Ericson
450dcf2c1b
Remove HashType::Unknown
...
Instead, `Hash` uses `std::optional<HashType>`. In the future, we may
also make `Hash` itself require a known hash type, encoraging people to
use `std::optional<Hash>` instead.
2020-06-02 15:52:13 +00:00