-
Notifications
You must be signed in to change notification settings - Fork 356
Add pyadb keygen command to generate keypairs #144
base: master
Are you sure you want to change the base?
Conversation
Let's help this thing reach master!
Hopefully I'll be able to do it soon. |
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.
Started a review for adb/android_pubkey.py
.
This is currently just a suggested cleanup, to increase readability for future reviews.
I will soon be inspecting the RSA-related code, with regards to:
- The correctness of the algorithm
- Library usage (specifically, porting to
cryptography
if possible).
Let me know what you think!
adb/android_pubkey.py
Outdated
def _to_bytes(n, length, endianess='big'): | ||
"""partial python2 compatibility with int.to_bytes | ||
https://stackoverflow.com/a/20793663""" | ||
if six.PY2: |
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.
Verify endianness
argument:
assert endianess in ('little', 'big')
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.
Hey! Thanks for the review. I like your changes overall.
The only ones I'm unsure about are the size_in
changes.
I'm not sure it's much clearer that way and might just be adding some unnecessary machinery, especially because it looks like its only used in two places. I'm probably open to it if you feel strongly about it, but how would you feel about leaving it the way it is, but maybe adding some comments to make it clearer?
I'll take a closer look when I get a chance and probably incorporate most/all of them.
It should be pretty easy to port to the other crypto lib but I haven't looked at it specifically.
I can help with that if you'd like.
The tests are probably most important.
Hi. I completely agree :) The But what if the modulus length is not a multiple of 32 or 8 bits? The Also agreed on the tests, probably most important. I'll try to get to those soon 👍 |
Co-Authored-By: Halastra <turchy@gmail.com>
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
Implementation and some comments from the following: - [auth.cpp] (https://github.com/aosp-mirror/platform_system_core/blob/c55fab4a59cfa461857c6a61d8a0f1ae4591900c/adb/client/auth.cpp) - [android_pubkey.c] (https://github.com/aosp-mirror/platform_system_core/blob/c55fab4a59cfa461857c6a61d8a0f1ae4591900c/libcrypto_utils/android_pubkey.c) - [android_pubkey.h] (https://github.com/aosp-mirror/platform_system_core/blob/c55fab4a59cfa461857c6a61d8a0f1ae4591900c/libcrypto_utils/include/crypto_utils/android_pubkey.h) Note: It looks like [2dc4ca] (aosp-mirror/platform_system_core@2dc4cab) removes the use of the public key file and directly extracts the public key from the private key.
With help from @Halastra suggestions from code review of google#144 - Define ANDROID_RSAPUBLICKEY_STRUCT - Remove use of six package - Fix some flake8 warnings Co-Authored-By: Halastra <turchy@gmail.com>
1a9a9cc
to
0a791b9
Compare
I rebased and incorporated most of your suggestions in 0791b9. I also ported it to use Let me know what you think! |
@googlebot I consent |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Well that took longer than expected.. but here goes.
Add the following code under
Regarding your previous notes:
Please add the above changes. I will review and approve them (promise!). |
Hey thanks for your suggestions! I haven't really been keeping up with this project, particularly #167 and all the stuff @JeffLIrion has been contributing, so it is a little unclear to me what the best path forward is. It's very possible his PR's could supersede this one. I'm happy to incorporate your suggestions to this PR either directly or you can maybe submit a PR to https://github.com/joeleong/python-adb/tree/add-custom-pubkey-encoding and I'll push your commits here. |
You are right in your observations. His work is indeed an improvement in many areas! So I guess I'll submit a PR to your repository as you suggested. |
Should address #95 and #131
pyadb keygen
command to mimicadb keygen
Note: I did update the dependencies since the pubkey code uses
pycryptodome
andsix
.I was having problems similar to #109, so I think you need
M2Crypto
orrsa
andpycryptodome
(2 libraries). There is probably a way to implement the pubkey stuff with the other crypto libraries but I didn't bother. Happy to change things if necessary.