[DICOM] Constrain cryptoHash output to the target VR's length and character repertoire - #268
Draft
Josiah Vinson (jovinson-ms) with Copilot wants to merge 3 commits into
Draft
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: jovinson-ms <88204686+jovinson-ms@users.noreply.github.com>
… docs Co-authored-by: jovinson-ms <88204686+jovinson-ms@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix crypto hash output to respect DICOM VR length limits
[DICOM] Constrain cryptoHash output to the target VR's length and character repertoire
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cryptoHashwrote the raw 64-character SHA-256 hex digest into string elements, which violates bounded VRs (e.g.SHallows 16 characters) and made output reconstruction fail withFellowOakDicom.DicomValidationExceptionfromDicomValidation.ValidateSH.{"tag": "PatientTelephoneNumbers", "method": "cryptohash"} // SHBefore:
2e7acefff0307262cef6f503fa7019257f3f9d47fc987fb2c5a31ae4f4d3c022(64 chars → validation error)After:
2e7acefff0307262(16 chars)Changes
CryptoHashProcessor: hashed string values are now conformed to the target VR before being written:DicomVR.MaximumLength(SH/AE/CS/DS→ 16,UI/LO/PN→ 64; VRs without a limit such asUC/UT/URkeep the full digest).ISis further capped at 9 digits so the value always fits a 32-bit signed integer.DS/IS/UI(leading zero avoided), uppercase forCS. Output stays deterministic for a given input, key and VR.AS/DA/DT/TM), anAnonymizerOperationExceptionis raised naming only the tag and VR. TheDicomValidationExceptionis deliberately not chained, since it embeds the offending content.AE,CS,DS,IS,SH,UI; explicitSH16-character boundary case; determinism andmatchInputStringLengthcases; fixed-format VR case asserting the source value does not appear in the message. TheDicomResults/Invalid-String-Format.dcmengine fixture was regenerated for the shorter outputs.docs/DICOM-anonymization.mddescribes the per-VR constraints, notes that truncation reduces collision resistance to the retained characters (64 bits for 16 hex chars), and points todateShift/redactforAS/DA/DT/TM.Notes for reviewers
cryptoHashoutput for bounded VRs differs from previous releases, so re-anonymizing the same source data produces different values than before.