Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertBytesToPrivate(sigName string, privy []byte) (*signaturealgorithm.PrivateKey, error)
- func ConvertBytesToPublic(sigName string, pub []byte) (*signaturealgorithm.PublicKey, error)
- func DecapSecret(seckey, ciphertext []byte) ([]byte, error)
- func EnabledKEMs() []string
- func EncapSecret(publicKey []byte) (ciphertext, sharedSecret []byte, err error)
- func ExportPrivateKey(sigName string, privy *signaturealgorithm.PrivateKey) ([]byte, error)
- func ExportPublicKey(sigName string, pub *signaturealgorithm.PublicKey) ([]byte, error)
- func GenerateKemKeyPair() (*keyestablishmentalgorithm.PrivateKey, error)
- func GenerateKey(sigName string) (*signaturealgorithm.PrivateKey, error)
- func InitOqs()
- func IsKEMEnabled(algName string) bool
- func IsKEMSupported(algName string) bool
- func IsSigEnabled(algName string) bool
- func KEMName(algID int) (string, error)
- func MaxNumberKEMs() int
- func MemCleanse(v []byte)
- func Sign(sigName string, msg []byte, seckey []byte) ([]byte, error)
- func SignWithKey(sigName string, digestHash []byte, prv *signaturealgorithm.PrivateKey) (sig []byte, err error)
- func SupportedKEMs() []string
- func VerifySignature(sigName string, pubkey, msg, signature []byte) bool
- type Falcon
- type KeyEncapsulation
- func (kem *KeyEncapsulation) Clean()
- func (kem *KeyEncapsulation) DecapsulateSecret(ciphertext []byte) ([]byte, error)
- func (kem *KeyEncapsulation) Details() KeyEncapsulationDetails
- func (kem *KeyEncapsulation) EncapsulateSecret(publicKey []byte) (ciphertext, sharedSecret []byte, err error)
- func (kem *KeyEncapsulation) GenerateKemKeyPair() (*keyestablishmentalgorithm.PrivateKey, error)
- func (kem *KeyEncapsulation) Init(algName string, secretKey []byte) error
- type KeyEncapsulationDetails
- type OqsSig
- func (s OqsSig) CombinePublicKeySignature(sigBytes []byte, pubKeyBytes []byte) (combinedSignature []byte, err error)
- func (s OqsSig) DecodePublicKey(encoded []byte) (*signaturealgorithm.PublicKey, error)
- func (s OqsSig) DeserializePrivateKey(priv []byte) (*signaturealgorithm.PrivateKey, error)
- func (s OqsSig) DeserializePublicKey(pub []byte) (*signaturealgorithm.PublicKey, error)
- func (s OqsSig) EncodePublicKey(pubKey *signaturealgorithm.PublicKey) []byte
- func (s OqsSig) GenerateKey() (*signaturealgorithm.PrivateKey, error)
- func (s OqsSig) HexToPrivateKey(hexkey string) (*signaturealgorithm.PrivateKey, error)
- func (s OqsSig) HexToPrivateKeyNoError(hexkey string) *signaturealgorithm.PrivateKey
- func (s OqsSig) HexToPublicKey(hexkey string) (*signaturealgorithm.PublicKey, error)
- func (s OqsSig) LoadPrivateKeyFromFile(file string) (*signaturealgorithm.PrivateKey, error)
- func (s OqsSig) PrivateKeyLength() int
- func (s OqsSig) PrivateKeyToHex(priv *signaturealgorithm.PrivateKey) (string, error)
- func (s OqsSig) PublicKeyAndSignatureFromCombinedSignature(digestHash []byte, sig []byte) (signature []byte, pubKey []byte, err error)
- func (s OqsSig) PublicKeyBytesFromSignature(digestHash []byte, sig []byte) ([]byte, error)
- func (s OqsSig) PublicKeyFromSignature(digestHash []byte, sig []byte) (*signaturealgorithm.PublicKey, error)
- func (s OqsSig) PublicKeyLength() int
- func (s OqsSig) PublicKeyStartValue() byte
- func (s OqsSig) PublicKeyToAddress(p *signaturealgorithm.PublicKey) (common.Address, error)
- func (s OqsSig) PublicKeyToAddressNoError(p *signaturealgorithm.PublicKey) common.Address
- func (s OqsSig) PublicKeyToHex(pub *signaturealgorithm.PublicKey) (string, error)
- func (s OqsSig) SavePrivateKeyToFile(file string, key *signaturealgorithm.PrivateKey) error
- func (s OqsSig) SerializePrivateKey(priv *signaturealgorithm.PrivateKey) ([]byte, error)
- func (s OqsSig) SerializePublicKey(pub *signaturealgorithm.PublicKey) ([]byte, error)
- func (s OqsSig) Sign(digestHash []byte, prv *signaturealgorithm.PrivateKey) (sig []byte, err error)
- func (s OqsSig) SignatureLength() int
- func (s OqsSig) SignatureName() string
- func (s OqsSig) SignatureStartValue() byte
- func (s OqsSig) SignatureWithPublicKeyLength() int
- func (osig OqsSig) ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool
- func (s OqsSig) Verify(pubKey []byte, digestHash []byte, signature []byte) bool
- func (s OqsSig) Zeroize(prv *signaturealgorithm.PrivateKey)
- type Signature
- type SignatureDetails
Constants ¶
const KemName = "Kyber512" //sntrup761
Variables ¶
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") )
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 EnabledKEMs ¶
func EnabledKEMs() []string
EnabledKEMs returns the list of enabled KEM algorithms.
func EncapSecret ¶
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 IsKEMEnabled ¶
IsKEMEnabled returns true if a KEM algorithm is enabled, and false otherwise.
func IsKEMSupported ¶
IsKEMSupported returns true if a KEM algorithm is supported, and false otherwise.
func IsSigEnabled ¶
IsSigEnabled returns true if a signature algorithm is enabled, and false otherwise.
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 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 ¶
Types ¶
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 ¶
func (kem *KeyEncapsulation) Details() KeyEncapsulationDetails
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)
type KeyEncapsulationDetails ¶
type KeyEncapsulationDetails struct { ClaimedNISTLevel int IsINDCCA bool LengthCiphertext int LengthPublicKey int LengthSecretKey int Name string Version string }
KeyEncapsulationDetails defines the KEM algorithm details.
type OqsSig ¶
type OqsSig struct {
// contains filtered or unexported fields
}
func (OqsSig) CombinePublicKeySignature ¶
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 (OqsSig) PrivateKeyToHex ¶
func (s OqsSig) PrivateKeyToHex(priv *signaturealgorithm.PrivateKey) (string, error)
func (OqsSig) PublicKeyAndSignatureFromCombinedSignature ¶
func (OqsSig) PublicKeyBytesFromSignature ¶
func (OqsSig) PublicKeyFromSignature ¶
func (OqsSig) PublicKeyLength ¶
func (OqsSig) PublicKeyStartValue ¶
func (OqsSig) PublicKeyToAddress ¶
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 (OqsSig) SignatureName ¶
func (OqsSig) SignatureStartValue ¶
func (OqsSig) SignatureWithPublicKeyLength ¶
func (OqsSig) ValidateSignatureValues ¶
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) 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.
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)