Calculate the password requested by ethernet gateways from the Legrand / Bticino MyHome OpenWebNet home automation system when the user's ip address is not in the gateway's whitelist

Note: Factory default password is '12345'. Changing it is highly recommended !

conversation goes as follows

← *#*1##
→ *99*0##
← *#603356072##
at which point a password should be sent back, calculated from the "password open" that is set in the gateway, and the nonce that was just sent

→ *#25280520##
← *#*1##
F ownCalcPass(password, nonce)
   UInt32 result
   V start = 1B
   L(c) nonce
      I c != ‘0’ & start
         result = UInt32(Int(password))
         start = 0B
      S c
         ‘0’
            {}
         ‘1’
            result = rotr(result, 7)
         ‘2’
            result = rotr(result, 4)
         ‘3’
            result = rotr(result, 3)
         ‘4’
            result = rotl(result, 1)
         ‘5’
            result = rotl(result, 5)
         ‘6’
            result = rotl(result, 12)
         ‘7’
            result = (result [&] 0000'FF00) [|] result << 24 [|]
                     (result [&] 00FF'0000) >> 16 [|] (result [&] FF00'0000) >> 8
         ‘8’
            result = result << 16 [|] result >> 24 [|] (result [&] 00FF'0000) >> 8
         ‘9’
            result = (-)result
         E
            X ValueError(‘non-digit in nonce.’)
   R result
 
F test_passwd_calc(passwd, nonce, expected)
   V res = ownCalcPass(passwd, nonce)
   V m = passwd‘ ’nonce‘ ’res‘ ’expected
   I res == expected
      print(‘PASS ’m)
   E
      print(‘FAIL ’m)
 
test_passwd_calc(‘12345’, ‘603356072’, 25280520)
test_passwd_calc(‘12345’, ‘410501656’, 119537670)
test_passwd_calc(‘12345’, ‘630292165’, 4269684735)