Skip to content

Commit

Permalink
Update decrypt.go
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Jul 30, 2024
1 parent 1cd3400 commit 57638f8
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions pkg/aea/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,6 @@ func decryptCluster(ctx context.Context, r io.ReadSeeker, outfile *os.File, main
return err
}

// out <- work{ClusterIndex: cindex, Data: bytes.Join(segments, nil)}

clusterMAC = nextClusterMac
cindex++

Expand Down Expand Up @@ -428,34 +426,24 @@ func aeaDecrypt(in, out string, symmetricKey []byte) (string, error) {
return "", err
}

dec := make(chan work) // decrypted data channel

of, err := os.Create(out)
if err != nil {
return "", err
}
defer of.Close()

// go func() {
if err := decryptCluster(context.Background(), f, of, mainKey, encRootHdr.ClusterHmac, rootHdr, dec); err != nil {

Check failure on line 435 in pkg/aea/decrypt.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: dec
log.WithError(err).Error("failed to decrypt cluster")
}
// }()

// total := 0
// for d := range dec {
// log.Debugf("Writing cluster %d", d.ClusterIndex)
// if n, err := of.Write(d.Data); err != nil {
// return "", err
// } else {
// log.Debugf("Wrote %s", humanize.Bytes(uint64(n)))
// total += n
// }
// }
// log.Debugf("TOTAL: %s", humanize.Bytes(uint64(total)))
// if total != int(rootHdr.FileSize) {
// return "", fmt.Errorf("invalid file size: %d; expected %d", total, rootHdr.FileSize)
// }

finfo, err := of.Stat()
if err != nil {
return "", err
}
if int(finfo.Size()) != int(rootHdr.FileSize) {
return "", fmt.Errorf("invalid file size: %d; expected %d", finfo.Size(), rootHdr.FileSize)
}

return out, nil
}

Expand Down Expand Up @@ -488,8 +476,8 @@ func Decrypt(c *DecryptConfig) (string, error) {
}
}

if true {
// if _, err := os.Stat(aeaBinPath); os.IsNotExist(err) { // 'aea' binary NOT found (linux/windows)
// if true {
if _, err := os.Stat(aeaBinPath); os.IsNotExist(err) { // 'aea' binary NOT found (linux/windows)
log.Info("Using pure Go implementation for AEA decryption")
return aeaDecrypt(c.Input, filepath.Join(c.Output, filepath.Base(strings.TrimSuffix(c.Input, filepath.Ext(c.Input)))), c.symEncKey)
}
Expand Down

0 comments on commit 57638f8

Please sign in to comment.