mirror of
https://github.com/rwinkhart/cmutton.git
synced 2026-08-27 20:36:31 -04:00
Sync with latest libmutton development version
This commit is contained in:
-14
@@ -1,14 +0,0 @@
|
||||
//go:build ios || darwin
|
||||
|
||||
package main
|
||||
|
||||
// #include <string.h>
|
||||
// #include <stdlib.h>
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// securePtrOverwriteAndFree securely overwrites the memory at the input pointer and then frees it.
|
||||
func securePtrOverwriteAndFree(input unsafe.Pointer, length C.size_t) {
|
||||
C.memset_s(input, length, 0, length)
|
||||
C.free(input)
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
//go:build !ios && !darwin
|
||||
|
||||
package main
|
||||
|
||||
// #include <string.h>
|
||||
// #include <stdlib.h>
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// securePtrOverwriteAndFree securely overwrites the memory at the input pointer and then frees it.
|
||||
func securePtrOverwriteAndFree(input unsafe.Pointer, length C.size_t) {
|
||||
C.explicit_bzero(input, C.size_t(length))
|
||||
C.free(input)
|
||||
}
|
||||
@@ -3,7 +3,7 @@ module cmutton
|
||||
go 1.26rc3
|
||||
|
||||
require (
|
||||
github.com/rwinkhart/libmutton v0.4.3-0.20260208050303-cdb5bd562142
|
||||
github.com/rwinkhart/libmutton v0.4.3-0.20260208053501-420333e412c3
|
||||
github.com/rwinkhart/rcw v0.2.5
|
||||
)
|
||||
|
||||
|
||||
@@ -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.20260208050303-cdb5bd562142 h1:EmrGJnprEageU5YrPjfgq4wkwyfKEkgTp2IJtRkhjBE=
|
||||
github.com/rwinkhart/libmutton v0.4.3-0.20260208050303-cdb5bd562142/go.mod h1:G9EvjsHvTyOvUOs1VZ8aRKRpRRgzrrdZSCGheL/t72I=
|
||||
github.com/rwinkhart/libmutton v0.4.3-0.20260208053501-420333e412c3 h1:brL+4MpVFlwMsQkXB6ZAFd52wrz5ryUx8+/BfO+Ls4c=
|
||||
github.com/rwinkhart/libmutton v0.4.3-0.20260208053501-420333e412c3/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=
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
// #include <stdlib.h>
|
||||
// #include "types.h"
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/rwinkhart/libmutton/privkey"
|
||||
)
|
||||
|
||||
// SetPrivKeyBytes forces libmutton to use custom bytes for the SSH private key.
|
||||
//
|
||||
//export SetPrivKeyBytes
|
||||
func SetPrivKeyBytes(privKeyPascal C.PascalString) {
|
||||
privkey.SetBytes(C.GoBytes(unsafe.Pointer(privKeyPascal.data), privKeyPascal.len))
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
//go:build ios
|
||||
|
||||
package main
|
||||
|
||||
// #include <stdlib.h>
|
||||
// #include <string.h>
|
||||
// #include "types.h"
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/rwinkhart/libmutton/privkey"
|
||||
)
|
||||
|
||||
// SetPrivKeyDataAndEraseFreeInput is meant to be called on iOS
|
||||
// prior to any server connections to ensure libmutton can
|
||||
// retrieve the correct SSH private key contents (enables
|
||||
// loading from keychain).
|
||||
//
|
||||
//export SetPrivKeyDataAndEraseFreeInput
|
||||
func SetPrivKeyDataAndEraseFreeInput(privKeyData C.PascalString) {
|
||||
privKeyDataPtr := unsafe.Pointer(privKeyData.data)
|
||||
privkey.LocalBytes = C.GoBytes(privKeyDataPtr, privKeyData.len)
|
||||
securePtrOverwriteAndFree(privKeyDataPtr, C.size_t(privKeyData.len))
|
||||
FreePascalString(privKeyData)
|
||||
}
|
||||
Reference in New Issue
Block a user