Skip to content

Update SMIMETest.java - #2371

Open
cragkhit wants to merge 4128 commits into
bcgit:mainfrom
cragkhit:matcha-update-smime-array-comparison
Open

Update SMIMETest.java#2371
cragkhit wants to merge 4128 commits into
bcgit:mainfrom
cragkhit:matcha-update-smime-array-comparison

Conversation

@cragkhit

@cragkhit cragkhit commented Jul 22, 2026

Copy link
Copy Markdown

Hi. We are researchers from Mahidol University, Thailand, and the State University of Ceará, Brazil, working on a research project for improving open-source projects by using the latest accepted answer from Stack Overflow that matched your code snippet. We found this recommendation for improving your code from https://stackoverflow.com/a/40056844.

Note: Our study is approved by the Institutional Review Board of Mahidol University. You can find the participant information sheet explaining this study https://drive.google.com/file/d/1ml5AqrtWQ9pnifTQyTFTcWQmwp6RuPA7/view?usp=sharing.

Disclosure: This contribution was prepared with assistance from OpenAI Codex. I reviewed and verified the resulting change.


Proposed change

Added identity and null checks before comparing the byte arrays.

Testing

./gradlew :util:compileTestJava :util:test

Result: Passed

dghgit and others added 30 commits June 27, 2026 16:01
- improve attribute validation and prepare for more
EthereumIESEngine: close static-key stream-mode cross-message MAC forgery

See merge request root/bc-java!237
ArmoredOutputStream / PemWriter: reject CR/LF in header name/value (header injection)

See merge request root/bc-java!232
MLS SecureRandom hygiene: source from the Group / registrar, never `new SecureRandom()` per operation

See merge request root/bc-java!212
GF(2^8) / GF(2^4) arithmetic consolidation onto constant-time util.GF256 / util.GF16

See merge request root/bc-java!215
EAX / CCM / OCB / KCCM: reject nonce reuse on re-init for encryption

See merge request root/bc-java!226
AIMer

See merge request root/bc-java!133
ElGamalEngine: validate ciphertext components on decryption (small-subgroup confinement)

See merge request root/bc-java!236
Fix `PKIXCertPathReviewer.getPolicyTree()` always returning `null`

See merge request root/bc-java!217
…nstraints per RFC 5280 sec. 4.2.1.10, relates to github bcgit#2331.
RFC 8702 — SHAKE in CMS: KMAC-with-SHAKE support

See merge request root/bc-java!185
dghgit and others added 28 commits July 16, 2026 07:47
…dule so examples compile and smoke-test under CI without shipping in the bc jars
… configurable node limit (org.bouncycastle.x509.max_cert_path_build_nodes)
…e *Test classes from the bcprov copy, and relocate OwlUtilTest to its own AllTests so it builds under bctest
…jar junit test-sweeping OSGi gotcha in docs/claude/build-jdk14.md
…aging to avoid the OwlUtilTest bcprov signer-info clash, matching the lms/mayo/est/keybox pattern
…09CRLEntryObject/RFC3280/X509CertificateObject/BaseBlockCipher, new PQC KeyPairGeneratorSpi overlays with NoSuchProviderException catch, SM2Signer/Utils), the Falcon FPREngine JLS2 forward-reference fix, and drop the KEM cipher families so bcprov-jdk13 compiles clean
…ed NPE/AIOOBE

Consolidates the empty/missing-content parser-robustness fixes into one review unit.
Each entry point converts an unchecked runtime exception (NullPointerException,
ArrayIndexOutOfBoundsException, IllegalStateException or ArithmeticException) that
escaped on empty / content-less / truncated / out-of-range input into the checked
exception it already declares; the malformed input is rejected either way, only the
leaked exception type is corrected. Well-formed input is unaffected.

Parse entry points:
  tsp.cms.CMSTimeStampedData (+ asn1.cms.MetaData, tsp.cms.TimeStampDataUtil)
  cms.CMSEnvelopedData (EnvelopedData with no encryptedContent)
  tsp.TimeStampToken (SignerInfo carrying no signed attributes)
  tsp.TimeStampRequest, tsp.TimeStampResponse (empty/truncated stream)
  cert.cmp.GeneralPKIMessage, est.CSRAttributesResponse, cmc.SimplePKIResponse,
  openssl.X509TrustedCertificateBlock, pkcs.PKCS12PfxPdu,
  pkcs.PKCS8EncryptedPrivateKeyInfo (empty / no-content input)
  cert.crmf.CertificateRequestMessage.hasSigningKeyProofOfPossessionWithPKMAC
  crypto.util.OpenSSHPrivateKeyUtil.parsePrivateKeyBlob, math.ec.ECCurve.decodePoint

PKIX revocation reporting (attacker-controlled CRL/OCSP fields):
  pkix.jcajce.PKIXCertPathReviewer, pkix.jcajce.X509RevocationChecker
    (out-of-range CRLReason index against the fixed reason table)
  jce.provider.RFC3280CertPathUtilities (absent CRL distribution-point reasons mask)
  jce.provider.ProvOcspRevocationChecker (OCSP response with no nonce extension)

Audit findings F16, F23, F24, F26, F28, F29, F30, F32, F52 plus the
parse-empty-input-null-guards, tsp-empty-stream-parse-guard and
crl-reasoncode-crlreasons-aioobe branches.
…ith destroy() throws DestroyFailedException resolved via the jce/src backport on the build-lw classpath, plus jdk14-parity cades excludes and jce/lcrypto test-contamination excludes
… and register it in the cert test AllTests suite
…tering its encapsulation lengths, with a round-trip test covering the AES-Wrap-192/256 mappings from draft-chen-lamps-cms-frodokem
…ntInfo generate side, binding the ukm field into the KDF otherInfo, with round-trip and tamper tests
…n CMS EnvelopedData, add the twelve composite encapsulation lengths, with a round-trip test over all parameter sets
…ssage through SecurityExceptions.invalidKeyException so the cause is chained (and stays Java 4 safe), across the KEM CipherSpis and the RSA/ElGamal/Falcon/Dilithium/composite paths
…rough SecurityExceptions.illegalBlockSizeException so the cause is chained, matching the sibling KEM CipherSpis
…ng NoSuchAlgorithmException throws through it so the cause is chained (and stays Java 4 safe), across the KEM CipherSpis, X509CRL/Certificate, BCFKS and JcaPKCS10CertificationRequest
…th CMS AuthEnvelopedData AEAD content, with ML-KEM/FrodoKEM/Composite round-trip tests
…ing the full draft-ietf-lamps-cms-composite-kem wrap/KDF/KEM mapping
…complete encoding and nothing extra; add byte[]/InputStream constructors to CMSEncryptedData
…n v3/checkout v4, use build-mode none (Gradle needs JDK 25 so autobuild cannot compile)
Add identity and null checks before comparing byte arrays.
@cragkhit
cragkhit force-pushed the matcha-update-smime-array-comparison branch from ced58ce to e9aaa7a Compare July 22, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants