]> Cypherpunks repositories - keks.git/commitdiff
Ability to get bind value conveniently
authorSergey Matveev <stargrave@stargrave.org>
Fri, 24 Jan 2025 13:33:17 +0000 (16:33 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 26 Jan 2025 14:04:19 +0000 (17:04 +0300)
go/pki/cmd/enctool/main.go
go/pki/cmd/enctool/usage.go

index 25a2b31c1c8836a862dff19cb3cf4894dd4219b6072b6382fb08a125c8ab4285..0d6d7dae4ddaad5b27f97506d34f4698c9fbc34fe29b3df2216c587ca052d048 100644 (file)
@@ -45,6 +45,8 @@ const (
        BalloonSaltLen          = 8
        BalloonHKDFSalt         = "keks/pki/encrypted/balloon-blake2b-hkdf"
        SNTRUP4591761X25519Salt = "keks/pki/encrypted/sntrup4591761-x25519-hkdf-blake2b"
+
+       BindFdNum = 3 + 1
 )
 
 type BalloonCost struct {
@@ -181,6 +183,10 @@ func main() {
                if encrypted.Bind == uuid.Nil {
                        log.Fatalln("unll bind")
                }
+               if bindFd := os.NewFile(BindFdNum, "bind"); bindFd != nil {
+                       bindFd.WriteString(encrypted.Bind.String() + "\n")
+                       bindFd.Close()
+               }
                if encrypted.DEM.A != pki.ChaCha20Poly1305 {
                        log.Fatalln("unsupported DEM:", encrypted.DEM.A)
                }
@@ -305,6 +311,10 @@ func main() {
                if err != nil {
                        log.Fatal(err)
                }
+               if bindFd := os.NewFile(BindFdNum, "bind"); bindFd != nil {
+                       bindFd.WriteString(binding.String() + "\n")
+                       bindFd.Close()
+               }
                var kems []KEM
                cek = make([]byte, chacha20poly1305.KeySize)
                _, err = io.ReadFull(rand.Reader, cek)
index 360254e8d76001ea46795fdd5869c9a67cd2323512f9f9751f7b3a6c3ee46b7b..520d89960d71856fc42d0b61623eb2f98373cf5945432f97c21773b7e655f101 100644 (file)
@@ -24,12 +24,12 @@ import (
 func usage() {
        fmt.Fprintf(os.Stderr, `Usage:
   Encrypt to recipient:
-    enctool -cer CER [-include-to] [-bind UUID] <DATA >DATA.encrypted
+    enctool -cer CER [-include-to] [-bind UUID] <DATA >DATA.encrypted [4>bind.value]
   Encrypt on passphrase:
-    enctool -p [-bind UUID] <DATA >DATA.encrypted
+    enctool -p [-bind UUID] <DATA >DATA.encrypted [4>bind.value]
       [-balloon-s X] [-balloon-t X] [-balloon-p X]
   Decrypt by providing possible KEMs:
-    enctool -d [-p] [-prv PRV ...] <DATA.encrypted >DATA
+    enctool -d [-p] [-prv PRV ...] <DATA.encrypted >DATA [4>bind.value]
 
 `)
        flag.PrintDefaults()