-
-
Notifications
You must be signed in to change notification settings - Fork 578
age: add ExtractHeader, DecryptHeader, and NewInjectedFileKeyIdentity #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
821adc7 to
b671626
Compare
AnomalRoil
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a nice addition that will make using it as a library a little bit easier as well, I'm guessing the goal is to allow to have detached headers to have files with just ciphertext and no headers?
|
|
||
| func decryptHdr(hdr *format.Header, identities ...Identity) ([]byte, error) { | ||
| if len(identities) == 0 { | ||
| return nil, errors.New("no identities specified") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an error that might be worth exporting to allow library users to easily spot it (errors.Is(err, age.ErrNoIdentity)) and issue proper guidance to their users.
| type injectedFileKeyIdentity struct { | ||
| fileKey []byte | ||
| } | ||
|
|
||
| // NewInjectedFileKeyIdentity returns an [Identity] that always produces | ||
| // a fixed file key, such as one returned by [DecryptHeader]. | ||
| func NewInjectedFileKeyIdentity(fileKey []byte) Identity { | ||
| return injectedFileKeyIdentity{fileKey} | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name isn't immediately clear imo, maybe fixedFileKeyIdentity would be clearer?
| return nil, ErrIncorrectIdentity | ||
| } | ||
|
|
||
| // ExtractHeader returns a detched header from the src file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: s/detched/detached/
No description provided.