[macOS] fix kcpassword issue for passwords exactly 11 bytes long (#5305)

This commit is contained in:
Aleksandr Chebotov
2022-03-30 12:04:17 +02:00
committed by GitHub
parent e4da6b3499
commit 63cd495e98
2 changed files with 6 additions and 2 deletions

View File

@@ -18,7 +18,9 @@ def kcpassword(passwd):
passwd = [ord(x) for x in list(passwd)] passwd = [ord(x) for x in list(passwd)]
# pad passwd length out to an even multiple of key length # pad passwd length out to an even multiple of key length
r = len(passwd) % key_len r = len(passwd) % key_len
if (r > 0): if len(passwd) == 11:
passwd += [0]
elif (r > 0):
passwd = passwd + [0] * (key_len - r) passwd = passwd + [0] * (key_len - r)
for n in range(0, len(passwd), len(key)): for n in range(0, len(passwd), len(key)):

View File

@@ -25,7 +25,9 @@ function kcpasswordEncode {
#get padding by subtraction if under 11 #get padding by subtraction if under 11
local r=$(( ${#thisStringHex_array[@]} % 11 )) local r=$(( ${#thisStringHex_array[@]} % 11 ))
local padding=0 local padding=0
if [ $r -gt 0 ]; then if [ ${#thisStringHex_array[@]} -eq 11 ];
local padding=1
elif [ $r -gt 0 ]; then
local padding=$(( 11 - $r )) local padding=$(( 11 - $r ))
fi fi