Skip to content

Instantly share code, notes, and snippets.

@powersj
Created March 29, 2023 19:20
Show Gist options
  • Save powersj/174b06d88c70b4dcdfd2265f311d744b to your computer and use it in GitHub Desktop.
Save powersj/174b06d88c70b4dcdfd2265f311d744b to your computer and use it in GitHub Desktop.
memguard loop
package main
import (
"fmt"
"sync"
"github.com/awnumar/memguard"
)
func loadSecret(wg *sync.WaitGroup, enclave *memguard.Enclave) {
lockbuf, err := enclave.Open()
if err != nil {
panic(err)
}
lockbuf.Bytes()
lockbuf.Destroy()
wg.Done()
}
func main() {
var wg sync.WaitGroup
counter := 1
enclave := memguard.NewEnclave([]byte("password"))
for {
fmt.Printf("loading %d times\n", counter)
for i := 0; i < counter; i++ {
wg.Add(1)
go loadSecret(&wg, enclave)
}
wg.Wait()
counter = counter + 1
}
}
@powersj
Copy link
Author

powersj commented Mar 29, 2023

Run with:

ulimit -Hl 64; ulimit -l 64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment