-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Native Generation of RO keys #3
Comments
Promising information here: https://forum.bittorrent.com/topic/21338-inofficial-protocol-specification/ but only covers standard keys, not encrypted keys. Specifically:
|
Example:
|
The linked post doesn't seem to work given our test cases; we expect B3KTFE2GJ7JOUJNW5C45RHKWY7YMZENBJ at the end.
|
I suspect this all involves some combination of b32encode, b32decode, sha1 or sha256, RSA/ECDSA private/public key related stuff. R/W keys correspond to private keys, R/O keys correspond to public keys, R/O encrypted correspond to a public key and a symmetric encryption key, and R/O storage correspond to a public key (less the symmetric encryption key). |
Placed a small bounty on bountysource; I suspect anyone moderately interested in public/private/symmetric cryptography with some spare time can figure this out with some experimentation. Worst case someone might need to take a look internally at what btsync does with the --generate-secret and --get-ro-secret flags. |
The following is all that is needed to start solving this bounty (make the two failing tests pass by figuring out the relation between rwenc/rwreg and roenc/roreg keys): import unittest
from hashlib import sha1, sha256
from base64 import b32encode, b64encode
from os import urandom
def baseKey2RWreg(baseKey):
return 'A'+baseKey
def baseKey2RWenc(baseKey):
return 'D'+baseKey
def ROenc2ROsto(ROenc):
return 'F'+ROenc[1:33]
def RWreg2ROreg(RWreg):
assert False, "Needs to be implemented."
def RWenc2ROenc(ROenc):
assert False, "Needs to be implemented."
class TestKeyMethods(unittest.TestCase):
def test_baseKey2RWreg(self):
self.assertEqual(baseKey2RWreg("OVD7B5MHX6RC4FYAIHNSHAUUIJPKWZOF"),
"AOVD7B5MHX6RC4FYAIHNSHAUUIJPKWZOF")
def test_baseKey2RWenc(self):
self.assertEqual(baseKey2RWenc("OVD7B5MHX6RC4FYAIHNSHAUUIJPKWZOF"),
"DOVD7B5MHX6RC4FYAIHNSHAUUIJPKWZOF")
def test_ROenc2ROsto(self):
self.assertEqual(ROenc2ROsto("EAOJPGYQTTEAMZM2XQH2XQB7I5MYKE4MSSFYWJC55PLS6CTUGAIBUZ7K2OY"),
"FAOJPGYQTTEAMZM2XQH2XQB7I5MYKE4MS")
def test_RWreg2ROreg(self):
self.assertEqual(RWreg2ROreg("AOVD7B5MHX6RC4FYAIHNSHAUUIJPKWZOF"),
"B3KTFE2GJ7JOUJNW5C45RHKWY7YMZENBJ")
def test_RWenc2ROenc(self):
self.assertEqual(RWenc2ROenc("DOVD7B5MHX6RC4FYAIHNSHAUUIJPKWZOF"),
"EAOJPGYQTTEAMZM2XQH2XQB7I5MYKE4MSSFYWJC55PLS6CTUGAIBUZ7K2OY")
if __name__ == '__main__':
unittest.main() |
This might require some reverse engineering but would keep us from having to include the binaries with distribution code and would also give us cross-platform support of Read-Only key generation.
Presently we lean upon the btsync binaries being available at run-time.
The text was updated successfully, but these errors were encountered: