From: Stefan Metzmacher Date: Thu, 28 Jan 2016 13:00:38 +0000 (+0100) Subject: python:samba/join.py: make use of the generic arcfour_encrypt() and string_to_byte_ar... X-Git-Tag: tevent-0.9.27~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d5423feb4b3d388d2de8e1745a8f1138b42b64f5;p=thirdparty%2Fsamba.git python:samba/join.py: make use of the generic arcfour_encrypt() and string_to_byte_array() functions BUG: https://bugzilla.samba.org/show_bug.cgi?id=11699 Signed-off-by: Stefan Metzmacher Reviewed-by: Alexander Bokovoy --- diff --git a/python/samba/join.py b/python/samba/join.py index cdfe45207cf..6df337c55c0 100644 --- a/python/samba/join.py +++ b/python/samba/join.py @@ -20,7 +20,7 @@ from samba.auth import system_session from samba.samdb import SamDB -from samba import gensec, Ldb, drs_utils +from samba import gensec, Ldb, drs_utils, arcfour_encrypt, string_to_byte_array import ldb, samba, sys, uuid from samba.ndr import ndr_pack from samba.dcerpc import security, drsuapi, misc, nbt, lsa, drsblobs @@ -963,19 +963,6 @@ class dc_join(object): def join_setup_trusts(ctx): """provision the local SAM.""" - def arcfour_encrypt(key, data): - from Crypto.Cipher import ARC4 - c = ARC4.new(key) - return c.encrypt(data) - - def string_to_array(string): - blob = [0] * len(string) - - for i in range(len(string)): - blob[i] = ord(string[i]) - - return blob - print "Setup domain trusts with server %s" % ctx.server binding_options = "" # why doesn't signing work here? w2k8r2 claims no session key lsaconn = lsa.lsarpc("ncacn_np:%s[%s]" % (ctx.server, binding_options), @@ -1005,7 +992,7 @@ class dc_join(object): except RuntimeError: pass - password_blob = string_to_array(ctx.trustdom_pass.encode('utf-16-le')) + password_blob = string_to_byte_array(ctx.trustdom_pass.encode('utf-16-le')) clear_value = drsblobs.AuthInfoClear() clear_value.size = len(password_blob) @@ -1041,7 +1028,7 @@ class dc_join(object): auth_blob = lsa.DATA_BUF2() auth_blob.size = len(encrypted_trustpass) - auth_blob.data = string_to_array(encrypted_trustpass) + auth_blob.data = string_to_byte_array(encrypted_trustpass) auth_info = lsa.TrustDomainInfoAuthInfoInternal() auth_info.auth_blob = auth_blob