openssl

package
v0.0.0-...-c0af43b Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright (C) 2018 NuCypher

This file is part of goUmbral.

goUmbral is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

goUmbral is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with goUmbral. If not, see <https://www.gnu.org/licenses/>.

This file is part of goUmbral.

goUmbral is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

goUmbral is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with goUmbral. If not, see <https://www.gnu.org/licenses/>.

This file is part of goUmbral.

goUmbral is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

goUmbral is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with goUmbral. If not, see <https://www.gnu.org/licenses/>.

This file is part of goUmbral.

goUmbral is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

goUmbral is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with goUmbral. If not, see <https://www.gnu.org/licenses/>.

This file wraps OpenSSL functions that are relevant to Umbral.

Most of these functions will return errors if they exist.

If there is an error then an OpenSSLError will be returned, otherwise the functions will return a nil error.

This file is part of goUmbral.

goUmbral is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

goUmbral is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with goUmbral. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	SECP256R1 = C.NID_X9_62_prime256v1
	SECP256K1 = C.NID_secp256k1
	SECP384R1 = C.NID_secp384r1
)

Supported curves

View Source
const ERR_R_FATAL = 64

Variables

This section is empty.

Functions

func AddBN

func AddBN(r, a, b BigNum) error

AddBN wraps BN_add.

func AddECP

func AddECP(group ECGroup, r, a, b ECPoint, ctx BNCtx) error

func BNIsWithinOrder

func BNIsWithinOrder(checkBN BigNum, curve *Curve) bool

func BNToBigInt

func BNToBigInt(bn BigNum) (*big.Int, error)

func BNToBytes

func BNToBytes(cBN BigNum) ([]byte, error)

func BNToDecStr

func BNToDecStr(cBN BigNum) string

func BytesToBigInt

func BytesToBigInt(bytes []byte) *big.Int

func CmpBN

func CmpBN(a, b BigNum) int

CmpBN wraps BN_cmp.

func CmpECP

func CmpECP(group ECGroup, a, b ECPoint, ctx BNCtx) (bool, error)

func DivBN

func DivBN(dv, rem, a, d BigNum, ctx BNCtx) error

DivBN wraps BN_div.

func FreeBNCtx

func FreeBNCtx(ctx BNCtx)

func FreeBNMontCtx

func FreeBNMontCtx(montCtx BNMontCtx)

func FreeBigNum

func FreeBigNum(bn BigNum)

func FreeECGroup

func FreeECGroup(group ECGroup)

func FreeECPoint

func FreeECPoint(point ECPoint)

func GetAffineCoordsFromECPoint

func GetAffineCoordsFromECPoint(point ECPoint, curve *Curve) (BigNum, BigNum, error)

func GetECGroupDegree

func GetECGroupDegree(group ECGroup) uint

func InvertECP

func InvertECP(group ECGroup, a ECPoint, ctx BNCtx) error

func ModAddBN

func ModAddBN(r, a, b, m BigNum, ctx BNCtx) error

ModAddBN wraps BN_mod_add.

func ModBN

func ModBN(rem, a, d BigNum, ctx BNCtx) error

MulBN wraps BN_mod.

func ModExpMontBN

func ModExpMontBN(r, a, b, m BigNum, ctx BNCtx) error

ModExpMontBN wraps BN_mod_exp_mont.

func ModInvertBN

func ModInvertBN(r, a, n BigNum, ctx BNCtx) error

ModInvertBN wraps BN_mod_inverse.

func ModModBN

func ModModBN(r, a, m BigNum, ctx BNCtx) error

ModModBN wraps BN_nnmod.

func ModMulBN

func ModMulBN(r, a, b, m BigNum, ctx BNCtx) error

ModMulBN wraps BN_mod_mul.

func ModNegBN

func ModNegBN(r, a, m BigNum, ctx BNCtx) error

ModNegBN negates 'a' and places the result in 'r'.

func ModSubBN

func ModSubBN(r, a, b, m BigNum, ctx BNCtx) error

ModSubBN wraps BN_mod_sub.

func MulBN

func MulBN(r, a, b BigNum, ctx BNCtx) error

MulBN wraps BN_mul.

func MulECP

func MulECP(group ECGroup, r ECPoint, n BigNum, q ECPoint, m BigNum, ctx BNCtx) error

func RandRangeBN

func RandRangeBN(r, max BigNum) error

RandRangeBN wraps BN_rand_range and places a cryptographically strong pseudo-random number in 'r' in the range 0 <= 'r' < 'max'.

func SetCompressedCoordsECP

func SetCompressedCoordsECP(group ECGroup, p ECPoint, x BigNum, yBit int, ctx BNCtx) error

func SizeOfBN

func SizeOfBN(bn BigNum) int

SizeOfBN wraps BN_num_bytes.

func SubBN

func SubBN(r, a, b BigNum) error

SubBN wraps BN_sub.

Types

type BNCtx

type BNCtx *C.BN_CTX

func NewBNCtx

func NewBNCtx() BNCtx

type BNMontCtx

type BNMontCtx *C.BN_MONT_CTX

func NewBNMontCtx

func NewBNMontCtx() BNMontCtx

func TmpBNMontCTX

func TmpBNMontCTX(modulus BigNum) (BNMontCtx, error)

type BigNum

type BigNum *C.BIGNUM

func BigIntToBN

func BigIntToBN(bInt *big.Int) (BigNum, error)

func BytesToBN

func BytesToBN(bytes []byte) (BigNum, error)

func DupBN

func DupBN(from BigNum) (BigNum, error)

DupBN wraps BN_dup.

func GetECOrderByGroup

func GetECOrderByGroup(group ECGroup) (BigNum, error)

func IntToBN

func IntToBN(sInt int) (BigNum, error)

func NewBigNum

func NewBigNum() BigNum

type Curve

type Curve struct {
	NID       int
	Group     ECGroup
	Order     BigNum
	Generator ECPoint
}

func NewCurve

func NewCurve(nid C.int) (*Curve, error)

func (*Curve) Equals

func (m *Curve) Equals(other *Curve) bool

func (*Curve) FieldOrderSize

func (m *Curve) FieldOrderSize() uint

func (*Curve) Free

func (m *Curve) Free()

type ECGroup

type ECGroup *C.EC_GROUP

func GetECGroupByCurveNID

func GetECGroupByCurveNID(curveNid C.int) (ECGroup, error)

type ECPoint

type ECPoint *C.EC_POINT

func DupECP

func DupECP(src ECPoint, group ECGroup) (ECPoint, error)

func GetECGeneratorByGroup

func GetECGeneratorByGroup(group ECGroup) (ECPoint, error)

func GetECPointFromAffine

func GetECPointFromAffine(affineX, affineY BigNum, curve *Curve) (ECPoint, error)

func NewECPoint

func NewECPoint(curve *Curve) (ECPoint, error)

type OpenSSLError

type OpenSSLError struct {
	// contains filtered or unexported fields
}

func NewOpenSSLError

func NewOpenSSLError() *OpenSSLError

func (*OpenSSLError) Error

func (m *OpenSSLError) Error() string

Jump to

Keyboard shortcuts

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