def _generateAndSaveKeys(registry=None): registry = registry or Registry_Base_URL k = rsa.generate_private_key(public_exponent=65537, key_size=2048, backend=default_backend()) privatekey_pem = k.private_bytes(serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption()) pubkey_pem = k.public_key().public_bytes( serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo) if _isPublicRegistry(registry): settings.setProperty('keys', 'private', privatekey_pem.decode('ascii')) settings.setProperty('keys', 'public', pubkey_pem.decode('ascii')) else: sources = _getSources() keys = None for s in sources: if _sourceMatches(s, registry): if not 'keys' in s: s['keys'] = dict() keys = s['keys'] break if keys is None: keys = dict() sources.append({'type': 'registry', 'url': registry, 'keys': keys}) keys['private'] = privatekey_pem.decode('ascii') keys['public'] = pubkey_pem.decode('ascii') settings.set('sources', sources) return pubkey_pem, privatekey_pem
def _generateAndSaveKeys(registry=None): registry = registry or Registry_Base_URL k = rsa.generate_private_key(public_exponent=65537, key_size=2048, backend=default_backend()) privatekey_pem = k.private_bytes( serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption() ) pubkey_pem = k.public_key().public_bytes( serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo ) if _isPublicRegistry(registry): settings.setProperty("keys", "private", privatekey_pem.decode("ascii")) settings.setProperty("keys", "public", pubkey_pem.decode("ascii")) else: sources = _getSources() keys = None for s in sources: if _sourceMatches(s, registry): if not "keys" in s: s["keys"] = dict() keys = s["keys"] break if keys is None: keys = dict() sources.append({"type": "registry", "url": registry, "keys": keys}) keys["private"] = privatekey_pem.decode("ascii") keys["public"] = pubkey_pem.decode("ascii") settings.set("sources", sources) return pubkey_pem, privatekey_pem
def _generateAndSaveKeys(): k = RSA.generate(2048) privatekey_hex = binascii.hexlify(k.exportKey('DER')) settings.setProperty('keys', 'private', privatekey_hex) pubkey_hex = binascii.hexlify(k.publickey().exportKey('DER')) settings.setProperty('keys', 'public', pubkey_hex) return pubkey_hex, privatekey_hex
def _pollForAuth(registry=None): tokens = registry_access.getAuthData(registry=registry) if tokens: if "github" in tokens: settings.setProperty("github", "authtoken", tokens["github"]) # mbed login doesn't send us a token return True return False
def _pollForAuth(registry=None): tokens = registry_access.getAuthData(registry=registry) if tokens: if 'github' in tokens: settings.setProperty('github', 'authtoken', tokens['github']) # mbed login doesn't send us a token return True return False
def _generateAndSaveKeys(): k = RSA.generate(2048) privatekey_hex = binascii.hexlify(k.exportKey('DER')).decode('ascii') settings.setProperty('keys', 'private', privatekey_hex) pubkey_hex = binascii.hexlify( k.publickey().exportKey('DER')).decode('ascii') settings.setProperty('keys', 'public', pubkey_hex) return pubkey_hex, privatekey_hex
def _pollForAuth(registry=None): tokens = registry_access.getAuthData(registry=registry) if tokens: if 'github' in tokens: settings.setProperty('github', 'authtoken', tokens['github']) if 'mbed' in tokens: settings.setProperty('mbed', 'authtoken', tokens['mbed']) return True return False
def getPublicKey(): ''' Return the user's public key (generating and saving a new key pair if necessary) ''' pubkey_hex = settings.getProperty('keys', 'public') if not pubkey_hex: k = RSA.generate(2048) settings.setProperty('keys', 'private', binascii.hexlify(k.exportKey('DER'))) pubkey_hex = binascii.hexlify(k.publickey().exportKey('DER')) settings.setProperty('keys', 'public', pubkey_hex) pubkey_hex, privatekey_hex = _generateAndSaveKeys() return _pubkeyWireFormat(RSA.importKey(binascii.unhexlify(pubkey_hex)))
def _generateAndSaveKeys(registry=None): registry = registry or Registry_Base_URL k = rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_backend() ) privatekey_pem = k.private_bytes( serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption() ) pubkey_pem = k.public_key().public_bytes( serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo ) if _isPublicRegistry(registry): settings.setProperty('keys', 'private', privatekey_pem.decode('ascii')) settings.setProperty('keys', 'public', pubkey_pem.decode('ascii')) else: sources = _getSources() keys = None for s in sources: if _sourceMatches(s, registry): if not 'keys' in s: s['keys'] = dict() keys = s['keys'] break if keys is None: keys = dict() sources.append({ 'type':'registry', 'url':registry, 'keys':keys }) keys['private'] = privatekey_pem.decode('ascii') keys['public'] = pubkey_pem.decode('ascii') settings.set('sources', sources) return pubkey_pem, privatekey_pem
def deauthorize(): if settings.getProperty('github', 'authtoken'): settings.setProperty('github', 'authtoken', '')
def deauthorize(): if settings.getProperty('keys', 'private'): settings.setProperty('keys', 'private', '') if settings.getProperty('keys', 'public'): settings.setProperty('keys', 'public', '')
def _pollForAuth(): tokens = registry_access.getAuthData() if tokens and 'github' in tokens: settings.setProperty('github', 'authtoken', tokens['github']) return True return False
def deauthorize(): if settings.getProperty('github', 'authtoken'): settings.setProperty('github', 'authtoken', '') if settings.getProperty('mbed', 'authtoken'): settings.setProperty('mbed', 'authtoken', '')