diff --git a/components/brave_sync/crypto/crypto.cc b/components/brave_sync/crypto/crypto.cc index d4aa715234c3..fb1ff974e7ab 100644 --- a/components/brave_sync/crypto/crypto.cc +++ b/components/brave_sync/crypto/crypto.cc @@ -39,13 +39,14 @@ std::vector HKDFSha512(const std::vector& ikm, void DeriveSigningKeysFromSeed(const std::vector& seed, const std::vector* salt, + const std::vector* info, std::vector* public_key, std::vector* private_key) { DCHECK(public_key); DCHECK(private_key); - const std::vector info = {0}; + DCHECK(info); std::vector output = - HKDFSha512(seed, salt, &info, DEFAULT_SEED_SIZE); + HKDFSha512(seed, salt, info, DEFAULT_SEED_SIZE); public_key->resize(ED25519_PUBLIC_KEY_LEN); private_key->resize(ED25519_PRIVATE_KEY_LEN); ED25519_keypair_from_seed(public_key->data(), private_key->data(), diff --git a/components/brave_sync/crypto/crypto.h b/components/brave_sync/crypto/crypto.h index ca906146486b..aca58da3f90f 100644 --- a/components/brave_sync/crypto/crypto.h +++ b/components/brave_sync/crypto/crypto.h @@ -26,6 +26,7 @@ std::vector HKDFSha512(const std::vector& ikm, // Derives an Ed25519 keypair given a random seed and an optional HKDF salt void DeriveSigningKeysFromSeed(const std::vector& seed, const std::vector* salt, + const std::vector* info, std::vector* public_key, std::vector* private_key); diff --git a/components/brave_sync/crypto/crypto_unittest.cc b/components/brave_sync/crypto/crypto_unittest.cc index f4516eb4cda7..0c50cd7bfc0d 100644 --- a/components/brave_sync/crypto/crypto_unittest.cc +++ b/components/brave_sync/crypto/crypto_unittest.cc @@ -134,7 +134,8 @@ TEST(CryptoTest, Ed25519KeyDerivation) { &seed); std::vector public_key = {}; std::vector private_key = {}; - DeriveSigningKeysFromSeed(seed, &HKDF_SALT, &public_key, &private_key); + std::vector info = {0}; + DeriveSigningKeysFromSeed(seed, &HKDF_SALT, &info, &public_key, &private_key); EXPECT_EQ("f58ca446f0c33ee7e8e9874466da442b2e764afd77ad46034bdff9e01f9b87d4", base::ToLowerASCII( base::HexEncode(public_key.data(), public_key.size()))); diff --git a/components/sync/driver/brave_sync_auth_manager.cc b/components/sync/driver/brave_sync_auth_manager.cc index c500a08e8c64..75b1a38900da 100644 --- a/components/sync/driver/brave_sync_auth_manager.cc +++ b/components/sync/driver/brave_sync_auth_manager.cc @@ -34,7 +34,9 @@ void BraveSyncAuthManager::DeriveSigningKeys(const std::string& seed) { 212, 239, 225, 52, 192, 219, 145, 40, 95, 19, 142, 98}; std::vector seed_bytes; brave_sync::crypto::PassphraseToBytes32(seed, &seed_bytes); - brave_sync::crypto::DeriveSigningKeysFromSeed(seed_bytes, &HKDF_SALT, + const std::string info_str = "sync-auth-key"; + std::vector info(info_str.begin(), info_str.end()); + brave_sync::crypto::DeriveSigningKeysFromSeed(seed_bytes, &HKDF_SALT, &info, &public_key_, &private_key_); if (registered_for_auth_notifications_) UpdateSyncAccountIfNecessary(); diff --git a/components/sync/driver/brave_sync_auth_manager_unittest.cc b/components/sync/driver/brave_sync_auth_manager_unittest.cc index 78fe480f28f9..3a74518ba7af 100644 --- a/components/sync/driver/brave_sync_auth_manager_unittest.cc +++ b/components/sync/driver/brave_sync_auth_manager_unittest.cc @@ -27,13 +27,13 @@ const char kSyncCode[] = "proud cabbage fee slow economy wage final fox cancel"; const char kAccessToken[] = - "MzEzMjMzMzQzNTM2Mzd8RDM0NDYyREVBNzAwQzg0QkVDNjEzMTlCRTk3QTMwOENGMzI2ODM2RD" - "UxM0Y1QjJCODU5RkM3RkU1REJGQjNDQTI2OTFCN0JCODA5NDM5NTgwQzQxNzlCQzYwQzk5Njk5" - "OTdEREMwRTIyRkU1NzQ2ODFFNUQ2QzIyNjkxM0M3MDJ8Rjk5NzNBNzdDQTlDRTRENzhGNDU2ND" - "kwMjUwMEM5NjY3NEQxOEU2QTM3QUU3NjJGODUzRUM5RkZGRDIyNzU1OQ=="; + "MzEzMjMzMzQzNTM2Mzd8MDBGNkExNjgxODkxQzU5RDZGMEYwNkVDQ0VGQzBFMTQ3QjA2NDE2RD" + "EzNzE0QkQ3MzE3ODJGRjE1NUZFNjMxMTNBNTE2Qzk2NTFFM0ZGQTEyRDhDMzcyQTcyNUZEMzZG" + "RjE3QUIxMDRDNDVBNTcyMDVCRkIwNjUwRjgxQ0MyMDl8NTAyMDQyMjcwQzgxNDUyNDdFRDcwQT" + "E4Rjg3MDIyQTM5ODg2OTAwQUIzNkYyRkZGNjU1NjM1REJFNTE2NzY1RQ=="; const char kAccountId[] = - "F9973A77CA9CE4D78F4564902500C96674D18E6A37AE762F853EC9FFFD227559"; + "502042270C8145247ED70A18F87022A39886900AB36F2FFF655635DBE516765E"; class BraveSyncAuthManagerTest : public testing::Test { protected: