airsonos icon indicating copy to clipboard operation
airsonos copied to clipboard

Invalid key length error

Open bjkeyser opened this issue 8 years ago • 25 comments

Hello... mostly worked but run into this error when I try to stream from my phone over aiplay. Running iOS 10 beta and OSX El Capitain 10.11.6. Any thoughts?

Error: Invalid key length at Error (native) at new Decipheriv (crypto.js:232:16) at Object.Decipheriv (crypto.js:229:12) at Object.decryptAudioData (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js:141:25) at RtpServer. (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/rtp.js:32:23) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at UDP.onMessage (dgram.js:540:8)

bjkeyser avatar Aug 20 '16 09:08 bjkeyser

Have you attempted to stream with an apple product running IOS 9? If so, have you reproduced your issue?

colinrioux avatar Aug 21 '16 21:08 colinrioux

+1, on iOS 9. Tested using node 4.5 and 6.4, on Arch Linux. The exception is triggered as soon as I hit play on my iDevice.

Search complete. Set up 4 device tunnels.
crypto.js:238
  this._handle.initiv(cipher, toBuf(key), toBuf(iv));
               ^

Error: Invalid key length
    at Error (native)
    at new Decipheriv (crypto.js:238:16)
    at Object.Decipheriv (crypto.js:235:12)
    at Object.decryptAudioData (/home/silvio/.nvm/versions/node/v6.4.0/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js:141:25)
    at RtpServer.<anonymous> (/home/silvio/.nvm/versions/node/v6.4.0/lib/node_modules/airsonos/node_modules/nodetunes/lib/rtp.js:32:23)
    at emitTwo (events.js:106:13)
    at Socket.emit (events.js:191:7)
    at UDP.onMessage (dgram.js:550:8)

sboehler avatar Aug 22 '16 21:08 sboehler

Same issue here on macOS Sierra beta: crypto.js:238 this._handle.initiv(cipher, toBuf(key), toBuf(iv)); ^

Error: Invalid key length at Error (native) at new Decipheriv (crypto.js:238:16) at Object.Decipheriv (crypto.js:235:12) at Object.decryptAudioData (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js:141:25) at RtpServer. (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/rtp.js:32:23) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at UDP.onMessage (dgram.js:550:8)

ghost avatar Aug 23 '16 09:08 ghost

#302 + Nodetunes fix

martinchapman avatar Aug 24 '16 10:08 martinchapman

Yes! that solves the issue

ghost avatar Aug 24 '16 11:08 ghost

I'm a bit new to this and have no idea how to apply this fix...can anyone help?

jonathanmmoore avatar Aug 24 '16 23:08 jonathanmmoore

when ths fix will be available on airsonos ?

yecine06 avatar Sep 10 '16 07:09 yecine06

I think the issue is that the pull request above has not yet been merged into nodetunes...

rightisleft avatar Oct 07 '16 15:10 rightisleft

I am seeing a similar issue:

Error: Invalid key length at Error (native) at new Decipheriv (crypto.js:239:16) at Object.Decipheriv (crypto.js:236:12) at Object.decryptAudioData (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js:141:25) at RtpServer. (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/rtp.js:32:23) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at UDP.onMessage (dgram.js:550:8)

discopolis avatar Oct 08 '16 12:10 discopolis

And I have updated the helper.js folder to reflect the #302 fix but still not working

discopolis avatar Oct 08 '16 12:10 discopolis

+1

anildigital avatar Oct 16 '16 14:10 anildigital

+1

isidore avatar Oct 18 '16 09:10 isidore

The fix works for me. Edit the file, ~/{user}/.nvm/versions/node/v6.2.1/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js

paddyriyer avatar Oct 19 '16 05:10 paddyriyer

Worked for me: Editing

/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js 

replacing

var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKey, audioAesIv);

with

var audioAesKeyBuffer = new Buffer(audioAesKey, 'binary');
var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKeyBuffer, audioAesIv);

isidore avatar Oct 24 '16 07:10 isidore

Thanks @isidore this worked for me!

naazy avatar Oct 26 '16 18:10 naazy

Worked for me too!

JoeCotellese avatar Nov 12 '16 17:11 JoeCotellese

I'm not a proficient programmer at all but could probably figure it out with a little help. Would appreciate if someone could advise how I can edit /usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js

and replace

var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKey, audioAesIv);

with

var audioAesKeyBuffer = new Buffer(audioAesKey, 'binary'); var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKeyBuffer, audioAesIv);

Thank you very much

psieyes avatar Dec 04 '16 17:12 psieyes

+1 Worked for me as well.

dabvid avatar Dec 13 '16 20:12 dabvid

@psieyes Open terminal.

Type vim /usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js to open the file.

Type /decipher to search for the string "decipher" and hit enter when it finds the line.

Type dd to delete that line.

Copy the two new lines:

var audioAesKeyBuffer = new Buffer(audioAesKey, 'binary');
var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKeyBuffer, audioAesIv);

Back in the terminal, type i to enter insert mode.

cmd + v to paste the new lines.

Hit ESC to exist insert mode.

Type :wq to save the file and quit.

ksho avatar Dec 20 '16 01:12 ksho

Works like a charm. Thanks guys

SimonSels avatar Dec 27 '16 11:12 SimonSels

perfect, thx a lot!

sspross avatar Jan 02 '17 11:01 sspross

Only worked with extra decipher.setAutoPadding(false) idk why

var audioAesKeyBuffer = new Buffer(audioAesKey, 'binary');
var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKeyBuffer, audioAesIv);
decipher.setAutoPadding(false);

igrek8 avatar Mar 29 '17 20:03 igrek8

Had the same issue, and it worked with

  var audioAesKeyBuffer = new Buffer(audioAesKey, 'binary');
  var decipher = crypto.createDecipheriv('aes-128-cbc', audioAesKeyBuffer, audioAesIv);
  decipher.setAutoPadding(false);

loretoparisi avatar May 19 '17 23:05 loretoparisi

Me too, experiencing this issue.

~$ airsonos
Searching for Sonos devices on network...

Family Room (@ 192.168.2.9:1400, RINCON_5CAxxxxx)

Search complete. Set up 1 device tunnel.
crypto.js:238
  this._handle.initiv(cipher, toBuf(key), toBuf(iv));
               ^

Error: Invalid key length
    at Error (native)
    at new Decipheriv (crypto.js:238:16)
    at Object.Decipheriv (crypto.js:235:12)
    at Object.decryptAudioData (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/helper.js:141:25)
    at RtpServer.<anonymous> (/usr/local/lib/node_modules/airsonos/node_modules/nodetunes/lib/rtp.js:32:23)
    at emitTwo (events.js:106:13)
    at Socket.emit (events.js:191:7)
    at UDP.onMessage (dgram.js:540:8)

This error is thrown as soon as I select the device in Preferences, Audio Output. MacOs Sierra 10.12.3

meglio avatar Sep 16 '17 13:09 meglio

Same as @meglio on macOS Sierra 10.12.6

mariogillazaro avatar Sep 19 '17 13:09 mariogillazaro