| ... | @@ -23,22 +23,6 @@ partially_read_buffer: [tls.max_ciphertext_record_len]u8, | ... | @@ -23,22 +23,6 @@ partially_read_buffer: [tls.max_ciphertext_record_len]u8, |
| 23 | partially_read_len: u15, | 23 | partially_read_len: u15, |
| 24 | eof: bool, | 24 | eof: bool, |
| 25 | | 25 | |
| 26 | // Measurement taken with 0.11.0-dev.810+c2f5848fe | | |
| 27 | // on x86_64-linux Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz: | | |
| 28 | // zig run .lib/std/crypto/benchmark.zig -OReleaseFast | | |
| 29 | // aegis-128l: 15382 MiB/s | | |
| 30 | // aegis-256: 9553 MiB/s | | |
| 31 | // aes128-gcm: 3721 MiB/s | | |
| 32 | // aes256-gcm: 3010 MiB/s | | |
| 33 | // chacha20Poly1305: 597 MiB/s | | |
| 34 | | | |
| 35 | const cipher_suites = | | |
| 36 | int2(@enumToInt(tls.CipherSuite.AEGIS_128L_SHA256)) ++ | | |
| 37 | int2(@enumToInt(tls.CipherSuite.AEGIS_256_SHA384)) ++ | | |
| 38 | int2(@enumToInt(tls.CipherSuite.AES_128_GCM_SHA256)) ++ | | |
| 39 | int2(@enumToInt(tls.CipherSuite.AES_256_GCM_SHA384)) ++ | | |
| 40 | int2(@enumToInt(tls.CipherSuite.CHACHA20_POLY1305_SHA256)); | | |
| 41 | | | |
| 42 | /// `host` is only borrowed during this function call. | 26 | /// `host` is only borrowed during this function call. |
| 43 | pub fn init(stream: net.Stream, host: []const u8) !Client { | 27 | pub fn init(stream: net.Stream, host: []const u8) !Client { |
| 44 | const kp = crypto.dh.X25519.KeyPair.create(null) catch |err| switch (err) { | 28 | const kp = crypto.dh.X25519.KeyPair.create(null) catch |err| switch (err) { |
| ... | @@ -713,3 +697,31 @@ inline fn int2(x: u16) [2]u8 { | ... | @@ -713,3 +697,31 @@ inline fn int2(x: u16) [2]u8 { |
| 713 | @truncate(u8, x), | 697 | @truncate(u8, x), |
| 714 | }; | 698 | }; |
| 715 | } | 699 | } |
| | 700 | |
| | 701 | /// The priority order here is chosen based on what crypto algorithms Zig has |
| | 702 | /// available in the standard library as well as what is faster. Following are |
| | 703 | /// a few data points on the relative performance of these algorithms. |
| | 704 | /// |
| | 705 | /// Measurement taken with 0.11.0-dev.810+c2f5848fe |
| | 706 | /// on x86_64-linux Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz: |
| | 707 | /// zig run .lib/std/crypto/benchmark.zig -OReleaseFast |
| | 708 | /// aegis-128l: 15382 MiB/s |
| | 709 | /// aegis-256: 9553 MiB/s |
| | 710 | /// aes128-gcm: 3721 MiB/s |
| | 711 | /// aes256-gcm: 3010 MiB/s |
| | 712 | /// chacha20Poly1305: 597 MiB/s |
| | 713 | /// |
| | 714 | /// Measurement taken with 0.11.0-dev.810+c2f5848fe |
| | 715 | /// on x86_64-linux Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz: |
| | 716 | /// zig run .lib/std/crypto/benchmark.zig -OReleaseFast -mcpu=baseline |
| | 717 | /// aegis-128l: 629 MiB/s |
| | 718 | /// chacha20Poly1305: 529 MiB/s |
| | 719 | /// aegis-256: 461 MiB/s |
| | 720 | /// aes128-gcm: 138 MiB/s |
| | 721 | /// aes256-gcm: 120 MiB/s |
| | 722 | const cipher_suites = |
| | 723 | int2(@enumToInt(tls.CipherSuite.AEGIS_128L_SHA256)) ++ |
| | 724 | int2(@enumToInt(tls.CipherSuite.AEGIS_256_SHA384)) ++ |
| | 725 | int2(@enumToInt(tls.CipherSuite.AES_128_GCM_SHA256)) ++ |
| | 726 | int2(@enumToInt(tls.CipherSuite.AES_256_GCM_SHA384)) ++ |
| | 727 | int2(@enumToInt(tls.CipherSuite.CHACHA20_POLY1305_SHA256)); |