| ... | @@ -4,6 +4,48 @@ | ... | @@ -4,6 +4,48 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // 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. |
| 6 | | 6 | |
| | 7 | /// Authenticated Encryption with Associated Data |
| | 8 | pub 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. |
| | 19 | pub 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. |
| | 25 | pub 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. |
| | 38 | pub const dh = struct { |
| | 39 | pub const X25519 = @import("crypto/25519/x25519.zig").X25519; |
| | 40 | }; |
| | 41 | |
| | 42 | /// Elliptic-curve arithmetic. |
| | 43 | pub 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. |
| 8 | pub const hash = struct { | 50 | pub 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 | }; |
| 17 | | 59 | |
| 18 | /// Authentication (MAC) functions. | 60 | /// Key derivation functions. |
| 19 | pub const auth = struct { | 61 | pub 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 | | |
| 25 | pub 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 | }; |
| 34 | | 64 | |
| 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 | }; |
| 59 | | 89 | |
| 60 | /// Core functions, that should rarely be used directly by applications. | | |
| 61 | pub 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. | | |
| 74 | pub 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. | | |
| 81 | pub const dh = struct { | | |
| 82 | pub const X25519 = @import("crypto/25519/x25519.zig").X25519; | | |
| 83 | }; | | |
| 84 | | | |
| 85 | /// Digital signature functions. | 90 | /// Digital signature functions. |
| 86 | pub const sign = struct { | 91 | pub 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 | }; |
| 97 | | 102 | |
| 98 | /// Key derivation functions. | | |
| 99 | pub const kdf = struct { | | |
| 100 | pub const hkdf = @import("crypto/hkdf.zig"); | | |
| 101 | }; | | |
| 102 | | | |
| 103 | const std = @import("std.zig"); | 103 | const std = @import("std.zig"); |
| 104 | pub const randomBytes = std.os.getrandom; | 104 | pub const randomBytes = std.os.getrandom; |
| 105 | | 105 | |