subtle

package module
v0.0.0-...-890d697 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: BSD-3-Clause Imports: 3 Imported by: 6

README

subtle

Go Reference

Useful cryptographic operations.

Installation

go get github.com/ericlagergren/subtle@latest

Security

Disclosure

This project uses full disclosure. If you find a security bug in an implementation, please e-mail me or create a GitHub issue.

Disclaimer

You should only use cryptography libraries that have been reviewed by cryptographers or cryptography engineers. While I am a cryptography engineer, I'm not your cryptography engineer, and I have not had this project reviewed by any other cryptographers.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyOverlap

func AnyOverlap(x, y []byte) bool

AnyOverlap reports whether x and y share memory at any (not necessarily corresponding) index. The memory beyond the slice length is ignored.

func ConstantTimeBigEndianLessOrEq

func ConstantTimeBigEndianLessOrEq(x, y []byte) int

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

func ConstantTimeBigEndianZero(x []byte) int

ConstantTimeBigEndianZero reports, in constant time, whether the big-endian integer x is zero.

It returns 1 if x <= y and 0 otherwise.

func ConstantTimeByteEq

func ConstantTimeByteEq(x, y uint8) int

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

func ConstantTimeByteGreater

func ConstantTimeByteGreater(x, y uint8) int

ConstantTimeByteGreater returns 1 if x > y and 0 otherwise.

func ConstantTimeByteLessOrEq

func ConstantTimeByteLessOrEq(x, y uint8) int

ConstantTimeByteLessOrEq returns 1 if x <= y and 0 otherwise.

func ConstantTimeCompare

func ConstantTimeCompare(x, y []byte) int

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

func ConstantTimeCopy(v int, 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 v takes any other value.

func ConstantTimeEq

func ConstantTimeEq(x, y int32) int

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

func ConstantTimeLessOrEq

func ConstantTimeLessOrEq(x, y int) int

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

func ConstantTimeSelect(v, x, y int) int

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

func InexactOverlap

func InexactOverlap(x, y []byte) bool

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

func SliceForAppend(in []byte, n int) (head, tail []byte)

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.

func Wipe

func Wipe(x []byte)

Wipe sets every byte in x to zero.

Types

This section is empty.

Directories

Path Synopsis
Package hex implements constant-time hexadecimal encoding and decoding.
Package hex implements constant-time hexadecimal encoding and decoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL