Skip to content

Commit 38e1bd7

Browse files
committed
Remove blob_pool::generate_reference_tag and related tests
This change is part of the remaining work for project-tsurugi/tsurugi-issues#1337
1 parent 4f40aca commit 38e1bd7

4 files changed

Lines changed: 0 additions & 103 deletions

File tree

include/limestone/api/blob_pool.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,6 @@ class blob_pool {
9191
*/
9292
[[nodiscard]] virtual blob_id_type duplicate_data(blob_id_type reference) = 0;
9393

94-
/**
95-
* @brief generates a BLOB reference tag for access control.
96-
* @param blob_id the BLOB reference
97-
* @param transaction_id the transaction ID
98-
* @return the generated BLOB reference tag
99-
* @throws limestone_blob_exception if an internal error occurs during tag generation.
100-
* Possible reasons include:
101-
* - Environment issues (e.g., cryptographic library not initialized or misconfigured)
102-
* - Resource exhaustion (e.g., out of memory)
103-
* - Other unexpected internal errors
104-
* @note No validation is performed for blob_id or transaction_id values; any value is accepted.
105-
*/
106-
[[nodiscard]] virtual blob_reference_tag_type generate_reference_tag(
107-
blob_id_type blob_id,
108-
std::uint64_t transaction_id) = 0;
10994
};
11095

11196
} // namespace limestone::api

src/limestone/blob_pool_impl.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -341,40 +341,4 @@ blob_id_type blob_pool_impl::register_data(std::string_view data) {
341341
return id;
342342
}
343343

344-
blob_reference_tag_type blob_pool_impl::generate_reference_tag(
345-
blob_id_type blob_id,
346-
std::uint64_t transaction_id) {
347-
348-
// Prepare input data: concatenate blob_id and transaction_id using portable approach
349-
std::array<unsigned char, sizeof(blob_id_type) + sizeof(std::uint64_t)> input_bytes{};
350-
std::memcpy(input_bytes.data(), &blob_id, sizeof(blob_id_type));
351-
std::memcpy(input_bytes.data() + sizeof(blob_id_type), &transaction_id, sizeof(std::uint64_t));
352-
353-
// Get the secret key from datastore_impl
354-
const auto& secret_key = datastore_.get_impl()->get_hmac_secret_key();
355-
356-
// Clear OpenSSL error queue to avoid noise from previous API calls
357-
ERR_clear_error();
358-
359-
// Calculate HMAC-SHA256
360-
std::array<unsigned char, EVP_MAX_MD_SIZE> md{};
361-
unsigned int md_len = 0;
362-
363-
unsigned char* result = HMAC(EVP_sha256(),
364-
secret_key.data(),
365-
static_cast<int>(secret_key.size()),
366-
input_bytes.data(),
367-
input_bytes.size(),
368-
md.data(),
369-
&md_len);
370-
371-
this->handle_hmac_result(result);
372-
373-
// Use the first 8 bytes of the HMAC result as the tag
374-
blob_reference_tag_type tag = 0;
375-
std::memcpy(&tag, md.data(), sizeof(blob_reference_tag_type));
376-
377-
return tag;
378-
}
379-
380344
} // namespace limestone::internal

src/limestone/blob_pool_impl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ class blob_pool_impl : public blob_pool {
3333

3434
[[nodiscard]] blob_id_type duplicate_data(blob_id_type reference) override;
3535

36-
[[nodiscard]] blob_reference_tag_type generate_reference_tag(
37-
blob_id_type blob_id,
38-
std::uint64_t transaction_id) override;
3936

4037
protected:
4138
// These protected fields and methods include:

test/limestone/blob/blob_pool_impl_test.cpp

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,53 +1424,4 @@ TEST_F(blob_pool_impl_test, handle_hmac_result_with_failed_hmac_throws) {
14241424
}
14251425
}
14261426

1427-
1428-
1429-
TEST_F(blob_pool_impl_test, generate_reference_tag_deterministic_and_unique) {
1430-
blob_id_type blob_id1 = pool_->register_data("dummy1");
1431-
blob_id_type blob_id2 = pool_->register_data("dummy2");
1432-
std::uint64_t txid1 = 100;
1433-
std::uint64_t txid2 = 200;
1434-
1435-
// The same input yields the same tag
1436-
auto tag1a = pool_->generate_reference_tag(blob_id1, txid1);
1437-
auto tag1b = pool_->generate_reference_tag(blob_id1, txid1);
1438-
EXPECT_EQ(tag1a, tag1b);
1439-
1440-
// Different blob_id yields a different tag
1441-
auto tag2 = pool_->generate_reference_tag(blob_id2, txid1);
1442-
EXPECT_NE(tag1a, tag2);
1443-
1444-
// Different transaction_id yields a different tag
1445-
auto tag3 = pool_->generate_reference_tag(blob_id1, txid2);
1446-
EXPECT_NE(tag1a, tag3);
1447-
}
1448-
1449-
TEST_F(blob_pool_impl_test, generate_reference_tag_changes_after_datastore_restart) {
1450-
blob_id_type blob_id = pool_->register_data("dummy");
1451-
std::uint64_t txid = 12345;
1452-
auto tag_before = pool_->generate_reference_tag(blob_id, txid);
1453-
1454-
// Restart datastore
1455-
pool_.reset();
1456-
resolver_.reset();
1457-
datastore_->shutdown();
1458-
datastore_.reset();
1459-
1460-
// Create a new datastore/pool
1461-
std::vector<boost::filesystem::path> data_locations{base_directory};
1462-
boost::filesystem::path metadata_location_path{metadata_location};
1463-
limestone::api::configuration conf(data_locations, metadata_location_path);
1464-
datastore_ = std::make_unique<limestone::api::datastore>(conf);
1465-
resolver_ = std::make_unique<blob_file_resolver>(boost::filesystem::path(blob_directory));
1466-
pool_ = std::make_unique<testable_blob_pool_impl>(id_generator_, *resolver_, *datastore_);
1467-
1468-
auto tag_after = pool_->generate_reference_tag(blob_id, txid);
1469-
1470-
// The tag changes after datastore restart (because the HMAC secret key changes)
1471-
EXPECT_NE(tag_before, tag_after);
1472-
}
1473-
1474-
1475-
14761427
} // namespace limestone::testing

0 commit comments

Comments
 (0)