Skip to content

Say how a file is protected and what it allows - #9

Merged
tannevaled merged 1 commit into
mainfrom
protection-report
Aug 25, 2026
Merged

Say how a file is protected and what it allows#9
tannevaled merged 1 commit into
mainfrom
protection-report

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

A document that opened has already been decrypted, and said nothing about what it had been protected with on the way.

Document.Protection() now reports it:

type Protection struct {
    Method      string      // "RC4-40", "RC4-128", "AES-128", "AES-256", "none"
    Revision    int         // 2, 3, 4, 5 or 6
    Permissions Permissions // what the file grants
    Owner       bool        // opened with the owner password, so they do not apply
}

Working out which password opened a file meant carrying that back from both key derivations, so a legacy candidate now says whether reaching it meant knowing the owner's password rather than the user's.

Permissions gains Allows and String, so what a file grants can be put in front of a person as words — print, copy — rather than as a bit pattern.

This is what ops needs for a permissions verb, and what pdfops needs to answer "what is this file, and what may I do with it".

100% statement coverage, go vet and gofmt clean.

A document that opened has already been decrypted, and said nothing about what
it had been protected with on the way. Document.Protection now reports it: the
method in words — RC4-40, RC4-128, AES-128, AES-256, or none for a file that
declares a security handler and then protects nothing with it — the handler's
revision, the permissions the file grants, and whether the password it opened
with was the owner's, in which case those permissions do not apply.

Working out which password opened a file meant carrying that back from the two
key derivations, so a legacy candidate now says whether reaching it meant
knowing the owner's password rather than the user's.

Permissions gains Allows and String, so that what a file grants can be put in
front of a person as words rather than as a bit pattern.
@tannevaled
tannevaled merged commit 118c49d into main Aug 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant