From d75cbb01db4f7fb73c4382af4351dc0e393d5d39 Mon Sep 17 00:00:00 2001 From: Rocknest <35231115+Rocknest@users.noreply.github.com> Date: Sun, 13 Sep 2020 23:00:33 +0300 Subject: [PATCH] Reference all crypto declarations --- lib/std/crypto.zig | 25 +++++++++++++++++++++++-- lib/std/crypto/kdf.zig | 17 ----------------- 2 files changed, 23 insertions(+), 19 deletions(-) delete mode 100644 lib/std/crypto/kdf.zig diff --git a/lib/std/crypto.zig b/lib/std/crypto.zig index 64ec22894c..9df96dec7d 100644 --- a/lib/std/crypto.zig +++ b/lib/std/crypto.zig @@ -35,7 +35,14 @@ pub const onetimeauth = struct { pub const Poly1305 = @import("crypto/poly1305.zig").Poly1305; }; -pub const kdf = @import("crypto/kdf.zig"); +/// A Key Derivation Function (KDF) is intended to turn a weak, human generated password into a +/// strong key, suitable for cryptographic uses. It does this by salting and stretching the +/// password. Salting injects non-secret random data, so that identical passwords will be converted +/// into unique keys. Stretching applies a deliberately slow hashing function to frustrate +/// brute-force guessing. +pub const kdf = struct { + pub const pbkdf2 = @import("crypto/pbkdf2.zig").pbkdf2; +}; /// Core functions, that should rarely be used directly by applications. pub const core = struct { @@ -72,6 +79,20 @@ const std = @import("std.zig"); pub const randomBytes = std.os.getrandom; test "crypto" { + inline for (std.meta.declarations(std)) |decl| { + switch (decl.data) { + .Type => |t| { + std.meta.refAllDecls(t); + }, + .Var => |v| { + _ = v; + }, + .Fn => |f| { + _ = f; + }, + } + } + _ = @import("crypto/aes.zig"); _ = @import("crypto/blake2.zig"); _ = @import("crypto/blake3.zig"); @@ -79,7 +100,7 @@ test "crypto" { _ = @import("crypto/gimli.zig"); _ = @import("crypto/hmac.zig"); _ = @import("crypto/md5.zig"); - _ = @import("crypto/kdf.zig"); + _ = @import("crypto/pbkdf2.zig"); _ = @import("crypto/poly1305.zig"); _ = @import("crypto/sha1.zig"); _ = @import("crypto/sha2.zig"); diff --git a/lib/std/crypto/kdf.zig b/lib/std/crypto/kdf.zig deleted file mode 100644 index 06bf67bbbd..0000000000 --- a/lib/std/crypto/kdf.zig +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. - -//! A Key Derivation Function (KDF) is intended to turn a weak, human generated password into a -//! strong key, suitable for cryptographic uses. It does this by salting and stretching the -//! password. Salting injects non-secret random data, so that identical passwords will be converted -//! into unique keys. Stretching applies a deliberately slow hashing function to frustrate -//! brute-force guessing. - -pub const pbkdf2 = @import("pbkdf2.zig").pbkdf2; - -test "kdf" { - _ = @import("pbkdf2.zig"); -}