]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:scripting/devel: make use of the generic arcfour_encrypt() and string_to_byte_arra...
authorStefan Metzmacher <metze@samba.org>
Thu, 28 Jan 2016 13:00:38 +0000 (14:00 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 3 Feb 2016 07:33:11 +0000 (08:33 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11699

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source4/scripting/devel/createtrust

index 7f1ba33b85ce2c78b08c2230d20e2316c3c963c8..6c0de1c3ff18e2c2e340b71a59eec93ac637bb73 100755 (executable)
@@ -11,21 +11,9 @@ import samba
 import samba.getopt as options
 from samba.dcerpc import lsa, security, drsblobs
 from samba.ndr import ndr_pack
+from samba import arcfour_encrypt, string_to_byte_array
 import random
 
-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
-
 ########### main code ###########
 if __name__ == "__main__":
     parser = OptionParser("createtrust [options] server")
@@ -73,7 +61,7 @@ if __name__ == "__main__":
     info.trust_type = lsa.LSA_TRUST_TYPE_UPLEVEL
     info.trust_attributes = lsa.LSA_TRUST_ATTRIBUTE_WITHIN_FOREST
 
-    password_blob = string_to_array("password".encode('utf-16-le'))
+    password_blob = string_to_byte_array("password".encode('utf-16-le'))
 
     clear_value = drsblobs.AuthInfoClear()
     clear_value.size = len(password_blob)
@@ -123,7 +111,7 @@ if __name__ == "__main__":
 
     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