Skip to content

crypto: use subtle.WithDataIndependentTiming for all constant-time APIs #49702

@FiloSottile

Description

@FiloSottile

Someone pointed me to this terrifying piece of arm64 documentation.

https://developer.arm.com/documentation/ddi0595/2021-06/AArch64-Registers/DIT--Data-Independent-Timing

It's a flag that ensures that "the timing of every load and store instruction is insensitive to the value of the data being loaded or stored" and "for certain data processing instructions, the instruction takes a time which is independent of: the values of the data supplied in any of its registers".

The nightmare fuel implication is that with this flag unset, instructions like MUL and LOAD might take different time based on the value they operate on. Due to the potential for timing attacks, this is not acceptable in any cryptographic code.

We should probably put a call-and-defer at each public crypto entry point that on arm64 detects the feature and set/unsets the flag. Setting it for the whole program might have an unacceptable performance cost, even if marginal.

I'll think about requesting a freeze exception, depending on the implementation details.

Metadata

Metadata

Assignees

Labels

NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Securityarch-arm64

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions