Erase Go privkey bytes from libmutton

This commit is contained in:
2026-02-07 23:54:19 -05:00
parent 39703114e8
commit 489d757112
3 changed files with 8 additions and 16 deletions
+2 -2
View File
@@ -3,8 +3,7 @@ module cmutton
go 1.26rc3
require (
github.com/rwinkhart/go-boilerplate v0.2.3-0.20260208035402-e1bb0012a781
github.com/rwinkhart/libmutton v0.4.3-0.20260208040332-7bfbc7ef309e
github.com/rwinkhart/libmutton v0.4.3-0.20260208045259-4602c295181e
github.com/rwinkhart/rcw v0.2.5
)
@@ -14,6 +13,7 @@ require (
github.com/kr/fs v0.1.0 // indirect
github.com/pkg/sftp v1.13.10 // indirect
github.com/pquerna/otp v1.5.0 // indirect
github.com/rwinkhart/go-boilerplate v0.2.3-0.20260208035402-e1bb0012a781 // indirect
github.com/rwinkhart/peercred-mini v0.1.2 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/sys v0.40.0 // indirect
+2 -2
View File
@@ -16,8 +16,8 @@ github.com/pquerna/otp v1.5.0 h1:NMMR+WrmaqXU4EzdGJEE1aUUI0AMRzsp96fFFWNPwxs=
github.com/pquerna/otp v1.5.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
github.com/rwinkhart/go-boilerplate v0.2.3-0.20260208035402-e1bb0012a781 h1:kMAM0fkWGPa8WK7A4a9rMX2oD2Lv198zJoD9LCUAzOA=
github.com/rwinkhart/go-boilerplate v0.2.3-0.20260208035402-e1bb0012a781/go.mod h1:QcUlr4SMgONRMKD965m8oTuCa6ZJVAc17w27Qopyr+s=
github.com/rwinkhart/libmutton v0.4.3-0.20260208040332-7bfbc7ef309e h1:Hl/LG+vc7RkU4tHVq+rMt15zg4t3utDZN6HY5RfPDPY=
github.com/rwinkhart/libmutton v0.4.3-0.20260208040332-7bfbc7ef309e/go.mod h1:G9EvjsHvTyOvUOs1VZ8aRKRpRRgzrrdZSCGheL/t72I=
github.com/rwinkhart/libmutton v0.4.3-0.20260208045259-4602c295181e h1:RFiKcMEXqHbgK4g4d1WOHMN+DmHeygIjKDHKH4Su55w=
github.com/rwinkhart/libmutton v0.4.3-0.20260208045259-4602c295181e/go.mod h1:G9EvjsHvTyOvUOs1VZ8aRKRpRRgzrrdZSCGheL/t72I=
github.com/rwinkhart/peercred-mini v0.1.2 h1:4cGWDbv0whvLeVvbUdx84V/9p+2fS+DEXgrA1KxlRFo=
github.com/rwinkhart/peercred-mini v0.1.2/go.mod h1:LLHG7YshHEpbpJJP+Il9nx2dnGj5O3VGE32rWmflj0c=
github.com/rwinkhart/rcw v0.2.5 h1:3GJeii9sDZsZNL+HRkfHrnbgxnaB8a9kejiMIfPXnpE=
+4 -12
View File
@@ -7,7 +7,6 @@ import "C"
import (
"unsafe"
"github.com/rwinkhart/go-boilerplate/back"
"github.com/rwinkhart/libmutton/privkey"
)
@@ -24,18 +23,11 @@ func SetPrivKeyDataAndEraseFreeInput(privKeyData C.PascalString) {
FreePascalString(privKeyData)
}
// EraseFreePrivKey is meant to be called on iOS after
// EraseGoPrivKey is meant to be called on iOS after
// any server connections to ensure the cached SSH private key
// set by SetPrivKeyDataAndEraseFreeInput is securely erased.
// It also erases and frees the input privKeyPascal.
//
//export EraseFreePrivKey
func EraseFreePrivKey(privKeyPascal C.PascalString) {
// erase Go/libmutton copy
privKeyBytes, _ := privkey.GetBytes(nil)
back.EraseBytesSecurely(privKeyBytes)
// erase C copy
securePtrOverwriteAndFree(unsafe.Pointer(privKeyPascal.data), C.size_t(privKeyPascal.len))
FreePascalString(privKeyPascal)
//export EraseGoPrivKey
func EraseGoPrivKey() {
privkey.Erase()
}