Skip to content

Commit

Permalink
feat: add support for NEW VRE/ComputeModule AEA dmgs
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Oct 25, 2024
1 parent 66ccbbb commit 3402770
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/ipsw/cmd/fw/aea.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var aeaCmd = &cobra.Command{
}

var bold = color.New(color.Bold).SprintFunc()
var info = color.New(color.FgHiGreen).SprintFunc()

if output == "" {
output = filepath.Dir(args[0])
Expand All @@ -120,7 +121,9 @@ var aeaCmd = &cobra.Command{
}
log.Info("AEA Info")
for k, v := range metadata {
if b64data, err := base64.StdEncoding.WithPadding(base64.StdPadding).DecodeString(string(v)); err == nil {
if k == "encryption_key" {
fmt.Printf("%s:\n%s\n\n", bold("["+k+"]"), info(string(v)))
} else if b64data, err := base64.StdEncoding.WithPadding(base64.StdPadding).DecodeString(string(v)); err == nil {
fmt.Printf("%s:\n%s\n", bold("["+k+"]"), utils.HexDump(b64data, 0))
} else {
if viper.GetBool("color") && !viper.GetBool("no-color") {
Expand Down
11 changes: 10 additions & 1 deletion pkg/aea/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,13 @@ func Decrypt(c *DecryptConfig) (string, error) {
return "", fmt.Errorf("failed to parse AEA: %v", err)
}

if c.B64SymKey == "" {
if encKey, ok := metadata["encryption_key"]; ok {
c.symEncKey, err = hex.DecodeString(string(encKey))
if err != nil {
return "", fmt.Errorf("failed to decode hex sym key: %v", err)
}
c.B64SymKey = base64.StdEncoding.EncodeToString(c.symEncKey)
} else if c.B64SymKey == "" {
c.symEncKey, err = metadata.DecryptFCS(c.PrivKeyData, c.PemDB)
if err != nil {
return "", fmt.Errorf("failed to HPKE decrypt fcs-key: %v", err)
Expand Down Expand Up @@ -489,6 +495,9 @@ func Decrypt(c *DecryptConfig) (string, error) {

func aea(in, out, key string) (string, error) {
if runtime.GOOS == "darwin" {
if err := os.MkdirAll(filepath.Dir(out), 0o750); err != nil {
return "", fmt.Errorf("failed to create output directory '%s': %v", filepath.Dir(out), err)
}
cmd := exec.Command(aeaBinPath, "decrypt", "-i", in, "-o", out, "-key-value", fmt.Sprintf("base64:%s", key))
cout, err := cmd.CombinedOutput()
if err != nil {
Expand Down

0 comments on commit 3402770

Please sign in to comment.