summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2016-01-28 14:00:38 +0100
committerKarolin Seeger <kseeger@samba.org>2016-02-05 10:03:34 +0100
commit6c44fabcfd6fc4370a78854ab0ee9ac54f137a0e (patch)
treee0cea6ad4f1290f83fa6c0776c562bd1adca90c7
parent8acf14ed580e890f8cac10fb0d58523eeac169e9 (diff)
downloadsamba-6c44fabcfd6fc4370a78854ab0ee9ac54f137a0e.tar.gz
s4:scripting/devel: 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 <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> (cherry picked from commit 8841b1e641e1b950c2f36b26db982473b73b9d3b)
-rwxr-xr-xsource4/scripting/devel/createtrust18
1 files changed, 3 insertions, 15 deletions
diff --git a/source4/scripting/devel/createtrust b/source4/scripting/devel/createtrust
index 7f1ba33b85c..6c0de1c3ff1 100755
--- a/source4/scripting/devel/createtrust
+++ b/source4/scripting/devel/createtrust
@@ -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