pohoc/crypto-sm
pohoc/crypto-sm is a PHP/Laravel package for working with SM cryptographic algorithms, offering helpers for encryption, hashing, and secure data handling. It provides a simple, framework-friendly API for integrating Chinese crypto standards into your applications.
Basis of assessment — No prior assessment and no dependency manifest or usage inventory were supplied. The evaluation below is driven entirely by the v0.3.0 release notes; stack, Laravel version, and PHP-extension assumptions are flagged as open questions rather than settled facts.
Architecture fit — This is a 国密 (SM2/SM3/SM4) cryptographic primitives package, not a general-purpose Laravel utility. Fit is therefore narrow and deliberate: it earns its place only where GB/T-derived algorithm compliance is a hard requirement (China-market deployments, 等保/密评 obligations, or counterparty mandates). Architecturally it belongs below the application layer — key management → this package → domain encryption — exposed through an internal adapter so domain code never binds directly to it. The v0.3.0 signal that matters most is that the project is pivoting from feature breadth to spec conformance: a critical GCM/GHASH correction plus formula-level GM/T vector anchoring is exactly the maturity curve you want to see before production adoption. It is still pre-1.0.
Integration feasibility — The two genuinely integration-unblocking additions are SM2 ciphertext ASN.1 and compressed public key import, because those are the formats real 国密 CA, HSM, and third-party gateways actually emit. SM4-CCM rounds out mode coverage. Remaining feasibility questions are mechanical: extension requirements (ext-gmp, ext-bcmath, ext-openssl with or without native SM support), whether the package publishes a service provider and config stub, whether it reads env() at runtime (breaks under config:cache), and whether the SM3 constant tables or backend detection introduce static state that is unsafe under Octane or long-lived queue workers.
Technical risk — Four items dominate:
feat! marker means every minor release is potentially breaking. Pin exactly; never use a caret range on 0.x.Key questions —
feat! marker a 1.0 removal schedule?Stack fit — Assumed Laravel 10/11 on PHP 8.2+. The package is algorithm-level, so integration should sit behind a first-party interface (CipherService / Sm2Signer style contracts) rather than being called inline. Confirm the service provider defers correctly, that configuration is publishable and cache-safe, and that key material is loaded from a KMS or secrets store rather than from .env directly.
Migration path — No prior assessment exists, so treat this as a greenfield adoption of 0.3.0 with a mandatory remediation track for any pre-existing 国密 data written by another implementation or an earlier version:
"vendor/package": "0.3.*" exactly.Do not assume tag compatibility across the GHASH fix. Assume the opposite and verify.
Compatibility — Validate against our full PHP matrix with and without native OpenSSL SM support to learn which backend gets selected on each host class. Confirm Laravel LTS coverage, and check whether the package's own test suite runs on our CI images — "benchmark backend detection alignment" strongly implies behaviour differs by environment, so CI-only validation is insufficient. Also verify the new deprecation notices do not collide with our error handler, log aggregation, or alerting thresholds.
Sequencing —
Maintenance — High-touch by nature. Pre-1.0 cryptographic dependencies require a standing upgrade cadence with human review of every release, not automated bumps. The feat! deprecation notices are the leading edge of a 1.0 cleanup: those APIs will be removed, so treat the notices as a work queue rather than noise. 93.94% coverage is respectable for a crypto library, but the untested remainder is unquantified risk concentrated in exactly the kind of edge cases that break cryptosystems.
Support — Release notes are terse and Chinese-only, with no CVE/CVSS identifiers and no referenced security policy. For a release that ships a critical authentication-tag fix, that is thin. Mitigations: establish a direct maintainer channel and request advance notice of security releases; designate one or two named owners internally; and document the cryptographic contract (algorithms, key sizes, IV/tag rules, mode choices) in a form usable for audit and 密评. The documentation work in this release — corrected performance figures, GM/T 0003.3 Appendix A worked examples — is a real improvement and should be treated as load-bearing for review and onboarding.
Scaling — Pure-PHP SM3/SM4 is orders of magnitude slower than AES-NI; plan capacity accordingly. The SM3 constant-table precomputation helps, and the backend-detection work implies an accelerated path is available on some hosts, but throughput must be measured on our own hardware before committing to in-process crypto at volume. Beyond raw speed, the scaling risk is IV discipline: GCM catastrophically fails under IV reuse, the benchmark scripts had exactly that bug, and concurrency across queue workers, Octane workers, and multi-node deployment is precisely where counter/RNG discipline erodes. Verify the production IV generation path explicitly and independently of the package's own tests.
Failure modes —
Ramp-up — Non-trivial. The team needs 国密 fundamentals (SM2 curve semantics, SM4 modes including the newly added CCM, SM3, and GM/T 0003.3 key exchange) on top of Laravel package wiring and key-management practice. Rough planning estimate: one to two weeks for a capable engineer to reach spike productivity, considerably longer for the organisation to build independent review capability — and independent review is mandatory here, because a team that cannot evaluate the GHASH class of defect also cannot tell whether the fix is complete. The newly archived GM/T 0003.3 Appendix A examples materially reduce this cost and should be the first thing a new owner reads.
How can I help you explore Laravel packages today?