def agentc_ADD_IDENTITY(self, data): """ Adds a private key to the agent's collection of identities. On subsequent interactions, the private key can be accessed using only the corresponding public key. """ # need to pre-read the key data so we can get past it to the comment string keyType, rest = getNS(data) if keyType == 'ssh-rsa': nmp = 6 elif keyType == 'ssh-dss': nmp = 5 else: raise keys.BadKeyError('unknown blob type: %s' % keyType) rest = getMP( rest, nmp)[-1] # ignore the key data for now, we just want the comment comment, rest = getNS( rest) # the comment, tacked onto the end of the key blob k = keys.Key.fromString(data, type='private_blob') # not wrapped in NS here self.factory.keys[k.blob()] = (k, comment) self.sendResponse(AGENT_SUCCESS, '')
def failOnSome(line): if line.startswith('f'): raise keys.BadKeyError('failed to parse') return line
def failOnSome(line): if line.startswith(b"f"): raise keys.BadKeyError("failed to parse") return line