Skip to content

fix:fix UserChoice Hash algorithm#2

Open
k1988 wants to merge 1 commit into
cssxn:mainfrom
k1988:main
Open

fix:fix UserChoice Hash algorithm#2
k1988 wants to merge 1 commit into
cssxn:mainfrom
k1988:main

Conversation

@k1988
Copy link
Copy Markdown

@k1988 k1988 commented May 9, 2026

detail: The original code used the 7D60 token-encoding pipeline for BOTH UserChoiceLatest and UserChoice registry keys. But
SFTA.ps1 implements UserChoice with a simpler algorithm (no token encoding, different canonical input format,
minute-rounded timestamp).

Files modified

HashCommon.h — Added FILETIME last_write_raw to AssocContext + ComputeHashUserChoice() declaration.

HashCodec.cpp — Added ComputeHashUserChoice() implementing the SFTA.ps1 algorithm:

  • UTF-16LE encode canonical input + null terminator
  • MD5 directly on raw bytes (no token encoding)
  • Same MixA/MixB/XOR/Base64 core (reuses existing functions, same seeds)

RegistryContext.cpp — Three additions:

  1. kUserExperience constant matching SFTA.ps1's experience string
  2. FormatTimestampHexMinuteRounded() — rounds FILETIME to minute precision (SFTA.ps1 Get-HexDateTime rounds seconds to 0)
  3. BuildCanonicalInputUserChoice() — fixed-format canonical string: assoc + sid + progid + timestamp + experience
  4. VerifyCurrentAssociation() now branches: UserChoiceLatest → 7D60 pipeline, UserChoice → SFTA.ps1-compatible algorithm
  5. LoadAssociationContext() stores raw FILETIME and uses minute-rounded timestamp for UserChoice key

detail: The original code used the 7D60 token-encoding pipeline for BOTH UserChoiceLatest and UserChoice registry keys. But
  SFTA.ps1 implements UserChoice with a simpler algorithm (no token encoding, different canonical input format,
  minute-rounded timestamp).

  Files modified

  HashCommon.h — Added FILETIME last_write_raw to AssocContext + ComputeHashUserChoice() declaration.

  HashCodec.cpp — Added ComputeHashUserChoice() implementing the SFTA.ps1 algorithm:
  - UTF-16LE encode canonical input + null terminator
  - MD5 directly on raw bytes (no token encoding)
  - Same MixA/MixB/XOR/Base64 core (reuses existing functions, same seeds)

  RegistryContext.cpp — Three additions:
  1. kUserExperience constant matching SFTA.ps1's experience string
  2. FormatTimestampHexMinuteRounded() — rounds FILETIME to minute precision (SFTA.ps1 Get-HexDateTime rounds seconds to
   0)
  3. BuildCanonicalInputUserChoice() — fixed-format canonical string: assoc + sid + progid + timestamp + experience
  4. VerifyCurrentAssociation() now branches: UserChoiceLatest → 7D60 pipeline, UserChoice → SFTA.ps1-compatible
  algorithm
  5. LoadAssociationContext() stores raw FILETIME and uses minute-rounded timestamp for UserChoice key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant