Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Invalid key length error #316

Open
bjkeyser opened this issue Aug 20, 2016 · 25 comments
Open

Invalid key length error #316

bjkeyser opened this issue Aug 20, 2016 · 25 comments

Comments

@bjkeyser
Copy link

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)

@colinrioux
Copy link

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

@sboehler
Copy link

sboehler commented Aug 22, 2016

+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)

@ghost
Copy link

ghost commented Aug 23, 2016

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)

@martinchapman
Copy link

#302 + Nodetunes fix

@ghost
Copy link

ghost commented Aug 24, 2016

Yes! that solves the issue

@jonathanmmoore
Copy link

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

@yecine06
Copy link

yecine06 commented Sep 10, 2016

when ths fix will be available on airsonos ?

@rightisleft
Copy link

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

@discopolis
Copy link

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
Copy link

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

@anildigital
Copy link

+1

1 similar comment
@isidore
Copy link

isidore commented Oct 18, 2016

+1

@paddyriyer
Copy link

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

@isidore
Copy link

isidore commented Oct 24, 2016

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);

@naazy
Copy link

naazy commented Oct 26, 2016

Thanks @isidore this worked for me!

@JoeCotellese
Copy link

Worked for me too!

@psieyes
Copy link

psieyes commented Dec 4, 2016

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

@dabvid
Copy link

dabvid commented Dec 13, 2016

+1
Worked for me as well.

@ksho
Copy link

ksho commented Dec 20, 2016

@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.

@SimonSels
Copy link

Works like a charm. Thanks guys

@sspross
Copy link

sspross commented Jan 2, 2017

perfect, thx a lot!

@igrek8
Copy link

igrek8 commented Mar 29, 2017

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);

@nedjam nedjam mentioned this issue Apr 4, 2017
@loretoparisi
Copy link

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);

@meglio
Copy link

meglio commented Sep 16, 2017

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

@mariogillazaro
Copy link

Same as @meglio on macOS Sierra 10.12.6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests