aboutsummaryrefslogtreecommitdiff
path: root/lib/std/crypto.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-09-22 11:41:21 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-09-22 11:41:21 -0700
commite2d1f9874df2a9221aaa9ec55bd2974b70601f64 (patch)
treeeff7919b0717e193aa53b70fcee862d6f33deddb /lib/std/crypto.zig
parent52b8239a22aa37fe3914427cd4e2905231769e59 (diff)
parent58ee5f4e61cd9b7a9ba65798e2214efa3753a733 (diff)
downloadzig-e2d1f9874df2a9221aaa9ec55bd2974b70601f64.tar.gz
zig-e2d1f9874df2a9221aaa9ec55bd2974b70601f64.zip
Merge remote-tracking branch 'origin/master' into llvm11
Diffstat (limited to 'lib/std/crypto.zig')
-rw-r--r--lib/std/crypto.zig24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/std/crypto.zig b/lib/std/crypto.zig
index 5de2f13896..3a1ae599a0 100644
--- a/lib/std/crypto.zig
+++ b/lib/std/crypto.zig
@@ -35,6 +35,15 @@ pub const onetimeauth = struct {
pub const Poly1305 = @import("crypto/poly1305.zig").Poly1305;
};
+/// 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 {
pub const aes = @import("crypto/aes.zig");
@@ -70,6 +79,20 @@ const std = @import("std.zig");
pub const randomBytes = std.os.getrandom;
test "crypto" {
+ inline for (std.meta.declarations(@This())) |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");
@@ -77,6 +100,7 @@ test "crypto" {
_ = @import("crypto/gimli.zig");
_ = @import("crypto/hmac.zig");
_ = @import("crypto/md5.zig");
+ _ = @import("crypto/pbkdf2.zig");
_ = @import("crypto/poly1305.zig");
_ = @import("crypto/sha1.zig");
_ = @import("crypto/sha2.zig");