-
Notifications
You must be signed in to change notification settings - Fork 895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HD Key cleanup #27118
base: master
Are you sure you want to change the base?
HD Key cleanup #27118
Conversation
0082f8a
to
992733d
Compare
.cost = (size_t)*n, | ||
.block_size = (size_t)*r, | ||
.parallelization = (size_t)*p, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we also need checked_cast
for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should't CHECK here as this json is coming from user. There is also DeriveKeyScryptNoCheck
which intentionally just fails on invalid args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we checked above for iteration which is also from user input
a8e93dd
to
b5aed5e
Compare
[puLL-Merge] - brave/brave-core@27118 DescriptionThis PR makes significant changes to the Brave Wallet's key derivation and management system, focusing on improving the HDKey (Hierarchical Deterministic Key) implementation, adding support for JSON keystore parsing, and refactoring various keyring classes for better organization and efficiency. ChangesChanges
sequenceDiagram
participant User
participant KeyringService
participant JSONKeystoreParser
participant HDKey
participant Keyring
User->>KeyringService: Import account from JSON
KeyringService->>JSONKeystoreParser: Parse and decrypt keystore
JSONKeystoreParser-->>KeyringService: Return private key
KeyringService->>HDKey: Generate from private key
HDKey-->>KeyringService: Return HDKey
KeyringService->>Keyring: Import account
Keyring-->>KeyringService: Return imported account info
KeyringService-->>User: Return result
Possible Issues
Security Hotspots
|
std::vector<uint8_t> chain_code(ptr, ptr + 32); | ||
ptr += chain_code.size(); | ||
hdkey->SetChainCode(chain_code); | ||
reader.ReadU32BigEndian(reinterpret_cast<uint32_t&>(result->version)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] Using reinterpret_cast
against some data types may lead to undefined behaviour. In general, when needing to do these conversions, check how Chromium upstream does them. Most of the times a reinterpret_cast is wrong and there's no guarantee the compiler will generate the code that you thought it would.
Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/client/reinterpret_cast.yaml
Cc @stoletheminerals @thypon @cdesouza-chromium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem correct. What is the type of result->version
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum class ExtendedKeyVersion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use base::to_underlying
?
Resolves brave/brave-browser#43110
DerivationIndex
instead.ImportAccountFromJson
payload to separate file.Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: