Movatterモバイル変換


[0]ホーム

URL:


subtle

packagestandard library
go1.25.5Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:3Imported by:23,649

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package subtle implements functions that are often useful in cryptographiccode but require careful thought to use correctly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcConstantTimeByteEq

func ConstantTimeByteEq(x, yuint8)int

ConstantTimeByteEq returns 1 if x == y and 0 otherwise.

funcConstantTimeCompare

func ConstantTimeCompare(x, y []byte)int

ConstantTimeCompare returns 1 if the two slices, x and y, have equal contentsand 0 otherwise. The time taken is a function of the length of the slices andis independent of the contents. If the lengths of x and y do not match itreturns 0 immediately.

funcConstantTimeCopy

func ConstantTimeCopy(vint, x, y []byte)

ConstantTimeCopy copies the contents of y into x (a slice of equal length)if v == 1. If v == 0, x is left unchanged. Its behavior is undefined if vtakes any other value.

funcConstantTimeEq

func ConstantTimeEq(x, yint32)int

ConstantTimeEq returns 1 if x == y and 0 otherwise.

funcConstantTimeLessOrEqadded ingo1.2

func ConstantTimeLessOrEq(x, yint)int

ConstantTimeLessOrEq returns 1 if x <= y and 0 otherwise.Its behavior is undefined if x or y are negative or > 2**31 - 1.

funcConstantTimeSelect

func ConstantTimeSelect(v, x, yint)int

ConstantTimeSelect returns x if v == 1 and y if v == 0.Its behavior is undefined if v takes any other value.

funcWithDataIndependentTimingadded ingo1.24.0

func WithDataIndependentTiming(f func())

WithDataIndependentTiming enables architecture specific features which ensurethat the timing of specific instructions is independent of their inputsbefore executing f. On f returning it disables these features.

WithDataIndependentTiming should only be used when f is written to make useof constant-time operations. WithDataIndependentTiming does not makevariable-time code constant-time.

WithDataIndependentTiming may lock the current goroutine to the OS thread forthe duration of f. Calls to WithDataIndependentTiming may be nested.

On Arm64 processors with FEAT_DIT, WithDataIndependentTiming enablesPSTATE.DIT. Seehttps://developer.arm.com/documentation/ka005181/1-0/?lang=en.

Currently, on all other architectures WithDataIndependentTiming executes f immediatelywith no other side-effects.

funcXORBytesadded ingo1.20

func XORBytes(dst, x, y []byte)int

XORBytes sets dst[i] = x[i] ^ y[i] for all i < n = min(len(x), len(y)),returning n, the number of bytes written to dst.

If dst does not have length at least n,XORBytes panics without writing anything to dst.

dst and x or y may overlap exactly or not at all,otherwise XORBytes may panic.

Types

This section is empty.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp