Documentation ¶
Overview ¶
Package goliboqs is a Go wrapper around the liboqs library (see https://github.com/open-quantum-safe/liboqs).
Usage ¶
Sample usage is shown below. Error handling omitted for brevity.
// Load the library (don't forget to close) lib, _ := goliboqs.LoadLib("/path/to/liboqs.so") defer lib.Close() // Get a particular KEM (don't forget to close) kem, _ := lib.GetKem(goliboqs.KemKyber1024) defer kem.Close() // Use the kem... publicKey, secretKey, _ := kem.KeyPair() sharedSecret, ciphertext, _ := kem.Encaps(publicKey) recoveredSecret, _ := kem.Decaps(ciphertext, secretKey) // sharedSecret == recoveredSecret
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kem ¶
type Kem interface { // KeyPair generates a new key pair. KeyPair() (publicKey, secretKey []byte, err error) // Encaps generates a new shared secret and encrypts it under the public key. Encaps(public []byte) (sharedSecret, ciphertext []byte, err error) // Decaps decrypts an encrypted shared secret. Decaps(ciphertext, secretKey []byte) (sharedSecret []byte, err error) // Close frees resources uses by this Kem. Close() error }
A Kem is an implementation of a key encapsulation mechanism (KEM) from liboqs. Use GetKem to load a Kem by name. Call Close on the Kem to avoid resource leaks.
type KemType ¶
type KemType string
A KemType identifies a KEM algorithm. Since these are just strings, you can call GetKem with anything you want. This may be useful if you are using a newer version of liboqs.
const ( KemBike1L1 KemType = "BIKE1-L1" KemBike1L3 KemType = "BIKE1-L3" KemBike1L5 KemType = "BIKE1-L5" KemBike2L1 KemType = "BIKE2-L1" KemBike2L3 KemType = "BIKE2-L3" KemBike2L5 KemType = "BIKE2-L5" KemBike3L1 KemType = "BIKE3-L1" KemBike3L3 KemType = "BIKE3-L3" KemBike3L5 KemType = "BIKE3-L5" KemFrodo640AES KemType = "FrodoKEM-640-AES" KemFrodo640Shake KemType = "FrodoKEM-640-SHAKE" KemFrodo976AES KemType = "FrodoKEM-976-AES" KemFrodo976Shake KemType = "FrodoKEM-976-SHAKE" KemFrodo1344AES KemType = "FrodoKEM-1344-AES" KemFrodo1344Shake KemType = "FrodoKEM-1344-SHAKE" KemNewHope512 KemType = "NewHope-512-CCA-KEM" KemNewHope1024 KemType = "NewHope-1024-CCA-KEM" KemKyber512 KemType = "Kyber-512-CCA-KEM" KemKyber768 KemType = "Kyber-768-CCA-KEM" KemKyber1024 KemType = "Kyber-1024-CCA-KEM" KemSidhP503 KemType = "Sidh-p503" KemSidhP751 KemType = "Sidh-p751" KemSikeP503 KemType = "Sike-p503" KemSikeP751 KemType = "Sike-p751" )
KEM types defined by liboqs (see kem.h)
type Lib ¶
type Lib struct {
// contains filtered or unexported fields
}
Lib stores state for the loaded liboqs library. Call Close to free resources after use.
func LoadLib ¶
LoadLib loads the liboqs library. The path parameter is given directly to dlopen, see the dlopen man page for details of how path is interpreted. (Paths with a slash are treated as absolute or relative paths). Be sure to Close after use to free resources.