Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Leftover questions about age #363

Closed
UnixCro opened this issue Nov 26, 2021 · 3 comments
Closed

Leftover questions about age #363

UnixCro opened this issue Nov 26, 2021 · 3 comments

Comments

@UnixCro
Copy link

UnixCro commented Nov 26, 2021

Hello,

please excuse me if it is a stupid question, but I am not familiar with cryptography, so please give me an answer.

age-keygen generates a public key and a private key and a new pair each time it is called.

Isn't it possible that at some point all possible combinations will be used up and that by chance someone will have the same private key as the public key?

  1. Which algorithm does age encrypt with, somehow I couldn't find anything about it?

  2. I understand the parameter —armor, you might be so friendly and you could explain it to me in more detail, perhaps with examples.

@covert-encryption
Copy link

@UnixCro There are so insanely many possible secret keys that it is impossible to ever create the same ones again, assuming that the source of random numbers is working properly. It is impossible to grasp how large the number of possibilities is, but here is a video that covers it quite well: https://www.youtube.com/watch?v=S9JGmA5_unY

The encryption algorithm is ChaCha20 with Poly1305 authentication. This is mentioned in the specification, and is pretty much the best algorithm currently known, and also very widely used in different systems. Different types of recipient keys are used, as explained in the specs, to derive the file encryption key used with ChaCha20 which encrypts all your data.

Armor means conversion into Base64, which is well explained in multiple sources, so that it becomes ASCII text, rather than binary data. This is to allow copy&pasting to messaging software, where you cannot always attach binary files. Age imitates PGP in that it also adds -----BEGIN AGE ENCRYPTED FILE----- headers around the base64 but these are actually quite useless, if not for advertising the software used.

@str4d
Copy link

str4d commented Nov 26, 2021

The reason age supports armoring is not for copying files into messaging software (though it does enable that as a side effect), but because Windows machines don't have consistent handling of Unix line endings. The age format consistently uses \n for separating header sections (and requires them for canonicity), but Windows can and will interfere with that and use \r\n instead. The armoring format provides slightly more flexibility in that it accepts either kind of line ending.

The BEGIN headers around the armored format are there because age uses the strict textual encoding format defined in RFC 7468.

@covert-encryption
Copy link

This is becoming off topic, and I certainly respect the effort to follow an RFC, but a few comments on armoring...

Indentation, different EOLs and quote marks > can be handled/removed just fine without those headers.

Verifying that each line except for the last one is of full length, and that the last line is divisible by four protect against loss of characters (some systems miss characters when a large amount of text is pasted on a terminal, and in messaging if not properly code tagged, /slashes/ in Base64 may be interpreted as italics and removed). Invalidating anything with non-Base64 characters within the lines quite reliably rejects any text snippets that are not actually Base64. The headers are particularly prone to corruption by Unicode hyphen conversions or --overstrike-- markup (but again one should be using code tags, so this might be a good thing, catching such issues early).

Given that Age has its plain text header also within the Base64 encoded content, the format can be easily verified even without these headers, and certainly one can just base64 -d the content and hand it over to Age as a non-armored file.

Presumably the headers would allow for easier extraction of Age snippets from a longer text, and the footer would allow Age to stop reading more input lines from console once the footer is seen. However, it seems that the current implementation does not do either of these, but instead decodes the message before even reading the footer: #364

Repository owner locked and limited conversation to collaborators Nov 29, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants