Reference all crypto declarations

This commit is contained in:
Rocknest 2020-09-13 23:00:33 +03:00
parent b6385870d0
commit d75cbb01db
2 changed files with 23 additions and 19 deletions

View File

@ -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");

View File

@ -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");
}