authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2020-09-29 21:33:14+02:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2020-09-30 01:39:55+02:00
logd75d6e7f774c6236eb11a5a6b0277561a3b42a22
tree9889155795448a61d683fdaf72c2c2aadb36424b
parent6eaba61ef57c54231eccfdda42ed0c4de2985f27

Remove unused var, sort std.crypto.*


2 files changed, 45 insertions(+), 47 deletions(-)

lib/std/crypto.zig+45-45
...@@ -4,6 +4,48 @@...@@ -4,6 +4,48 @@
4// The MIT license requires this copyright notice to be included in all copies4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.5// and substantial portions of the software.
66
7/// Authenticated Encryption with Associated Data
8pub const aead = struct {
9 const chacha20 = @import("crypto/chacha20.zig");
10
11 pub const Gimli = @import("crypto/gimli.zig").Aead;
12 pub const ChaCha20Poly1305 = chacha20.Chacha20Poly1305;
13 pub const XChaCha20Poly1305 = chacha20.XChacha20Poly1305;
14 pub const AEGIS128L = @import("crypto/aegis.zig").AEGIS128L;
15 pub const AEGIS256 = @import("crypto/aegis.zig").AEGIS256;
16};
17
18/// Authentication (MAC) functions.
19pub const auth = struct {
20 pub const hmac = @import("crypto/hmac.zig");
21 pub const siphash = @import("crypto/siphash.zig");
22};
23
24/// Core functions, that should rarely be used directly by applications.
25pub const core = struct {
26 pub const aes = @import("crypto/aes.zig");
27 pub const Gimli = @import("crypto/gimli.zig").State;
28
29 /// Modes are generic compositions to construct encryption/decryption functions from block ciphers and permutations.
30 ///
31 /// These modes are designed to be building blocks for higher-level constructions, and should generally not be used directly by applications, as they may not provide the expected properties and security guarantees.
32 ///
33 /// Most applications may want to use AEADs instead.
34 pub const modes = @import("crypto/modes.zig");
35};
36
37/// Diffie-Hellman key exchange functions.
38pub const dh = struct {
39 pub const X25519 = @import("crypto/25519/x25519.zig").X25519;
40};
41
42/// Elliptic-curve arithmetic.
43pub const ecc = struct {
44 pub const Curve25519 = @import("crypto/25519/curve25519.zig").Curve25519;
45 pub const Edwards25519 = @import("crypto/25519/edwards25519.zig").Edwards25519;
46 pub const Ristretto255 = @import("crypto/25519/ristretto255.zig").Ristretto255;
47};
48
7/// Hash functions.49/// Hash functions.
8pub const hash = struct {50pub const hash = struct {
9 pub const Md5 = @import("crypto/md5.zig").Md5;51 pub const Md5 = @import("crypto/md5.zig").Md5;
...@@ -15,21 +57,9 @@ pub const hash = struct {...@@ -15,21 +57,9 @@ pub const hash = struct {
15 pub const Gimli = @import("crypto/gimli.zig").Hash;57 pub const Gimli = @import("crypto/gimli.zig").Hash;
16};58};
1759
18/// Authentication (MAC) functions.60/// Key derivation functions.
19pub const auth = struct {61pub const kdf = struct {
20 pub const hmac = @import("crypto/hmac.zig");62 pub const hkdf = @import("crypto/hkdf.zig");
21 pub const siphash = @import("crypto/siphash.zig");
22};
23
24/// Authenticated Encryption with Associated Data
25pub const aead = struct {
26 const chacha20 = @import("crypto/chacha20.zig");
27
28 pub const Gimli = @import("crypto/gimli.zig").Aead;
29 pub const ChaCha20Poly1305 = chacha20.Chacha20Poly1305;
30 pub const XChaCha20Poly1305 = chacha20.XChacha20Poly1305;
31 pub const AEGIS128L = @import("crypto/aegis.zig").AEGIS128L;
32 pub const AEGIS256 = @import("crypto/aegis.zig").AEGIS256;
33};63};
3464
35/// MAC functions requiring single-use secret keys.65/// MAC functions requiring single-use secret keys.
...@@ -57,31 +87,6 @@ pub const pwhash = struct {...@@ -57,31 +87,6 @@ pub const pwhash = struct {
57 pub const pbkdf2 = @import("crypto/pbkdf2.zig").pbkdf2;87 pub const pbkdf2 = @import("crypto/pbkdf2.zig").pbkdf2;
58};88};
5989
60/// Core functions, that should rarely be used directly by applications.
61pub const core = struct {
62 pub const aes = @import("crypto/aes.zig");
63 pub const Gimli = @import("crypto/gimli.zig").State;
64
65 /// Modes are generic compositions to construct encryption/decryption functions from block ciphers and permutations.
66 ///
67 /// These modes are designed to be building blocks for higher-level constructions, and should generally not be used directly by applications, as they may not provide the expected properties and security guarantees.
68 ///
69 /// Most applications may want to use AEADs instead.
70 pub const modes = @import("crypto/modes.zig");
71};
72
73/// Elliptic-curve arithmetic.
74pub const ecc = struct {
75 pub const Curve25519 = @import("crypto/25519/curve25519.zig").Curve25519;
76 pub const Edwards25519 = @import("crypto/25519/edwards25519.zig").Edwards25519;
77 pub const Ristretto255 = @import("crypto/25519/ristretto255.zig").Ristretto255;
78};
79
80/// Diffie-Hellman key exchange functions.
81pub const dh = struct {
82 pub const X25519 = @import("crypto/25519/x25519.zig").X25519;
83};
84
85/// Digital signature functions.90/// Digital signature functions.
86pub const sign = struct {91pub const sign = struct {
87 pub const Ed25519 = @import("crypto/25519/ed25519.zig").Ed25519;92 pub const Ed25519 = @import("crypto/25519/ed25519.zig").Ed25519;
...@@ -95,11 +100,6 @@ pub const stream = struct {...@@ -95,11 +100,6 @@ pub const stream = struct {
95 pub const ChaCha20With64BitNonce = @import("crypto/chacha20.zig").ChaCha20With64BitNonce;100 pub const ChaCha20With64BitNonce = @import("crypto/chacha20.zig").ChaCha20With64BitNonce;
96};101};
97102
98/// Key derivation functions.
99pub const kdf = struct {
100 pub const hkdf = @import("crypto/hkdf.zig");
101};
102
103const std = @import("std.zig");103const std = @import("std.zig");
104pub const randomBytes = std.os.getrandom;104pub const randomBytes = std.os.getrandom;
105105
lib/std/crypto/hkdf.zig-2
...@@ -13,8 +13,6 @@ pub const HkdfSha512 = Hkdf(hmac.sha2.HmacSha512);...@@ -13,8 +13,6 @@ pub const HkdfSha512 = Hkdf(hmac.sha2.HmacSha512);
13/// derives one or more uniform keys from it.13/// derives one or more uniform keys from it.
14pub fn Hkdf(comptime Hmac: type) type {14pub fn Hkdf(comptime Hmac: type) type {
15 return struct {15 return struct {
16 pub const prk_length = Hmac.mac_length;
17
18 /// Return a master key from a salt and initial keying material.16 /// Return a master key from a salt and initial keying material.
19 fn extract(salt: []const u8, ikm: []const u8) [Hmac.mac_length]u8 {17 fn extract(salt: []const u8, ikm: []const u8) [Hmac.mac_length]u8 {
20 var prk: [Hmac.mac_length]u8 = undefined;18 var prk: [Hmac.mac_length]u8 = undefined;