?
This document uses PHP Chinese website manual Release
import "crypto/subtle"
概述
索引
Subtle 包實(shí)現(xiàn)了在密碼學(xué)中經(jīng)常使用的功能,但需要仔細(xì)考慮才能正確使用。
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
constant_time.go
func ConstantTimeByteEq(x, y uint8) int
如果 x == y 則 ConstantTimeByteEq 返回1,否則返回0。
func ConstantTimeCompare(x, y []byte) int
當(dāng)且僅當(dāng)兩個切片 x和y 具有相等的內(nèi)容時,ConstantTimeCompare 返回1。所花費(fèi)的時間是切片長度的函數(shù),并且與內(nèi)容無關(guān)。
func ConstantTimeCopy(v int, x, y []byte)
如果v == 1,ConstantTimeCopy 將y的內(nèi)容復(fù)制到x(一個等長的片段)中。如果v == 0,x保持不變。如果v取任何其他值,它的行為是不確定的。
func ConstantTimeEq(x, y int32) int
如果x == y,則ConstantTimeEq 返回1,否則返回0。
func ConstantTimeLessOrEq(x, y int) int
如果x <= y,則ConstantTimeLessOrEq 返回1,否則返回0。如果x或y為負(fù)值或> 2**31 - 1,則其行為不確定。
func ConstantTimeSelect(v, x, y int) int
如果v為1,則ConstantTimeSelect 返回x;如果v為0,則返回y。如果v采用任何其他值,則其行為是不確定的。