def write_private_key_file(self, filename, password=None): keylist = [ 0, self.p, self.q, self.g, self.y, self.x ] try: b = BER() b.encode(keylist) except BERException: raise SSHException('Unable to create ber encoding of key') self._write_private_key_file('DSA', filename, str(b), password)
def test_encode_decode(self): """ When decoding an encoded integer, the original integer should be returned """ ber = BER() ber.encode(1337) decoded = ber.decode() self.assertEqual(decoded, 1337)
def test_encode_works_on_lists_directly(self): """ Encode should raise exception when used with string """ ber = BER() original_list = [1, 2, 3, 4, 5] ber.encode(original_list) self.assertEqual(ber.decode(), original_list)
def _encode_key(self): if self.x is None: raise SSHException('Not enough key information') keylist = [0, self.p, self.q, self.g, self.y, self.x] try: b = BER() b.encode(keylist) except BERException: raise SSHException('Unable to create ber encoding of key') return b.asbytes()
def _encode_key(self): if self.x is None: raise SSHException('Not enough key information') keylist = [0, self.p, self.q, self.g, self.y, self.x] try: b = BER() b.encode(keylist) except BERException: raise SSHException('Unable to create ber encoding of key') return b.asbytes()
def _encode_key(self): if self.x is None: raise SSHException("Not enough key information") keylist = [0, self.p, self.q, self.g, self.y, self.x] try: b = BER() b.encode(keylist) except BERException: raise SSHException("Unable to create ber encoding of key") return str(b)
def write_private_key_file(self, filename, password=None): keylist = [ 0, self.n, self.e, self.d, self.p, self.q, self.d % (self.p - 1), self.d % (self.q - 1), util.mod_inverse(self.q, self.p) ] try: b = BER() b.encode(keylist) except BERException: raise SSHException('Unable to create ber encoding of key') self._write_private_key_file('RSA', filename, str(b), password)
def _encode_key(self): if (self.p is None) or (self.q is None): raise SSHException('Not enough key info to write private key file') keylist = [ 0, self.n, self.e, self.d, self.p, self.q, self.d % (self.p - 1), self.d % (self.q - 1), util.mod_inverse(self.q, self.p) ] try: b = BER() b.encode(keylist) except BERException: raise SSHException('Unable to create ber encoding of key') return b.asbytes()
def _encode_key(self): if (self.p is None) or (self.q is None): raise SSHException('Not enough key info to write private key file') keylist = [0, self.n, self.e, self.d, self.p, self.q, self.d % (self.p - 1), self.d % (self.q - 1), util.mod_inverse(self.q, self.p)] try: b = BER() b.encode(keylist) except BERException: raise SSHException('Unable to create ber encoding of key') return b.asbytes()
def write_private_key_file(self, filename, password=None): keylist = [ 0, self.n, self.e, self.d, self.p, self.q, self.d % (self.p - 1), self.d % (self.q - 1), util.mod_inverse(self.q, self.p) ] try: b = BER() b.encode(keylist) except BERException: raise SSHException('Unable to create ber encoding of key') self._write_private_key_file('RSA', filename, str(b), password)