-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add entitlements support (#314)
* extract: Add support for entitlements This can be tested with https://github.com/crc-org/vfkit/releases/download/v0.5.1/vfkit The "entitlements" and "entitlementsDER" fields are theoritically 2 distinct slots/.., but handling them together in `describe` should not make a big differenc. Signed-off-by: Christophe Fergeau <[email protected]> * sign: Add SpecialSlot data structure Special slots (requirements, entitlements, ...) are handled in 2 places: in GenerateSigningSuperBlob and in newCodeDirectory. This handling mostly hardcodes that there's a macho.CsSlotRequirements slot, and nothing else. For examples, to add handling for a new slot type, newCodeDirectory needs changes in at least 3 non-obvious places (`hashOff` computation, writing of the hashes, and NSpecialSlots). This code abstracts special slots handling by: - adding a new SpecialSlot struct to describe a special slot - the rest of the code no longer needs to know it's dealing with CsSlotRequirements or a CsSlotEntitlements (which I want to add support for) - it adds a SpecialSlotHashWriter type for use in newCodeDirectory to count the number of special slots, compute the `hashOff` value accordingly, write the slots in the correct order, ... This will be useful in the commits which add support for entitlements. Signed-off-by: Christophe Fergeau <[email protected]> * sign: Add support for entitlements 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 #4 Signed-off-by: Christophe Fergeau <[email protected]> --------- Signed-off-by: Christophe Fergeau <[email protected]>
- Loading branch information
Showing
24 changed files
with
235 additions
and
54 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
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
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
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 |
---|---|---|
@@ -1,10 +1,23 @@ | ||
package extract | ||
|
||
type EntitlementDetails struct { | ||
Blob BlobDetails `json:"blob"` | ||
Blob BlobDetails `json:"blob"` | ||
Entitlements string `json:"entitlements,omitempty"` | ||
EntitlementsDER []byte `json:"entitlements_der,omitempty"` | ||
} | ||
|
||
func getEntitlements(_ File) []EntitlementDetails { | ||
// TODO | ||
return nil | ||
func getEntitlements(m File) *EntitlementDetails { | ||
entitlements := m.blacktopFile.CodeSignature().Entitlements | ||
entitlementsDER := m.blacktopFile.CodeSignature().EntitlementsDER | ||
if entitlements == "" && entitlementsDER == nil { | ||
return nil | ||
} | ||
return &EntitlementDetails{ | ||
Entitlements: entitlements, | ||
EntitlementsDER: entitlementsDER, | ||
} | ||
} | ||
|
||
func (e EntitlementDetails) String() string { | ||
return e.Entitlements | ||
} |
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
Oops, something went wrong.