oqs

package
v0.0.0-...-37ff43f Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const KemName = "Kyber512" //sntrup761

Variables

View Source
var (
	ErrKemInitial              = errors.New("kem is not supported by OQS")
	ErrInvalidKemCiphertextLen = errors.New("invalid ciphertext length")
	ErrKemKeypairFailed        = errors.New("can not generate keypair")
	ErrEncapsulate             = errors.New("can not encapsulate secret")
	ErrDecapsulate             = errors.New("can not decapsulate secret")
	ErrInvalidKemPrivateKeyLen = errors.New("incorrect secret key length, make sure you " +
		"specify one in Init() or run GenerateKemKeyPair()")
	ErrInvalidKemPublicKeyLen = errors.New("invalid public key length")
)
View Source
var (
	ErrSignatureInitial       = errors.New("signature mechanism is not supported by OQS")
	ErrInvalidMsgLen          = errors.New("invalid message length, need 32 bytes")
	ErrInvalidSignatureLen    = errors.New("invalid signature length")
	ErrInvalidPublicKeyLen    = errors.New("invalid public key length")
	ErrInvalidPrivateKeyLen   = errors.New("invalid private key length")
	ErrInvalidRecoveryID      = errors.New("invalid signature recovery id")
	ErrInvalidKey             = errors.New("invalid private key")
	ErrInvalidPubkey          = errors.New("invalid public key")
	ErrMismatchPublicKey      = errors.New("mismatch public key")
	ErrSignFailed             = errors.New("signing failed")
	ErrRecoverFailed          = errors.New("recovery failed")
	ErrKeypairFailed          = errors.New("can not generate keypair")
	ErrInvalidLen             = errors.New("invalid length")
	ErrVerifyFailed           = errors.New("verify length")
	ErrRecoverPublicKeyFailed = errors.New("recover public key length")
)

Functions

func ConvertBytesToPrivate

func ConvertBytesToPrivate(sigName string, privy []byte) (*signaturealgorithm.PrivateKey, error)

ConvertBytesToPrivate exports the corresponding secret key from the sig receiver.

func ConvertBytesToPublic

func ConvertBytesToPublic(sigName string, pub []byte) (*signaturealgorithm.PublicKey, error)

ConvertBytesToPublic exports the corresponding secret key from the sig receiver.

func DecapSecret

func DecapSecret(seckey, ciphertext []byte) ([]byte, error)

func EnabledKEMs

func EnabledKEMs() []string

EnabledKEMs returns the list of enabled KEM algorithms.

func EncapSecret

func EncapSecret(publicKey []byte) (ciphertext, sharedSecret []byte, err error)

func ExportPrivateKey

func ExportPrivateKey(sigName string, privy *signaturealgorithm.PrivateKey) ([]byte, error)

ExportPrivateKey exports the corresponding secret key from the sig receiver.

func ExportPublicKey

func ExportPublicKey(sigName string, pub *signaturealgorithm.PublicKey) ([]byte, error)

ExportPublicKey exports the corresponding secret key from the sig receiver.

func GenerateKemKeyPair

func GenerateKemKeyPair() (*keyestablishmentalgorithm.PrivateKey, error)

func GenerateKey

func GenerateKey(sigName string) (*signaturealgorithm.PrivateKey, error)

GenerateKey exports the corresponding secret key from the sig receiver.

func InitOqs

func InitOqs()

Initializes liboqs and the lists enabledKEMs and supportedKEMs.

func IsKEMEnabled

func IsKEMEnabled(algName string) bool

IsKEMEnabled returns true if a KEM algorithm is enabled, and false otherwise.

func IsKEMSupported

func IsKEMSupported(algName string) bool

IsKEMSupported returns true if a KEM algorithm is supported, and false otherwise.

func IsSigEnabled

func IsSigEnabled(algName string) bool

IsSigEnabled returns true if a signature algorithm is enabled, and false otherwise.

func KEMName

func KEMName(algID int) (string, error)

KEMName returns the KEM algorithm name from its corresponding numerical ID.

func MaxNumberKEMs

func MaxNumberKEMs() int

MaxNumberKEMs returns the maximum number of supported KEM algorithms.

func MemCleanse

func MemCleanse(v []byte)

MemCleanse sets to zero the content of a byte slice by invoking the liboqs OQS_MEM_cleanse() function. Use it to clean "hot" memory areas, such as secret keys etc.

func Sign

func Sign(sigName string, msg []byte, seckey []byte) ([]byte, error)

func SignWithKey

func SignWithKey(sigName string, digestHash []byte, prv *signaturealgorithm.PrivateKey) (sig []byte, err error)

func SupportedKEMs

func SupportedKEMs() []string

SupportedKEMs returns the list of supported KEM algorithms.

func VerifySignature

func VerifySignature(sigName string, pubkey, msg, signature []byte) bool

Types

type Falcon

type Falcon struct {
	OqsSig
}

func InitFalcon

func InitFalcon() Falcon

type KeyEncapsulation

type KeyEncapsulation struct {
	AlgDetails KeyEncapsulationDetails
	// contains filtered or unexported fields
}

KeyEncapsulation defines the KEM main data structure.

func (*KeyEncapsulation) Clean

func (kem *KeyEncapsulation) Clean()

func (*KeyEncapsulation) DecapsulateSecret

func (kem *KeyEncapsulation) DecapsulateSecret(ciphertext []byte) ([]byte, error)

decapSecret decapsulates a ciphertexts and returns the corresponding shared secret.

func (*KeyEncapsulation) Details

Details returns the KEM algorithm details.

func (*KeyEncapsulation) EncapsulateSecret

func (kem *KeyEncapsulation) EncapsulateSecret(publicKey []byte) (ciphertext,
	sharedSecret []byte, err error)

encapSecret encapsulates a secret using a public key and returns the corresponding ciphertext and shared secret.

func (*KeyEncapsulation) GenerateKemKeyPair

func (kem *KeyEncapsulation) GenerateKemKeyPair() (*keyestablishmentalgorithm.PrivateKey, error)

func (*KeyEncapsulation) Init

func (kem *KeyEncapsulation) Init(algName string, secretKey []byte) error

type KeyEncapsulationDetails

type KeyEncapsulationDetails struct {
	ClaimedNISTLevel   int
	IsINDCCA           bool
	LengthCiphertext   int
	LengthPublicKey    int
	LengthSecretKey    int
	LengthSharedSecret int
	Name               string
	Version            string
}

KeyEncapsulationDetails defines the KEM algorithm details.

type OqsSig

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

func CreateOqs

func CreateOqs(sigName string) OqsSig

func (OqsSig) CombinePublicKeySignature

func (s OqsSig) CombinePublicKeySignature(sigBytes []byte, pubKeyBytes []byte) (combinedSignature []byte, err error)

func (OqsSig) DecodePublicKey

func (s OqsSig) DecodePublicKey(encoded []byte) (*signaturealgorithm.PublicKey, error)

func (OqsSig) DeserializePrivateKey

func (s OqsSig) DeserializePrivateKey(priv []byte) (*signaturealgorithm.PrivateKey, error)

func (OqsSig) DeserializePublicKey

func (s OqsSig) DeserializePublicKey(pub []byte) (*signaturealgorithm.PublicKey, error)

func (OqsSig) EncodePublicKey

func (s OqsSig) EncodePublicKey(pubKey *signaturealgorithm.PublicKey) []byte

func (OqsSig) GenerateKey

func (s OqsSig) GenerateKey() (*signaturealgorithm.PrivateKey, error)

func (OqsSig) HexToPrivateKey

func (s OqsSig) HexToPrivateKey(hexkey string) (*signaturealgorithm.PrivateKey, error)

func (OqsSig) HexToPrivateKeyNoError

func (s OqsSig) HexToPrivateKeyNoError(hexkey string) *signaturealgorithm.PrivateKey

func (OqsSig) HexToPublicKey

func (s OqsSig) HexToPublicKey(hexkey string) (*signaturealgorithm.PublicKey, error)

func (OqsSig) LoadPrivateKeyFromFile

func (s OqsSig) LoadPrivateKeyFromFile(file string) (*signaturealgorithm.PrivateKey, error)

func (OqsSig) PrivateKeyLength

func (s OqsSig) PrivateKeyLength() int

func (OqsSig) PrivateKeyToHex

func (s OqsSig) PrivateKeyToHex(priv *signaturealgorithm.PrivateKey) (string, error)

func (OqsSig) PublicKeyAndSignatureFromCombinedSignature

func (s OqsSig) PublicKeyAndSignatureFromCombinedSignature(digestHash []byte, sig []byte) (signature []byte, pubKey []byte, err error)

func (OqsSig) PublicKeyBytesFromSignature

func (s OqsSig) PublicKeyBytesFromSignature(digestHash []byte, sig []byte) ([]byte, error)

func (OqsSig) PublicKeyFromSignature

func (s OqsSig) PublicKeyFromSignature(digestHash []byte, sig []byte) (*signaturealgorithm.PublicKey, error)

func (OqsSig) PublicKeyLength

func (s OqsSig) PublicKeyLength() int

func (OqsSig) PublicKeyStartValue

func (s OqsSig) PublicKeyStartValue() byte

func (OqsSig) PublicKeyToAddress

func (s OqsSig) PublicKeyToAddress(p *signaturealgorithm.PublicKey) (common.Address, error)

func (OqsSig) PublicKeyToAddressNoError

func (s OqsSig) PublicKeyToAddressNoError(p *signaturealgorithm.PublicKey) common.Address

func (OqsSig) PublicKeyToHex

func (s OqsSig) PublicKeyToHex(pub *signaturealgorithm.PublicKey) (string, error)

func (OqsSig) SavePrivateKeyToFile

func (s OqsSig) SavePrivateKeyToFile(file string, key *signaturealgorithm.PrivateKey) error

func (OqsSig) SerializePrivateKey

func (s OqsSig) SerializePrivateKey(priv *signaturealgorithm.PrivateKey) ([]byte, error)

func (OqsSig) SerializePublicKey

func (s OqsSig) SerializePublicKey(pub *signaturealgorithm.PublicKey) ([]byte, error)

func (OqsSig) Sign

func (s OqsSig) Sign(digestHash []byte, prv *signaturealgorithm.PrivateKey) (sig []byte, err error)

func (OqsSig) SignatureLength

func (s OqsSig) SignatureLength() int

func (OqsSig) SignatureName

func (s OqsSig) SignatureName() string

func (OqsSig) SignatureStartValue

func (s OqsSig) SignatureStartValue() byte

func (OqsSig) SignatureWithPublicKeyLength

func (s OqsSig) SignatureWithPublicKeyLength() int

func (OqsSig) ValidateSignatureValues

func (osig OqsSig) ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool

ValidateSignatureValues verifies whether the signature values are valid with the given chain rules. The v value is assumed to be either 0 or 1.

func (OqsSig) Verify

func (s OqsSig) Verify(pubKey []byte, digestHash []byte, signature []byte) bool

func (OqsSig) Zeroize

func (s OqsSig) Zeroize(prv *signaturealgorithm.PrivateKey)

type Signature

type Signature struct {
	AlgDetails SignatureDetails
	// contains filtered or unexported fields
}

Signature defines the signature main data structure.

func (*Signature) Clean

func (sig *Signature) Clean()

Clean zeroes-in the stored secret key and resets the sig receiver. One can reuse the signature by re-initializing it with the Signature.Init method.

func (*Signature) Details

func (sig *Signature) Details() SignatureDetails

Details returns the signature algorithm details.

func (*Signature) Init

func (sig *Signature) Init(algName string, secretKey []byte) error

type SignatureDetails

type SignatureDetails struct {
	ClaimedNISTLevel   int
	IsEUFCMA           bool
	LengthPublicKey    int
	LengthSecretKey    int
	MaxLengthSignature int
	Name               string
	Version            string
	// contains filtered or unexported fields
}

SignatureDetails defines the signature algorithm details.

func GetSignatureDetails

func GetSignatureDetails(sigName string) (SignatureDetails, error)

Jump to

Keyboard shortcuts

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