MCPcopy
hub / github.com/smallstep/cli / deriveMachineID

Function deriveMachineID

command/ssh/certificate.go:559–581  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

557}
558
559func deriveMachineID() (uuid.UUID, error) {
560 // use /etc/machine-id
561 machineID, err := os.ReadFile("/etc/machine-id")
562 if err != nil {
563 return uuid.Nil, err
564 }
565
566 // 16 bytes, not secret
567 key := []byte("man moon machine")
568 mac, err := blake2b.New(16, key)
569 if err != nil {
570 return uuid.Nil, err
571 }
572 mac.Write(machineID)
573 machineHash := mac.Sum(nil)
574 var u uuid.UUID
575 copy(u[:], machineHash)
576 // Make it a v4 uuid (taken from uuid.NewRandom):
577 u[6] = (u[6] & 0x0f) | 0x40 // Version 4
578 u[8] = (u[8] & 0x3f) | 0x80 // Variant is 10
579
580 return u, nil
581}
582
583func readExistingUUID() (uuid.UUID, error) {
584 id, err := identity.LoadDefaultIdentity()

Callers 1

certificateActionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…