forked from anchore/quill
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With the abstraction work done in the previous commit, adding support for entitlements is now fairly straightforward, just need to build the entitlements blob and hashes using user-provided XML data. This fixes anchore#4 Signed-off-by: Christophe Fergeau <[email protected]>
- Loading branch information
Showing
5 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package sign | ||
|
||
import ( | ||
"fmt" | ||
"hash" | ||
|
||
"github.com/go-restruct/restruct" | ||
|
||
"github.com/anchore/quill/quill/macho" | ||
) | ||
|
||
func generateEntitlements(h hash.Hash, entitlementsXML string) (*SpecialSlot, error) { | ||
if entitlementsXML == "" { | ||
return nil, nil | ||
} | ||
entitlementsBytes := []byte(entitlementsXML) | ||
blob := macho.NewBlob(macho.MagicEmbeddedEntitlements, entitlementsBytes) | ||
blobBytes, err := restruct.Pack(macho.SigningOrder, &blob) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to encode entitlements blob: %w", err) | ||
} | ||
|
||
// the requirements hash is against the entire blob, not just the payload | ||
h.Write(blobBytes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &SpecialSlot{macho.CsSlotEntitlements, &blob, h.Sum(nil)}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters