Commit Graph

11315 Commits (317c555a5cdc52612e998d8b4bcbaf730be1a6f1)

Author SHA1 Message Date
Andrew Kelley 9052e0b137
Merge pull request #6713 from jprudil/close-6697
Make std.meta.Int accept a signedness parameter
2020-10-17 18:55:25 -04:00
Frank Denis fa17447090 std/crypto: make the whole APIs more consistent
- use `PascalCase` for all types. So, AES256GCM is now Aes256Gcm.
- consistently use `_length` instead of mixing `_size` and `_length` for the
constants we expose
- Use `minimum_key_length` when it represents an actual minimum length.
Otherwise, use `key_length`.
- Require output buffers (for ciphertexts, macs, hashes) to be of the right
size, not at least of that size in some functions, and the exact size elsewhere.
- Use a `_bits` suffix instead of `_length` when a size is represented as a
number of bits to avoid confusion.
- Functions returning a constant-sized slice are now defined as a slice instead
of a pointer + a runtime assertion. This is the case for most hash functions.
- Use `camelCase` for all functions instead of `snake_case`.

No functional changes, but these are breaking API changes.
2020-10-17 18:53:08 -04:00
Andrew Kelley 0011def2b2 fix compilation error when building with io_mode evented
The merge of #5613 introduced a regression when building with io_mode
evented, fixed in this commit.

closes #6715
2020-10-17 15:46:36 -07:00
Vexu e8ca1b254d
std: remove renderStringLiteral in favor of std.fmt specifier 2020-10-17 23:20:38 +03:00
Sebastien Marie 35a7247a2c
Merge branch 'master' into openbsd-minimal 2020-10-17 17:38:23 +02:00
Jan Prudil 132813849c Convert remaining call sites 2020-10-17 14:50:26 +02:00
Jan Prudil aadccc4206 Make std.meta.Int accept a signedness parameter 2020-10-17 14:09:59 +02:00
Vexu 2c294676b5
use new format specifier in translate-c and std lib 2020-10-17 10:27:19 +03:00
Vexu 8d38a91ca8
std.fmt: add specifier for Zig identifiers 2020-10-17 10:26:59 +03:00
Andrew Kelley 245d98d32d
Merge pull request #6291 from pixelherodev/cbe_arithmetic
CBE: addition and subtraction
2020-10-17 01:00:38 -04:00
Andrew Kelley 9241c1b772 Merge branch 'nmichaels-zbs-doc'
closes #5800
2020-10-16 21:33:04 -07:00
Andrew Kelley 9ca8bcb4d9 langref cleanups
* move the opaque section to after struct, enum, union, and add
   hyperlinks
 * improve the introduction of the zig build system. don't link to the
   wiki.
 * update to the latest zig init-exe example code
 * rename headers to avoid redundant words such as "zig"
 * simplify example code
2020-10-16 21:29:33 -07:00
Nathan Michaels eb80cc2b9e Add some basic examples for the Zig Build System. 2020-10-16 21:29:22 -07:00
Andrew Kelley 6850e54cc0 Merge branch 'vegecode-byteOffsetOf_fix'
closes #5713
2020-10-16 21:25:42 -07:00
vegecode 2545f44db0 byteOffsetOf add fields to non-packet struct to maintain symmetry 2020-10-16 20:04:42 -07:00
vegecode 0456b2145d byteOffsetOf rounds up using bit offset in host integer 2020-10-16 20:04:42 -07:00
Juha Syrjälä 79ef96b6a4 Add support for `zig build run -- arg1 arg1` in file created by init-exe 2020-10-16 21:29:24 -04:00
Andrew Kelley 8a2d12d707
Merge pull request #6393 from onebsv1/priority-queue-update
Adding a function to update the priority of an element
2020-10-16 21:26:04 -04:00
LemonBoy d44486b274 std: Add libssp implementation for GNU/Windows targets
Unlike glibc and musl, MinGW provides no libssp symbols leading to
countless compile errors if FORTIFY_SOURCE is defined.

Add a (incomplete) implementation of libssp written in Zig so that
linking succeeds.

Closes #6492
2020-10-16 21:22:14 -04:00
Andrew Kelley 2aff27d922 Merge branch '6604'
closes #6604
2020-10-16 18:15:31 -07:00
Andrew Kelley 5c16022c81 rename WaitpidRet to WaitPidResult 2020-10-16 18:14:39 -07:00
stf 3921cb0d8d std.os.waitpid: also return pid of child
closes #6581
2020-10-16 17:26:50 -07:00
Isaac Freund 0e4c3934a0 zig fmt: write modified files to stdout not stderr 2020-10-16 20:23:18 -04:00
Andrew Kelley 8364417c8f trivial refactor to remove redundant function call 2020-10-16 16:15:50 -07:00
Jakub Konka fe127a3691 Add llvm-config detection when dynlinking clang 2020-10-16 19:14:42 -04:00
Jakub Konka abd72781a3 Allow linking with dynamic libraries in main CLI 2020-10-16 19:14:42 -04:00
Frank Denis 0b4a5254fa Vectorize Gimli 2020-10-16 18:41:11 -04:00
LemonBoy f78380b936 stage1: Don't ask LLVM to emit misaligned memcpy
Pay close attention to the RHS type alignment when rendering an
assignment op as it may differ from the LHS pointer one.

This problem was noticed when debugging a CI failure in #6648: due to
sheer luck the misalignment caused a segfault on macos that was also
reproduced locally.

I tried to write a small test case but it turned out to be a daunting
task as I couldn't manage to trigger the problem consistently (and stop
the optimizer from simplifying everything). Patches welcome.
2020-10-16 18:39:48 -04:00
LemonBoy 2a62d4b20b stage1: Expand undefined struct/arrays when indexed
Fixes #6693
2020-10-16 17:13:38 +03:00
Andrew Kelley 996a2284dd Merge branch 'AnthonyYoManz-5002-fix-entrypoint-with-winmain'
closes #5002
closes #5613
2020-10-15 19:39:44 -07:00
Andrew Kelley d87bd3d8af fixups regarding windows wide strings
* remove GetModuleHandleA from kernel32.zig. use of A functions
   considered harmful.
 * make it a compile error to expose WinMain instead of wWinMain. same
   thing.
 * start code declares wWinMainCRTStartup instead of WinMainCRTStartup
   when it has the choice.
2020-10-15 19:37:55 -07:00
Andrew Kelley c7c38e7279 Merge branch '5002-fix-entrypoint-with-winmain' of https://github.com/AnthonyYoManz/zig into AnthonyYoManz-5002-fix-entrypoint-with-winmain 2020-10-15 18:22:12 -07:00
Frank Denis 51a3d0603c std.rand: set DefaultCsprng to Gimli, and require a larger seed
`DefaultCsprng` is documented as a cryptographically secure RNG.

While `ISAAC` is a CSPRNG, the variant we have, `ISAAC64` is not.
A 64 bit seed is a bit small to satisfy that claim.

We also saw it being used with the current date as a seed, that
also defeats the point of a CSPRNG.

Set `DefaultCsprng` to `Gimli` instead of `ISAAC64`, rename
the parameter from `init_s` to `secret_seed` + add a comment to
clarify what kind of seed is expected here.

Instead of directly touching the internals of the Gimli implementation
(which can change/be architecture-specific), add an `init()` function
to the state.

Our Gimli-based CSPRNG was also not backtracking resistant. Gimli
is a permutation; it can be reverted. So, if the state was ever leaked,
future secrets, but also all the previously generated ones could be
recovered. Clear the rate after a squeeze in order to prevent this.

Finally, a dumb test was added just to exercise `DefaultCsprng` since
we don't use it anywhere.
2020-10-15 20:57:16 -04:00
Andrew Kelley f701459f04
Merge pull request #6685 from ifreund/bufprint0
std/fmt: rename allocPrint0() to allocPrintZ(), add bufPrintZ()
2020-10-15 20:51:25 -04:00
Frank Denis cb44f27104 std/crypto/hmac: remove HmacBlake2s256 definition
HMAC is a generic construction, so we allow it to be instantiated
with any hash function.

In practice, HMAC is almost exclusively used with MD5, SHA1 and SHA2,
so it makes sense to define some shortcuts for them.

However, defining `HmacBlake2s256` is a bit weird (and why
specifically that one, and not other hash functions we also support?).
There would be nothing wrong with that construction, but it's not
used in any standard protocol and would be a curious choice.

BLAKE2 being a keyed hash function, it doesn't need HMAC to be used as
a MAC, so that also doesn't make it a good example of a possible hash
function for HMAC.

This commit doesn't remove the ability to use a Hmac(Blake2s256) type
if, for some reason, applications really need this, but it removes
HmacBlake2s256 as a constant.
2020-10-15 20:50:34 -04:00
Andrew Kelley a66449c1ed
Merge pull request #6616 from fengb/darwin-rusage
Darwin rusage
2020-10-15 20:49:54 -04:00
Andrew Kelley ee0ba9ec7d Merge branch 'g-w1-master'
closes #6627
2020-10-15 17:44:26 -07:00
Andrew Kelley 09a250c531 adjust error message of zig run with no args
previously it said "one source file" which was not correct
2020-10-15 17:44:10 -07:00
g-w1 dfce396cf8 friendly error message for zig run with no args 2020-10-15 17:43:44 -07:00
Tadeo Kondrak e892ee17e6 std: move std.meta.refAllDecls to std.testing 2020-10-15 20:34:22 -04:00
Andrew Kelley 0da027f078 Merge branch 'g-w1-zig-test-zig-run-execve'
closes #6653
2020-10-15 17:19:47 -07:00
Andrew Kelley 43c2ce10a1 fixups
* extract logic into a `os_can_execve` and use it in the other place
   that we execve
 * outdent some code by introducing `run_or_test` variable
 * delete unnecessary and wasteful memory management logic
 * better error message for when execve fails
 * add comment to explain why we do not execve for `zig test`
2020-10-15 17:18:40 -07:00
g-w1 1c36680928 stage2: use execve where available for zig test and zig run
closes #6531
2020-10-15 16:54:50 -07:00
Andrew Kelley e17297102a Merge branch 'kubkon-enable-stage2-macos-tests'
closes #6661
2020-10-15 16:48:44 -07:00
Andrew Kelley d91e75f5ca getExternalExecutor fixups regarding dynamic linker
* std.Target.standardDynamicLinkerPath: macOS has a dynamic linker
 * no need to override the default dynamic linker in the macos
   CrossTarget initialization in the tests
 * in getExternalExecutor, when validating the dynamic linker path, take
   into account the standard dynamic linker path.
2020-10-15 16:44:16 -07:00
Clayton Voges 8c4031fd87 replaced inStream() with reader()
`inStream()` is now deprecated and deserves replacing.
2020-10-15 19:30:21 -04:00
Jakub Konka 0e1afee732 Enable stage2 end-to-end tests on macOS run natively
This commit enables stage2 end-to-end tests to run natively on macOS
(where and when applicable). Since QEMU on macOS doesn't support
the same type of architecture emulation as it does on linux (i.e.,
there is no `qemu-x86_64` for instance), this commit ensures that we
specify a path to dynamic linker on macOS (`/usr/lib/dyld`) which
is then checked for existence in `std.CrossTarget.getExternalExecutor()`
function, and if exists, we can run the test natively.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-10-15 15:59:16 -07:00
Frank Denis f3667e8a80 std/crypto/25519: do cofactored ed25519 verification
This is slightly slower but makes our verification function compatible
with batch signatures. Which, in turn, makes blockchain people happy.
And we want to make our users happy.

Add convenience functions to substract edwards25519 points and to
clear the cofactor.
2020-10-15 18:49:10 -04:00
LemonBoy ab585c680b stage1: Off-by-one error in int to float conversion
The base is 2^64 and not 2^64-1.

Closes #6683
2020-10-15 21:25:59 +03:00
Isaac Freund 7b150dd05e docs: snake_case enums/unions in langref examples
This follows the accepted change to the style guide:
https://github.com/ziglang/zig/issues/2101
2020-10-15 18:55:57 +03:00