Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Crypto Sm Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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:

  • Legacy ciphertext incompatibility (highest). The critical fix states GCM GHASH domain mixing produced authentication tags non-conformant with RFC 8998. Anything encrypted and tagged under ≤v0.2.x must be presumed at risk of failing verification after upgrade. This is a data-migration exposure, not merely a code upgrade.
  • Version discipline. 0.x semver plus an explicit feat! marker means every minor release is potentially breaking. Pin exactly; never use a caret range on 0.x.
  • Security process maturity. A critical cryptographic defect was corrected in a minor release with no CVE identifier, no CVSS, and no referenced disclosure policy. In isolation that is tolerable for a pre-1.0 package; as a pattern it means we cannot rely on upstream to surface severity for us.
  • Unassessed side-channel posture. 93.94% coverage and 80 new exception-branch tests demonstrate correctness discipline, not constant-time behaviour, memory zeroization, or RNG quality. None of those are mentioned. Notably, an IV-reuse bug was found and fixed in the benchmark scripts — that raises a direct question about the production IV generation path.

Key questions —

  1. Is this package a thin Laravel wrapper over an upstream core library, or the implementation itself? This determines who owns CVE response and whether the GHASH class of bug is fixed once or twice.
  2. Which backends exist, how is selection performed, and does the package fail closed if the expected backend is absent or misdetected?
  3. What is the exact list of APIs carrying the new runtime deprecation notices from v0.3.0, and do we touch any of them?
  4. Is there a published security policy, disclosure channel, or advisory history?
  5. Which GM/T vectors are now asserted, and do they cover every SM2 key-exchange mode and SM4 mode we intend to use?
  6. Is there any third-party audit or 密评-relevant attestation, now or on the roadmap to 1.0?
  7. What is the stated upgrade contract from 0.x to 1.0, and is the feat! marker a 1.0 removal schedule?

Integration Approach

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:

  1. Pin "vendor/package": "0.3.*" exactly.
  2. Inventory all stored SM4-GCM ciphertext and tags, including data written by systems we are replacing.
  3. Run a reconciliation job that decrypts under the old path, re-encrypts under 0.3.0 with freshly generated IVs, and records a per-record result.
  4. Only after the reconciliation is green, remove the legacy code path.

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 —

  1. Sandbox spike — install, publish config, run the GM/T conformance suite per target host class (not just CI).
  2. Interop spike — SM2 ASN.1 ciphertext and compressed public key round-trip against the actual counterparty CA/gateway. This is the gate for the whole initiative.
  3. Performance benchmark — SM3/SM4 throughput on our real hardware; decide in-process vs. HSM/KMS offload.
  4. Ciphertext reconciliation — inventory and re-encrypt legacy GCM data.
  5. Integration — wire behind internal adapters; no direct package references in domain code.
  6. Deprecation capture — enable notices in staging, enumerate the list, map to our call sites, and remove those usages now rather than at 1.0.

Operational Impact

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 —

  • Post-upgrade tag verification failures on legacy data — the primary risk introduced by this release; mitigated only by the reconciliation job.
  • Backend misdetection — silent fallback to a slower or differently-behaving implementation. Assert conformance at boot rather than trusting detection.
  • Fail-open errors — with 80 new exception-branch tests the paths are covered, but coverage does not prove that errors never yield plaintext, an empty tag, or a bypassed verification. Test this adversarially.
  • Key material leakage — config cache exposure, debug pages, or log lines carrying key bytes or derived material.
  • Long-lived worker state — stale constant tables or cached backend selection after a deploy.
  • Alert fatigue — the new runtime deprecation notices will fire in production logs and can mask genuine warnings unless routed deliberately.

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums