← Back to Pull requests

Add sm3{,-yescrypt} backend and tests. #206

Merged
besser82 merged 39 files (3033 lines) on Mar 17, 2025 15:52 UTC
View on GitHub
besser82 besser82 commented on Feb 14, 2025 11:29 UTC
Author

These hashing methods are useful in applications that need modern password hashing methods, but require to rely on cryptographic properties that have been approved by the Chinese Office of State Commercial Cryptography Administration (OSCCA).

ShangMi 3 is a cryptographic hash function used in the Chinese National Standard. It was published by the National Cryptography Administration (Chinese: 国家密码管理局) on 2010-12-17 as "GM/T 0004-2012: SM3 cryptographic hash algorithm".

SM3 is used for implementing digital signatures, message authentication codes, and pseudorandom number generators. The algorithm is public and is considered similar to SHA-256 in security and efficiency. SM3 is also used with Transport Layer Security.

SM3 is defined in each of:
GM/T 0004-2012: SM3 cryptographic hash algorithm
GB/T 32905-2016: Information security techniques SM3 cryptographic hash algorithm
ISO/IEC 10118-3:2018: IT Security techniques—Hash-functions, Part 3: Dedicated hash-functions
IETF RFC draft-sca-cfrg-sm3-02

See: https://datatracker.ietf.org/doc/html/draft-sca-cfrg-sm3

sm3crypt is currently in active use by the EulerOS, Kylin, openEuler, and openKylin distributions.

The additionally - in hope of adaption by the afore mentioned distributions - implemented sm3-yescrypt uses the output from the yescrypt hashing method in place of a hmac message. Thus, the yescrypt crypto properties are superseeded by the ShangMi 3 hash function with a 256 bit digest.

Fixes #188.

Diff: 3033 lines (+2893 / -140) across 39 files Reviewer: solardiz Review duration: 44902m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.72) × (1 − Review Confidence (0.77)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.72 · 3033 lines diff across 39 files
0.72
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.56 · 2 substantive comment(s)
0.56
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
77%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Mass File Touch mass_file_touch
0.080
Real PR Conversation Timeline
2 comments
doc/crypt.5
"I think we should use the `Acceptable for new hashes where required.` wording also for `sm3crypt`, do not omit the ` where required` part here."
clarifying weight: 0.45
doc/crypt.5
"Thanks for the feedback! Fixed in rebased commit."
clarifying weight: 0.45
Reviewers
Assignees
besser82 besser82
Labels
risk: low confidence: 77.3% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 71.5% (HIGH) · Higher = larger blast radius
71.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 77.3% · Lower = rushed or shallow review
77.3%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 16.2% · Safe to merge
16.2%