Skip to content
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

Can not paste more than 1023 chars into recovery input #19

Open
D3N14L opened this issue Jan 9, 2023 · 5 comments
Open

Can not paste more than 1023 chars into recovery input #19

D3N14L opened this issue Jan 9, 2023 · 5 comments

Comments

@D3N14L
Copy link

D3N14L commented Jan 9, 2023

Problem description

When pasting more than 1023 chars into the recovery input, the command stalls after 1024 chars and does not accept any more key presses.

How to reproduce

# Generate dummy ssh key 
$ ssh-keygen -t rsa -b 4096 -f /tmp/id_rsa -N ""

# Create a paperback backup. From the output copy the first line below "Main Document:" 
$ target/release/paperback backup --quorum-size 1 --shards 1 /tmp/id_rsa

# delete the dummy ssh key
$ rm /tmp/id_rsa

# Execute the recovery command and paste the copied line into the recovery command prompt
$ target/release/paperback recover --interactive /tmp/id_rsa
Enter a main document code (unknown number of codes remaining): 9253239620054760480773498079880048392085023609742842040441216447577496617446522511370875848613996704392955370327328922021505813624459430649615647004836257715583803915725820234492619487563511735058047789402755199339859092601746721608432634524157899952992320457872099698050063905737816078540584111814371613885832431003302577055324833129473947363860462659423259525211314871908819730229296258076477521533657856983503245554846583692028058674287473573834129460088792647819166374931328080799339353723362304667836773508987216392810973673734903634617168285294218709368415340502361941598376136512904673448181173749369421372015801785805191848425038073416836444570342722255581674236030369275690062713106590311335700342677911770602043028693566314131764350369055707158650741524998825631546473357742808615494982181991857662250928740189539612597602590152772154238218901242586014158935194393650542887393610351381599452557668098113435215653343861277404681664851781973715584822873633221126356012335405179879816615450526302967659493552671496472^C

# kill the command with ctrl+c

Workaround

Use pbpaste | fold -w 1023 to split the Main Document line into lines of (max) 1023 chars length and paste the ouput into the recovery command:

$ target/release/paperback recover --interactive /tmp/id_rsa
Enter a main document code (unknown number of codes remaining): 925323962005476048077349807988004839208502360974284204044121644757749661744652251137087584861399670439295537032732892202150581362445943064961564700483625771558380391572582023449261948756351173505804778940275519933985909260174672160843263452415789995299232045787209969805006390573781607854058411181437161388583243100330257705532483312947394736386046265942325952521131487190881973022929625807647752153365785698350324555484658369202805867428747357383412946008879264781916637493132808079933935372336230466783677350898721639281097367373490363461716828529421870936841534050236194159837613651290467344818117374936942137201580178580519184842503807341683644457034272225558167423603036927569006271310659031133570034267791177060204302869356631413176435036905570715865074152499882563154647335774280861549498218199185766225092874018953961259760259015277215423821890124258601415893519439365054288739361035138159945255766809811343521565334386127740468166485178197371558482287363322112635601233540517987981661545052630296765949355267149647
226410538752391687911178318761080263108873022289284775587263668520331196972717697729788699398000173167806414614066258077067583088872821697226010398021823269373626541263340690902799891290195493231182505245988875228760735053610597622081372604957530939286812127279080393969338927405945210253668028668802396229106118040187749421774338451359750232325256546621164852961903428689581143751595660495424206222631944811791136556562665493854032676701329609059487180961119135380038394503182348329712756562548915305529935105716937911622233399595667033090052582507631333501183018417557726767882193277875868037920955394012806979455562452417268489519269164171473060246786822153865734340408197037615747796220862512927762776884634853344962301319327658743875225210860203381248682319300437723223314079610373260298521740246726570523473560457579068620266950310955013429105611246634681922824973450998433633929358510851168741554990897898123776323662065302374765725725752498255316418580610280332212084157119108874124773153735166470779108917882795390
09196407271449258621087535011601344373819201070644111198228597890282749477039387676183312395301367402243850223592732949953864817270418614449223792966

Enter a main document code (3 codes remaining):

Build Env

paperback: commit 0bd9e493b1220dc28b9241946b80d53bd7d38cfe (main at the time of writing)
OS: MacOS Ventura 13.1  (Apple Silicon M1) 
Cargo: 1.66.0 (d65d197ad 2022-11-15)
@cyphar
Copy link
Owner

cyphar commented Sep 17, 2023

Weird, we use std::io::BufReader in a fairly straightforward way; I wouldn't expect it to block indefinitely at 1024 bytes. I'll take a look...

@YouXam
Copy link

YouXam commented Apr 23, 2024

Weird, we use std::io::BufReader in a fairly straightforward way; I wouldn't expect it to block indefinitely at 1024 bytes. I'll take a look...

@cyphar I analyze the reasons for this limitation and provide possible solutions at #71.

@cyphar
Copy link
Owner

cyphar commented May 30, 2024

(Comment by @YouXam, from #71.)

Description

On macOS, there appears to be an issue when attempting to input a complete set of QR code data into the terminal in a single line. The macOS terminal input is restricted to 1024 characters as defined by the system limits (source). Once 1024 characters have been entered on a single line, any further input (including the Enter key) is not accepted. Typically, the data extracted from QR codes exceeds this 1024-character limit. As a result, this limitation forces users to engage in inconvenient and confusing multiple manual copy-paste operations to input the entire data string.

Possible Solutions

1. Modify the QR code generation process to output data in multiple lines rather than a single long line. This approach can help users to more easily handle and input data within the limitations of the macOS terminal character count.

2. Explore using libraries like [rustyline](https://github.com/kkawakam/rustyline) which might allow bypassing the 1024 character limit per line. This could provide a more seamless input experience for users dealing with lengthy single-line data.

This issue is particularly critical as the program necessitates the entry of large amounts of data, making it inevitable for macOS users to face this limitation. Users unfamiliar with this system constraint might not understand why they are unable to input data successfully, leading to significant usability concerns.

We hope this issue can be prioritized for a resolution to enhance the functionality and user experience of macOS terminal operations. Thank you for your attention and looking forward to any updates or feedback from the development team.

@cyphar
Copy link
Owner

cyphar commented May 30, 2024

@YouXam It wasn't necessary to open a new issue 😅.

We could add new lines to the QR codes, but because of how QR codes are encoded, adding a character from outside the character set we use will waste more space than just a single character (the encoder has to specify two extra encoding changes as well as the newline itself).

FWIW, the goal of paperback is to have a user-friendly GUI so that non-technical folks can do recovery and other necessary operations. Since the GUI is going to be the primary method of using paperback, the limitations of MacOS's terminal shouldn't affect things like how we encode data IMHO.

However, if switching to unbuffered mode (and using a readline-like library for input) also solves the issue, we can do that.

@YouXam
Copy link

YouXam commented May 30, 2024

@YouXam It wasn't necessary to open a new issue 😅.

We could add new lines to the QR codes, but because of how QR codes are encoded, adding a character from outside the character set we use will waste more space than just a single character (the encoder has to specify two extra encoding changes as well as the newline itself).

FWIW, the goal of paperback is to have a user-friendly GUI so that non-technical folks can do recovery and other necessary operations. Since the GUI is going to be the primary method of using paperback, the limitations of MacOS's terminal shouldn't affect things like how we encode data IMHO.

However, if switching to unbuffered mode (and using a readline-like library for input) also solves the issue, we can do that.

Is there currently a plan to develop a GUI program?

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

No branches or pull requests

3 participants