mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-04 22:20:53 +01:00
1d8f9c6b16
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.7.0 to 0.8.0. - [Release notes](https://github.com/golang/crypto/releases) - [Commits](https://github.com/golang/crypto/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
60 lines
2.1 KiB
Go
60 lines
2.1 KiB
Go
// Copyright 2019 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 curve25519 provides an implementation of the X25519 function, which
|
|
// performs scalar multiplication on the elliptic curve known as Curve25519.
|
|
// See RFC 7748.
|
|
//
|
|
// Starting in Go 1.20, this package is a wrapper for the X25519 implementation
|
|
// in the crypto/ecdh package.
|
|
package curve25519 // import "golang.org/x/crypto/curve25519"
|
|
|
|
// ScalarMult sets dst to the product scalar * point.
|
|
//
|
|
// Deprecated: when provided a low-order point, ScalarMult will set dst to all
|
|
// zeroes, irrespective of the scalar. Instead, use the X25519 function, which
|
|
// will return an error.
|
|
func ScalarMult(dst, scalar, point *[32]byte) {
|
|
scalarMult(dst, scalar, point)
|
|
}
|
|
|
|
// ScalarBaseMult sets dst to the product scalar * base where base is the
|
|
// standard generator.
|
|
//
|
|
// It is recommended to use the X25519 function with Basepoint instead, as
|
|
// copying into fixed size arrays can lead to unexpected bugs.
|
|
func ScalarBaseMult(dst, scalar *[32]byte) {
|
|
scalarBaseMult(dst, scalar)
|
|
}
|
|
|
|
const (
|
|
// ScalarSize is the size of the scalar input to X25519.
|
|
ScalarSize = 32
|
|
// PointSize is the size of the point input to X25519.
|
|
PointSize = 32
|
|
)
|
|
|
|
// Basepoint is the canonical Curve25519 generator.
|
|
var Basepoint []byte
|
|
|
|
var basePoint = [32]byte{9}
|
|
|
|
func init() { Basepoint = basePoint[:] }
|
|
|
|
// X25519 returns the result of the scalar multiplication (scalar * point),
|
|
// according to RFC 7748, Section 5. scalar, point and the return value are
|
|
// slices of 32 bytes.
|
|
//
|
|
// scalar can be generated at random, for example with crypto/rand. point should
|
|
// be either Basepoint or the output of another X25519 call.
|
|
//
|
|
// If point is Basepoint (but not if it's a different slice with the same
|
|
// contents) a precomputed implementation might be used for performance.
|
|
func X25519(scalar, point []byte) ([]byte, error) {
|
|
// Outline the body of function, to let the allocation be inlined in the
|
|
// caller, and possibly avoid escaping to the heap.
|
|
var dst [32]byte
|
|
return x25519(&dst, scalar, point)
|
|
}
|