keybase / keybase-issues

A single repo for managing publicly recognized issues with the keybase client, installer, and website.
902 stars 37 forks source link

Encrypted messages are too long, should be broken into multiple lines #3185

Open echosa opened 6 years ago

echosa commented 6 years ago

When I use keybase encrypt, the result is one giant long line, like:

BEGIN KEYBASE SALTPACK ENCRYPTED MESSAGE. 1234567890abcdef 1234567890abcdef  …etc… END KEYBASE SALTPACK ENCRYPTED MESSAGE. 

The problem is, this can be very long. If someone sends me this, I can't copy/paste it into my terminal to keybase decrypt it. The paste output gets stopped after 1024 characters, and I'm no longer able to add anymore input. I assume this is a Bash limitation, as it doesn't matter which terminal program I'm in or which CLI command I'm pasting into (keybase, cat, etc.)

GPG, on the other hand, encrypts messages into multiple lines, so this is never an issue.

Can Keybase make it so that encrypted messages are multiple lines and never have more than 1024 characters in each line so that they can be pasted into terminals for decryption, please?

oconnor663 commented 6 years ago

The messages are broken up into something around 3000 characters per line, though the expectation is that most terminals will wrap them gracefully. When I try to paste a large message (50k characters) into gnome-terminal + tmux, it seems to come out fine. Could you say more about what terminal you're using, so that maybe I could try to repro the issue?

Also, could you clarify what you mean by a bash limitation? The most straightforward way I can think of to paste a message into the terminal is to just run keybase decrypt with no further arguments, and then to paste into that and hit Ctrl-D. In that case, bash gets out of the way, and it's just keybase reading stdin from the terminal. Are you doing something more interesting?

echosa commented 6 years ago

I'm using both Terminal.app and iTerm 2 on macOS. When I paste a large amount of text, it stops at 1024.

bash limitation

I, probably naïvely, assumed that since multiple programs in multiples terms all had this problem, the common factor in all of the tests was bash. Therefore, I assume that bash is limiting the amount of input allowed.

run keybase decrypt with no further arguments, and then to paste into that and hit Ctrl-D.

That's exactly what I'm trying to do, but it doesn't work. Whether I run keybase decrypt or cat or whatever, the terminal is then waiting for input, as it should. When I paste the encrypted message, the terminal stops accepting input on that line after the 1024th character.

What's interesting, is that if I just paste the encrypted message straight at the prompt, it works fine. It only seems to get cut off when the terminal is accepting "buffered input" (not sure what it's really called... like when you just run cat then you can type, type, type, Ctrl-D… whatever that's called). This "buffered input" doesn't allow more than 1024 characters. The terminal refuses more characters on that like and dings at me with the Ctrl-G bell.

Hopefully that clears it up. Happy to answer more questions.

echosa commented 6 years ago

Ah, additionally, this works:

$ keybase decrypt -m '<paste>'

but this does not:

$ keybase decrypt # or cat, etc.
<paste>
oconnor663 commented 6 years ago

@malgorithms do you have any issue pasting long messages into your terminal? I remember we tried to test this sort of thing back in the day. We could always shorten the line length we emit...

malgorithms commented 6 years ago

hmm, I always use pbcopy and pbpaste on the mac. So I do this:

pbpaste | keybase decrypt

but yeah, we could change our 3000 to 1000. I don't want to go too small with it, because I think it formats nicely in most places by letting that place decide how to wrap.

echosa commented 6 years ago

Also, here's some related info, just FYI: https://unix.stackexchange.com/questions/204815/terminal-does-not-accept-pasted-or-typed-lines-of-more-than-1024-characters