icwmp/scripts/wepkeygen
Mohamed Kallel 27b73d5af7 PIVA::DELIVERY 8
script optimization
Voice parameters: AddObject/DeleteObject
Voice parameters: Vendor specific parameter

Concerning what we did in the optimization task:
1)  The main script  (freecwmp) is loaded only 1 time during the session. the load is done just before the start of the session. the function scripts are loaded within the load of the main script (freecwmp) only one time. The old behaviour consist to load the main script (freecwmp) and the function scripts for each parameter treatment. Core code (C) and Scripts are changed
2) Optimize the preparing of inform message. old script take ~30s and now it takes ~2s. Core code (C) and Scripts are changed
3) Execute only the function related to the parameter. For example if the requested parameter is "InternetGatewayDevice.ManagementServer.URL" then the main script freecwmp will execute only the related function of this parameter which is get_management_server(). The old behaviour consist to execute all get functions: get_wan_device(), get_lan_device(), get_device_info()...
4) Minimize the size of the script files: Replace some blocks o othe source code by a functions
2013-07-24 16:05:32 +01:00

74 lines
1.4 KiB
Bash

#!/usr/sbin/bash
# Copyright (C) 2013 Inteno Broadband Technology AB
# Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
usage()
{
echo "Usage: $0 <strength> <passphrase>"
echo "-<strength> Indicate the WEP KEY strength to generate. Should be 64 or 128"
echo "<passphrase> Indicate the passphrase used to generate the WEP KEY"
echo "$0 -h display this help"
}
wepkey128()
{
dup="$1"
while [ ${#dup} -lt 64 ]
do
dup="$dup$1"
done
dup="${dup:0:64}"
key=`echo -n $dup | md5sum`
echo "${key:0:26}"
}
wepkey64()
{
pass=$1
pseed=" 0 0 0 0"
i=0
while [ $i -lt ${#pass} ]
do
let n=$i%4
let j=$n*3
let h=$j+3
code=`printf '%d' "'${pass:$i:1}"`
let "oxor=$code^${pseed:$j:3}"
oxor=`printf '%3d' $oxor`
pseed=${pseed:0:$j}$oxor${pseed:$h}
let "i++"
done
let "randNumber=${pseed:0:3}|(${pseed:3:3}<<8)|(${pseed:6:3}<<16)|(${pseed:9}<<24)"
k64=""
for i in 0 1 2 3
do
for j in 0 1 2 3 4
do
let "randNumber=($randNumber * $((0x343fd)) + $((0x269ec3))) & $((0xffffffff))"
let "tmp=($randNumber>>16)&$((0xff))"
k64=$k64`printf '%02x' $tmp`
done
k64=$k64"\n"
done
printf "$k64"
}
if [ "_$1" = "-h" ]; then
usage;
exit 0;
fi
strength=$1
passphrase=$2
if [ _$strength != "_64" -a _$strength != "_128" ] || [ _$passphrase = "_" ]; then
usage;
exit 0;
fi
if [ $strength = "128" ]; then
wepkey128 $passphrase
else
wepkey64 $passphrase
fi