| ... | @@ -185,31 +185,27 @@ pub const errors = @import("crypto/errors.zig"); | ... | @@ -185,31 +185,27 @@ pub const errors = @import("crypto/errors.zig"); |
| 185 | pub const tls = @import("crypto/tls.zig"); | 185 | pub const tls = @import("crypto/tls.zig"); |
| 186 | pub const Certificate = @import("crypto/Certificate.zig"); | 186 | pub const Certificate = @import("crypto/Certificate.zig"); |
| 187 | | 187 | |
| 188 | /// Global configuration of cryptographic implementations in the standard library. | 188 | /// Side-channels mitigations. |
| 189 | pub const config = struct { | 189 | pub const SideChannelsMitigations = enum { |
| 190 | /// Side-channels mitigations. | 190 | /// No additional side-channel mitigations are applied. |
| 191 | pub const SideChannelsMitigations = enum { | 191 | /// This is the fastest mode. |
| 192 | /// No additional side-channel mitigations are applied. | 192 | none, |
| 193 | /// This is the fastest mode. | 193 | /// The `basic` mode protects against most practical attacks, provided that the |
| 194 | none, | 194 | /// application or implements proper defenses against brute-force attacks. |
| 195 | /// The `basic` mode protects against most practical attacks, provided that the | 195 | /// It offers a good balance between performance and security. |
| 196 | /// application or implements proper defenses against brute-force attacks. | 196 | basic, |
| 197 | /// It offers a good balance between performance and security. | 197 | /// The `medium` mode offers increased resilience against side-channel attacks, |
| 198 | basic, | 198 | /// making most attacks unpractical even on shared/low latency environements. |
| 199 | /// The `medium` mode offers increased resilience against side-channel attacks, | 199 | /// This is the default mode. |
| 200 | /// making most attacks unpractical even on shared/low latency environements. | 200 | medium, |
| 201 | /// This is the default mode. | 201 | /// The `full` mode offers the highest level of protection against side-channel attacks. |
| 202 | medium, | 202 | /// Note that this doesn't cover all possible attacks (especially power analysis or |
| 203 | /// The `full` mode offers the highest level of protection against side-channel attacks. | 203 | /// thread-local attacks such as cachebleed), and that the performance impact is significant. |
| 204 | /// Note that this doesn't cover all possible attacks (especially power analysis or | 204 | full, |
| 205 | /// thread-local attacks such as cachebleed), and that the performance impact is significant. | | |
| 206 | full, | | |
| 207 | }; | | |
| 208 | | | |
| 209 | /// This is a global configuration that applies to all cryptographic implementations. | | |
| 210 | pub const side_channels_mitigations: SideChannelsMitigations = if (@hasDecl(root, "side_channels_mitigations")) root.side_channels_mitigations else .medium; | | |
| 211 | }; | 205 | }; |
| 212 | | 206 | |
| | 207 | pub const default_side_channels_mitigations = .medium; |
| | 208 | |
| 213 | test { | 209 | test { |
| 214 | _ = aead.aegis.Aegis128L; | 210 | _ = aead.aegis.Aegis128L; |
| 215 | _ = aead.aegis.Aegis256; | 211 | _ = aead.aegis.Aegis256; |