Implement machine fingerprint hashing (T-501)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package windows
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"softbox.local/core/licensing"
|
||||
)
|
||||
|
||||
// ErrMachineFingerprintUnavailable reports that a required identifier could
|
||||
// not be safely read or normalized. It intentionally contains no source value.
|
||||
var ErrMachineFingerprintUnavailable = errors.New("machine fingerprint is unavailable")
|
||||
|
||||
type machineGUIDReader func() (string, error)
|
||||
type systemVolumeSerialReader func() (uint32, error)
|
||||
|
||||
func machineHashFrom(readMachineGUID machineGUIDReader, readSystemVolumeSerial systemVolumeSerialReader) (string, error) {
|
||||
if readMachineGUID == nil || readSystemVolumeSerial == nil {
|
||||
return "", ErrMachineFingerprintUnavailable
|
||||
}
|
||||
machineGUID, err := readMachineGUID()
|
||||
if err != nil {
|
||||
return "", ErrMachineFingerprintUnavailable
|
||||
}
|
||||
systemVolumeSerial, err := readSystemVolumeSerial()
|
||||
if err != nil {
|
||||
return "", ErrMachineFingerprintUnavailable
|
||||
}
|
||||
machineHash, err := licensing.DeriveMachineHash(machineGUID, systemVolumeSerial)
|
||||
if err != nil {
|
||||
return "", ErrMachineFingerprintUnavailable
|
||||
}
|
||||
return machineHash, nil
|
||||
}
|
||||
Reference in New Issue
Block a user