@@ -483,15 +483,16 @@ bool ECDHBitsTraits::DeriveBits(Environment* env,
483483 const auto pub = ECKeyPointer::GetPublicKey (public_key);
484484 int field_size = EC_GROUP_get_degree (group);
485485 len = (field_size + 7 ) / 8 ;
486- ByteSource::Builder buf (len);
486+ auto buf = DataPointer::Alloc (len);
487487 CHECK_NOT_NULL (pub);
488488 CHECK_NOT_NULL (private_key);
489- if (ECDH_compute_key (buf.data <char >(), len, pub, private_key, nullptr ) <=
489+ if (ECDH_compute_key (
490+ static_cast <char *>(buf.get ()), len, pub, private_key, nullptr ) <=
490491 0 ) {
491492 return false ;
492493 }
493494
494- *out = std::move (buf) .release ();
495+ *out = ByteSource::Allocated (buf.release () );
495496 }
496497 }
497498
@@ -605,14 +606,19 @@ WebCryptoKeyExportStatus EC_Raw_Export(const KeyObjectData& key_data,
605606 size_t len = EC_POINT_point2oct (group, point, form, nullptr , 0 , nullptr );
606607 if (len == 0 )
607608 return WebCryptoKeyExportStatus::FAILED;
608- ByteSource::Builder data (len);
609- size_t check_len = EC_POINT_point2oct (
610- group, point, form, data.data <unsigned char >(), len, nullptr );
609+ auto data = DataPointer::Alloc (len);
610+ size_t check_len =
611+ EC_POINT_point2oct (group,
612+ point,
613+ form,
614+ static_cast <unsigned char *>(data.get ()),
615+ len,
616+ nullptr );
611617 if (check_len == 0 )
612618 return WebCryptoKeyExportStatus::FAILED;
613619
614620 CHECK_EQ (len, check_len);
615- *out = std::move (data) .release ();
621+ *out = ByteSource::Allocated (data.release () );
616622 }
617623
618624 return WebCryptoKeyExportStatus::OK;
@@ -660,15 +666,20 @@ WebCryptoKeyExportStatus ECKeyExportTraits::DoExport(
660666 const size_t need =
661667 EC_POINT_point2oct (group, point, form, nullptr , 0 , nullptr );
662668 if (need == 0 ) return WebCryptoKeyExportStatus::FAILED;
663- ByteSource::Builder data (need);
664- const size_t have = EC_POINT_point2oct (
665- group, point, form, data.data <unsigned char >(), need, nullptr );
669+ auto data = DataPointer::Alloc (need);
670+ const size_t have =
671+ EC_POINT_point2oct (group,
672+ point,
673+ form,
674+ static_cast <unsigned char *>(data.get ()),
675+ need,
676+ nullptr );
666677 if (have == 0 ) return WebCryptoKeyExportStatus::FAILED;
667678 auto ec = ECKeyPointer::New (group);
668679 CHECK (ec);
669680 auto uncompressed = ECPointPointer::New (group);
670681 ncrypto::Buffer<const unsigned char > buffer{
671- .data = data. data <unsigned char >( ),
682+ .data = static_cast <unsigned char *>(data. get () ),
672683 .len = data.size (),
673684 };
674685 CHECK (uncompressed.setFromBuffer (buffer, group));
0 commit comments