Documentation ¶
Overview ¶
Copyright 2018 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package subtle implements functions that are often useful in cryptographic code but require careful thought to use correctly.
Index ¶
- func AnyOverlap(x, y []byte) bool
- func ConstantTimeBigEndianLessOrEq(x, y []byte) int
- func ConstantTimeBigEndianZero(x []byte) int
- func ConstantTimeByteEq(x, y uint8) int
- func ConstantTimeByteGreater(x, y uint8) int
- func ConstantTimeByteLessOrEq(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 InexactOverlap(x, y []byte) bool
- func SliceForAppend(in []byte, n int) (head, tail []byte)
- func Wipe(x []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyOverlap ¶
AnyOverlap reports whether x and y share memory at any (not necessarily corresponding) index. The memory beyond the slice length is ignored.
func ConstantTimeBigEndianLessOrEq ¶
ConstantTimeBigEndianLessOrEq compares x and y, which must have the same length, as big-endian integers in constant time.
It returns 1 if x <= y and 0 otherwise.
func ConstantTimeBigEndianZero ¶
ConstantTimeBigEndianZero reports, in constant time, whether the big-endian integer x is zero.
It returns 1 if x <= y and 0 otherwise.
func ConstantTimeByteEq ¶
ConstantTimeByteEq returns 1 if x == y and 0 otherwise.
func ConstantTimeByteGreater ¶
ConstantTimeByteGreater returns 1 if x > y and 0 otherwise.
func ConstantTimeByteLessOrEq ¶
ConstantTimeByteLessOrEq returns 1 if x <= y and 0 otherwise.
func ConstantTimeCompare ¶
ConstantTimeCompare returns 1 if the two slices, x and y, have equal contents and 0 otherwise.
The time taken is a function of the length of the slices and is independent of the contents.
func ConstantTimeCopy ¶
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 v takes any other value.
func ConstantTimeEq ¶
ConstantTimeEq returns 1 if x == y and 0 otherwise.
func ConstantTimeLessOrEq ¶
ConstantTimeLessOrEq returns 1 if x <= y and 0 otherwise. Its behavior is undefined if x or y are negative or > 2**31 - 1.
func ConstantTimeSelect ¶
ConstantTimeSelect returns x if v == 1 and y if v == 0. Its behavior is undefined if v takes any other value.
func InexactOverlap ¶
InexactOverlap reports whether x and y share memory at any non-corresponding index. The memory beyond the slice length is ignored. Note that x and y can have different lengths and still not have any inexact overlap.
InexactOverlap can be used to implement the requirements of the crypto/cipher AEAD, Block, BlockMode and Stream interfaces.
func SliceForAppend ¶
SliceForAppend takes a slice and a requested number of bytes. It returns a slice with the contents of the given slice followed by that many bytes and a second slice that aliases into it and contains only the extra bytes. If the original slice has sufficient capacity then no allocation is performed.
Types ¶
This section is empty.