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

compress qr code data #27

Closed
mwarning opened this issue Jun 27, 2019 · 12 comments
Closed

compress qr code data #27

mwarning opened this issue Jun 27, 2019 · 12 comments
Labels
enhancement New feature or request

Comments

@mwarning
Copy link
Owner

mwarning commented Jun 27, 2019

Key or certificates as part of the setup often do not fit into the QR-Code. Compress might help here.
Some data as pictures (in future versions) would need to be removed.

@mwarning mwarning added the enhancement New feature or request label Jun 27, 2019
@clach04
Copy link
Contributor

clach04 commented Jul 11, 2019

I hit this. My real https lock (with certs) is fine so luckily this is not impacting me :-)

For a test shell script with cert (that doesn't really control a lock https://github.com/mwarning/trigger/pull/30/files) I get an error that its too big (larger than 5000 bytes).

@mwarning
Copy link
Owner Author

I tried to apply compression, but the result was not significant enough to be useful.

@mwarning
Copy link
Owner Author

mwarning commented Jul 11, 2019

I was able to fit some certificates (e.g. for google.com) in the QR-Code. No idea how to improve the situation in general.

@clach04
Copy link
Contributor

clach04 commented Jul 16, 2019

I was not able to scan the qrcode with a generic app to look at the payload (scanning from within Trigger works great).

I spent a little time looking at the json export files. I saw a few places in the json payload where there is room for saving some bytes, I do not know if this would apply to qrcode:

  • the json file always contains a dictionary key, even for empty contents. Omitting empty string/null values would save a few bytes
  • the ssh key is noticeably larger (for me double the size) compared with a https key/
    • the ssh key is base encoded multiple times, there is the original plain-text (I think PEM PKCS8) format, this contains plain text markers along with base64 encoded data. Then as a wrapper there appears to be some binary data concatenated with the key, this combined payload is then base64 encoded again. This double encoding does pad out the payload more than needed, however the key is still larger than my sample https cert even if you ignore the double encoding.

Again, I looking at json payload. I'm not sure what the qrcode payload is where space is constrained.

@mwarning
Copy link
Owner Author

mwarning commented Jul 16, 2019

hm, empty strings and null values should be removed from the QR-Code: https://github.com/mwarning/trigger/blob/v1.9.1/app/src/main/java/com/example/trigger/QRShowActivity.java#L78

@mwarning
Copy link
Owner Author

This encoding for the ssh key could be improved. For now I wanted to be sure to get a string that does not contain binary data or the " character.

@mwarning
Copy link
Owner Author

mwarning commented Jul 16, 2019

The ssh key is also big because it stores the private and public key. Only the private key should be ok, but I do not know yet how to restore the public key from the private one with the library at hand.

@mwarning
Copy link
Owner Author

@mwarning
Copy link
Owner Author

The QR-Code is ~3400 Bytes now. But that is still too big.

@clach04
Copy link
Contributor

clach04 commented Jul 17, 2019

@mwarning good improvement/progress, frustrating results!

I don't need this functionality, json export/import is good for me. But this is an interesting problem. I have an idea for #32, I'll update there.

@mwarning
Copy link
Owner Author

The private key is about 512 Bytes (4096 bits), so it should be possible to fit it into the QR code - in theory.

@mwarning
Copy link
Owner Author

The used library stores the public key along the private key. There is not much i can do right now. Compression won't help here in a significant way. Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants