@ -2750,19 +2750,10 @@ void CipherBase::Update(const FunctionCallbackInfo<Value>& args) {
// Only copy the data if we have to, because it's a string
if ( args [ 0 ] - > IsString ( ) ) {
Local < String > string = args [ 0 ] . As < String > ( ) ;
enum encoding encoding = ParseEncoding ( env - > isolate ( ) , args [ 1 ] , BINARY ) ;
if ( ! StringBytes : : IsValidString ( env - > isolate ( ) , string , encoding ) )
return env - > ThrowTypeError ( " Bad input string " ) ;
size_t buflen = StringBytes : : StorageSize ( env - > isolate ( ) , string , encoding ) ;
char * buf = new char [ buflen ] ;
size_t written = StringBytes : : Write ( env - > isolate ( ) ,
buf ,
buflen ,
string ,
encoding ) ;
r = cipher - > Update ( buf , written , & out , & out_len ) ;
delete [ ] buf ;
StringBytes : : InlineDecoder decoder ;
if ( ! decoder . Decode ( env , args [ 0 ] . As < String > ( ) , args [ 1 ] , BINARY ) )
return ;
r = cipher - > Update ( decoder . out ( ) , decoder . size ( ) , & out , & out_len ) ;
} else {
char * buf = Buffer : : Data ( args [ 0 ] ) ;
size_t buflen = Buffer : : Length ( args [ 0 ] ) ;
@ -2929,19 +2920,10 @@ void Hmac::HmacUpdate(const FunctionCallbackInfo<Value>& args) {
// Only copy the data if we have to, because it's a string
bool r ;
if ( args [ 0 ] - > IsString ( ) ) {
Local < String > string = args [ 0 ] . As < String > ( ) ;
enum encoding encoding = ParseEncoding ( env - > isolate ( ) , args [ 1 ] , BINARY ) ;
if ( ! StringBytes : : IsValidString ( env - > isolate ( ) , string , encoding ) )
return env - > ThrowTypeError ( " Bad input string " ) ;
size_t buflen = StringBytes : : StorageSize ( env - > isolate ( ) , string , encoding ) ;
char * buf = new char [ buflen ] ;
size_t written = StringBytes : : Write ( env - > isolate ( ) ,
buf ,
buflen ,
string ,
encoding ) ;
r = hmac - > HmacUpdate ( buf , written ) ;
delete [ ] buf ;
StringBytes : : InlineDecoder decoder ;
if ( ! decoder . Decode ( env , args [ 0 ] . As < String > ( ) , args [ 1 ] , BINARY ) )
return ;
r = hmac - > HmacUpdate ( decoder . out ( ) , decoder . size ( ) ) ;
} else {
char * buf = Buffer : : Data ( args [ 0 ] ) ;
size_t buflen = Buffer : : Length ( args [ 0 ] ) ;
@ -3053,19 +3035,10 @@ void Hash::HashUpdate(const FunctionCallbackInfo<Value>& args) {
// Only copy the data if we have to, because it's a string
bool r ;
if ( args [ 0 ] - > IsString ( ) ) {
Local < String > string = args [ 0 ] . As < String > ( ) ;
enum encoding encoding = ParseEncoding ( env - > isolate ( ) , args [ 1 ] , BINARY ) ;
if ( ! StringBytes : : IsValidString ( env - > isolate ( ) , string , encoding ) )
return env - > ThrowTypeError ( " Bad input string " ) ;
size_t buflen = StringBytes : : StorageSize ( env - > isolate ( ) , string , encoding ) ;
char * buf = new char [ buflen ] ;
size_t written = StringBytes : : Write ( env - > isolate ( ) ,
buf ,
buflen ,
string ,
encoding ) ;
r = hash - > HashUpdate ( buf , written ) ;
delete [ ] buf ;
StringBytes : : InlineDecoder decoder ;
if ( ! decoder . Decode ( env , args [ 0 ] . As < String > ( ) , args [ 1 ] , BINARY ) )
return ;
r = hash - > HashUpdate ( decoder . out ( ) , decoder . size ( ) ) ;
} else {
char * buf = Buffer : : Data ( args [ 0 ] ) ;
size_t buflen = Buffer : : Length ( args [ 0 ] ) ;
@ -3214,19 +3187,10 @@ void Sign::SignUpdate(const FunctionCallbackInfo<Value>& args) {
// Only copy the data if we have to, because it's a string
Error err ;
if ( args [ 0 ] - > IsString ( ) ) {
Local < String > string = args [ 0 ] . As < String > ( ) ;
enum encoding encoding = ParseEncoding ( env - > isolate ( ) , args [ 1 ] , BINARY ) ;
if ( ! StringBytes : : IsValidString ( env - > isolate ( ) , string , encoding ) )
return env - > ThrowTypeError ( " Bad input string " ) ;
size_t buflen = StringBytes : : StorageSize ( env - > isolate ( ) , string , encoding ) ;
char * buf = new char [ buflen ] ;
size_t written = StringBytes : : Write ( env - > isolate ( ) ,
buf ,
buflen ,
string ,
encoding ) ;
err = sign - > SignUpdate ( buf , written ) ;
delete [ ] buf ;
StringBytes : : InlineDecoder decoder ;
if ( ! decoder . Decode ( env , args [ 0 ] . As < String > ( ) , args [ 1 ] , BINARY ) )
return ;
err = sign - > SignUpdate ( decoder . out ( ) , decoder . size ( ) ) ;
} else {
char * buf = Buffer : : Data ( args [ 0 ] ) ;
size_t buflen = Buffer : : Length ( args [ 0 ] ) ;
@ -3395,19 +3359,10 @@ void Verify::VerifyUpdate(const FunctionCallbackInfo<Value>& args) {
// Only copy the data if we have to, because it's a string
Error err ;
if ( args [ 0 ] - > IsString ( ) ) {
Local < String > string = args [ 0 ] . As < String > ( ) ;
enum encoding encoding = ParseEncoding ( env - > isolate ( ) , args [ 1 ] , BINARY ) ;
if ( ! StringBytes : : IsValidString ( env - > isolate ( ) , string , encoding ) )
return env - > ThrowTypeError ( " Bad input string " ) ;
size_t buflen = StringBytes : : StorageSize ( env - > isolate ( ) , string , encoding ) ;
char * buf = new char [ buflen ] ;
size_t written = StringBytes : : Write ( env - > isolate ( ) ,
buf ,
buflen ,
string ,
encoding ) ;
err = verify - > VerifyUpdate ( buf , written ) ;
delete [ ] buf ;
StringBytes : : InlineDecoder decoder ;
if ( ! decoder . Decode ( env , args [ 0 ] . As < String > ( ) , args [ 1 ] , BINARY ) )
return ;
err = verify - > VerifyUpdate ( decoder . out ( ) , decoder . size ( ) ) ;
} else {
char * buf = Buffer : : Data ( args [ 0 ] ) ;
size_t buflen = Buffer : : Length ( args [ 0 ] ) ;