diff options
author | Stefan Metzmacher <metze@samba.org> | 2016-01-28 14:00:38 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2016-02-03 08:33:11 +0100 |
commit | 8841b1e641e1b950c2f36b26db982473b73b9d3b (patch) | |
tree | 2225c5ef361f9f9110c26ec7f5aeaea7fabe9cd2 /source4/scripting/devel | |
parent | 452234b7bcdee2e0e3df6e0500ff798062bc5b9e (diff) | |
download | samba-8841b1e641e1b950c2f36b26db982473b73b9d3b.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>
Diffstat (limited to 'source4/scripting/devel')
-rwxr-xr-x | source4/scripting/devel/createtrust | 18 |
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 |