microsoft / microsoft/Tools-for-Health-Data-Anonymization
[DICOM] Ensure crypto hash output respects DICOM VR length limits
- Dominant language
- C#
- Stars
- 309
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Summary
DICOM crypto hashing can generate values that exceed the target value representation’s maximum length.
When MatchInputStringLength = false, SHA-256 hashing produces a 64-character hex string. Writing that value to a tag with the SH value representation fails validation because SH permits at most 16 characters.
The pipeline throws:
FellowOakDicom.DicomValidationException
from:
FellowOakDicom.DicomValidation.ValidateSH
Reproduction
- Configure a DICOM anonymization rule to crypto-hash an
SHtag. - Set
MatchInputStringLength = false. - Process a DICOM containing the configured tag.
- Observe output reconstruction fail because the generated hash exceeds the
SHlength limit.
Expected behavior
The DICOM anonymizer should generate deterministic hash output that conforms
to the target tag’s value representation, including its maximum length.
Acceptance criteria
- Constrain generated values to the target DICOM VR’s maximum length.
- Preserve deterministic hashing.
- Avoid truncation strategies that materially weaken collision resistance
without documenting the tradeoff. - Add tests for
SHvalues, including its 16-character boundary. - Add coverage for other bounded string VRs used by crypto-hash rules.
- Return a clear anonymizer error if a conformant value cannot be generated.
- Do not include source DICOM values in logs or exceptions.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.