Documentation
¶
Overview ¶
subtleパッケージは、暗号化コードでよく使用される関数を実装しますが、正しく使用するために注意深い考慮が必要です。
Index ¶
- func ConstantTimeByteEq(x, y uint8) int
- func ConstantTimeCompare(x, y []byte) int
- func ConstantTimeCopy(v int, x, y []byte)
- func ConstantTimeEq(x, y int32) int
- func ConstantTimeLessOrEq(x, y int) int
- func ConstantTimeSelect(v, x, y int) int
- func WithDataIndependentTiming(f func())
- func XORBytes(dst, x, y []byte) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstantTimeByteEq ¶
ConstantTimeByteEq は、x が y と等しい場合は1を、そうでない場合は0を返します。
func ConstantTimeCompare ¶
ConstantTimeCompareは、2つのスライスxとyが同じ内容を持つ場合は1を返し、そうでない場合は0を返します。実行時間はスライスの長さに依存し、内容には独立しています。xとyの長さが一致しない場合は、即座に0を返します。
func ConstantTimeCopy ¶
ConstantTimeCopyは、v == 1の場合、yの内容(長さが等しいスライス)をxにコピーします。 v == 0の場合、xは変更されません。vが他の値を取る場合の動作は未定義です。
func ConstantTimeEq ¶
ConstantTimeEqは、x == yの場合は1を返し、それ以外の場合は0を返します。
func ConstantTimeLessOrEq ¶ added in v1.2.0
ConstantTimeLessOrEq は、x ≤ y の場合は1を返し、そうでない場合は0を返します。 ただし、xまたはyが負数または2**31 - 1より大きい場合、動作は未定義です。
func ConstantTimeSelect ¶
ConstantTimeSelectは、vが1の場合はxを返し、vが0の場合はyを返します。 vが他の値を取る場合、動作は未定義です。
func WithDataIndependentTiming ¶ added in v1.25.0
func WithDataIndependentTiming(f func())
WithDataIndependentTiming enables architecture specific features which ensure that the timing of specific instructions is independent of their inputs before executing f. On f returning it disables these features.
WithDataIndependentTiming should only be used when f is written to make use of constant-time operations. WithDataIndependentTiming does not make variable-time code constant-time.
WithDataIndependentTiming may lock the current goroutine to the OS thread for the duration of f. Calls to WithDataIndependentTiming may be nested.
On Arm64 processors with FEAT_DIT, WithDataIndependentTiming enables PSTATE.DIT. See https://developer.arm.com/documentation/ka005181/1-0/?lang=en.
Currently, on all other architectures WithDataIndependentTiming executes f immediately with no other side-effects.
Types ¶
This section is empty.