Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with Go v1.22.1, liboqs v0.10.0 #36

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/client_server_kem/client/client_kem.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func main() {
log.Fatal(err)
} else if n != client.Details().LengthCiphertext {
log.Fatal(errors.New("client expected to read " +
string(client.Details().LengthCiphertext) + " bytes, but instead " +
"read " + string(n)))
fmt.Sprintf("%v", client.Details().LengthCiphertext) + " bytes, but instead " +
"read " + fmt.Sprintf("%v", n)))
}

// decapsulate the secret and extract the shared secret
Expand Down
8 changes: 4 additions & 4 deletions examples/client_server_kem/server/server_kem.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func handleConnection(conn net.Conn, kemName string) {
log.Fatal(err)
} else if n != server.Details().LengthPublicKey {
log.Fatal(errors.New("server expected to read " +
string(server.Details().LengthPublicKey) + " bytes, but instead " +
"read " + string(n)))
fmt.Sprintf("%v", server.Details().LengthPublicKey) + " bytes, but instead " +
"read " + fmt.Sprintf("%v", n)))
}

// encapsulate the secret
Expand All @@ -112,8 +112,8 @@ func handleConnection(conn net.Conn, kemName string) {
if err != nil {
log.Fatal(err)
} else if n != server.Details().LengthCiphertext {
log.Fatal(errors.New("server expected to write " + string(server.
Details().LengthCiphertext) + " bytes, but instead wrote " + string(n)))
log.Fatal(errors.New("server expected to write " + fmt.Sprintf("%v", server.
Details().LengthCiphertext) + " bytes, but instead wrote " + fmt.Sprintf("%v", n)))
}

log.Printf("\nConnection #%d - server shared secret:\n% X ... % X\n\n",
Expand Down
16 changes: 2 additions & 14 deletions examples/rand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package main

import (
"fmt"
"github.com/open-quantum-safe/liboqs-go/oqs"
"log"
"runtime"

"github.com/open-quantum-safe/liboqs-go/oqs"

oqsrand "github.com/open-quantum-safe/liboqs-go/oqs/rand" // RNG support
)

Expand All @@ -22,19 +23,6 @@ func CustomRNG(randomArray []byte, bytesToRead int) {
func main() {
fmt.Println("liboqs version: " + oqs.LiboqsVersion())

if err := oqsrand.RandomBytesSwitchAlgorithm("NIST-KAT"); err != nil {
log.Fatal(err)
}
// set the entropy seed to some values
var entropySeed [48]byte
for i := 0; i < 48; i++ {
entropySeed[i] = byte(i)
}
if err := oqsrand.RandomBytesNistKatInit256bit(entropySeed, nil); err != nil {
log.Fatal(err)
}
fmt.Printf("%-18s% X\n", "NIST-KAT: ", oqsrand.RandomBytes(32))

if err := oqsrand.RandomBytesCustomAlgorithm(CustomRNG); err != nil {
log.Fatal(err)
}
Expand Down
24 changes: 0 additions & 24 deletions oqs/rand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,6 @@ func RandomBytesSwitchAlgorithm(algName string) error {
return nil
}

// RandomBytesNistKatInit256bit initializes the NIST DRBG with the entropyInput
// seed, which must be 48 exactly bytes long. The personalizationString is an
// optional personalization string, which, if non-empty, must be at least 48
// bytes long. The security parameter is 256 bits.
func RandomBytesNistKatInit256bit(entropyInput [48]byte,
personalizationString []byte) error {
lenStr := len(personalizationString)
if lenStr > 0 {
if lenStr < 48 {
return errors.New("the personalization string must be either " +
"empty or at least 48 bytes long")
}

C.OQS_randombytes_nist_kat_init_256bit(
(*C.uint8_t)(unsafe.Pointer(&entropyInput[0])),
(*C.uint8_t)(unsafe.Pointer(&personalizationString[0])))
return nil
}
C.OQS_randombytes_nist_kat_init_256bit(
(*C.uint8_t)(unsafe.Pointer(&entropyInput[0])),
(*C.uint8_t)(unsafe.Pointer(nil)))
return nil
}

// RandomBytesCustomAlgorithm switches RandomBytes to use the given function.
// This allows additional custom RNGs besides the provided ones. The provided
// RNG function must have the same signature as RandomBytesInPlace,
Expand Down
Loading