Crypto update should only accept strings / buffers
authorFelix Geisendörfer <felix@debuggable.com>
Mon, 14 Mar 2011 10:16:35 +0000 (11:16 +0100)
committerRyan Dahl <ry@tinyclouds.org>
Mon, 14 Mar 2011 20:16:31 +0000 (13:16 -0700)
commit9d4c5a12f499fd59156e16efce17f019e16708d8
tree13a659b9402f6fb296d93afe601431728c97c4e7
parent2a05fe784d1c7ced3cee11e0d9e066b3bb0f361e
Crypto update should only accept strings / buffers

I have seen a lot of people trying to pass objects to crypto's update
functions, assuming that it would somehow serialize the object before
hashing.

In reality, the object was converted to '[object Object]' which was
then hashed, without any error message showing.

This patch modifies the DecodeBytes function (used exclusively by
crypto at this point) to complain when receiving anything but a
string or buffer.

Overall this should be a less-suprising, more robust behavior.
src/node_crypto.cc
test/simple/test-crypto.js