components/on_device_translation: Migrate to new crypto/hash APIs
MERGED2026components/on_device_translationrefactor
2026. 8. 15.
ch123song
components/on_device_translation 디렉토리 내 crypto/sha2.h 를 crypto/hash.h 로 마이그레이션했습니다.
문제 설명
- components/on_device_translation 디렉토리 내 crypto/sha2.h 헤더를 crypto/hash.h로 교체
- SHA-256 해시값의 크기를 std::array의 타입에 명시하여 별도의 static_assert 제거
해결 내용
- components/on_device_translation/DEPS 수정
include_rules = [
- "+crypto/sha2.h",
+ "+crypto/hash.h",
"+mojo/public/cpp/bindings",
"+mojo/public/cpp/system",
"+components/prefs",- components/on_device_translation/constants.h 수정
+#include <array>
#include <cstdint>
-#include <iterator>
-#include "crypto/sha2.h"
+#include "crypto/hash.h"
namespace component_updater {
// The SHA256 of the SubjectPublicKeyInfo used to sign the component.
// The component id is: lbimbicckdokpoicboneldipejkhjgdg
-extern const uint8_t kTranslateKitPublicKeySHA256[32];
+extern const std::array<uint8_t, crypto::hash::kSha256Size>
+ kTranslateKitPublicKeySHA256;
} // namespace component_updater
-static_assert(std::size(component_updater::kTranslateKitPublicKeySHA256) ==
- crypto::kSHA256Length,
- "Wrong hash length");
namespace on_device_translation {- components/on_device_translation/constants.cc 수정
+#include "components/on_device_translation/constants.h"
+
#include <cstddef>
#include <cstdint>
namespace component_updater {
// The SHA256 of the SubjectPublicKeyInfo used to sign the component.
// The component id is: lbimbicckdokpoicboneldipejkhjgdg
-extern const uint8_t kTranslateKitPublicKeySHA256[32] = {
- 0xb1, 0x8c, 0x18, 0x22, 0xa3, 0xea, 0xfe, 0x82, 0x1e, 0xd4, 0xb3,
- 0x8f, 0x49, 0xa7, 0x96, 0x36, 0x55, 0xf3, 0xbc, 0x0d, 0xa5, 0x67,
- 0x48, 0x09, 0xcd, 0x7b, 0xa9, 0x5f, 0xd8, 0x7f, 0x53, 0xb4};
+constexpr std::array<uint8_t, crypto::hash::kSha256Size>
+ kTranslateKitPublicKeySHA256 = {
+ 0xb1, 0x8c, 0x18, 0x22, 0xa3, 0xea, 0xfe, 0x82, 0x1e, 0xd4, 0xb3,
+ 0x8f, 0x49, 0xa7, 0x96, 0x36, 0x55, 0xf3, 0xbc, 0x0d, 0xa5, 0x67,
+ 0x48, 0x09, 0xcd, 0x7b, 0xa9, 0x5f, 0xd8, 0x7f, 0x53, 0xb4};
} // namespace component_updater
namespace on_device_translation {테스트 방법
autoninja -C out/Default chrome 빌드 성공
배운 점
git cl format을 사용해 formatting 하기- 리뷰 대응하는 법에 대해 배울 수 있었습니다.