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 @@
44// The MIT license requires this copyright notice to be included in all copies
55// 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
749/// Hash functions.
850pub const hash = struct {
951 pub const Md5 = @import("crypto/md5.zig").Md5;
......@@ -15,21 +57,9 @@ pub const hash = struct {
1557 pub const Gimli = @import("crypto/gimli.zig").Hash;
1658};
1759
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/// 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;
60/// Key derivation functions.
61pub const kdf = struct {
62 pub const hkdf = @import("crypto/hkdf.zig");
3363};
3464
3565/// MAC functions requiring single-use secret keys.
......@@ -57,31 +87,6 @@ pub const pwhash = struct {
5787 pub const pbkdf2 = @import("crypto/pbkdf2.zig").pbkdf2;
5888};
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
8590/// Digital signature functions.
8691pub const sign = struct {
8792 pub const Ed25519 = @import("crypto/25519/ed25519.zig").Ed25519;
......@@ -95,11 +100,6 @@ pub const stream = struct {
95100 pub const ChaCha20With64BitNonce = @import("crypto/chacha20.zig").ChaCha20With64BitNonce;
96101};
97102
98/// Key derivation functions.
99pub const kdf = struct {
100 pub const hkdf = @import("crypto/hkdf.zig");
101};
102
103103const std = @import("std.zig");
104104pub const randomBytes = std.os.getrandom;
105105
lib/std/crypto/hkdf.zig-2
......@@ -13,8 +13,6 @@ pub const HkdfSha512 = Hkdf(hmac.sha2.HmacSha512);
1313/// derives one or more uniform keys from it.
1414pub fn Hkdf(comptime Hmac: type) type {
1515 return struct {
16 pub const prk_length = Hmac.mac_length;
17
1816 /// Return a master key from a salt and initial keying material.
1917 fn extract(salt: []const u8, ikm: []const u8) [Hmac.mac_length]u8 {
2018 var prk: [Hmac.mac_length]u8 = undefined;