Skip to content

Add niap-android-cert-ext and sdp-file-encrypt libraries to niap-cc - #58

Open
KVVat wants to merge 13 commits into
android:masterfrom
KVVat:niap-libararies-updates
Open

KVVat wants to merge 13 commits into
android:masterfrom
KVVat:niap-libararies-updates

Conversation

@KVVat

@KVVat KVVat commented May 28, 2026

Copy link
Copy Markdown
Contributor

Added new 2 librarariees for NIAP validations.

  • niap-android-cert-ext
    • TLS/Cert Validator and X509 cert with EST client framework which compliat to the NIAP definitons.
    • docker files for mock server
  • sdp-file-encrypt
    • Encrypted file i/o libray which compliant to the NIAP definitions

@KVVat
KVVat requested a review from mpgroover May 28, 2026 08:20

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces two major security modules: niap-android-cert-ext, which implements strict X.509 certificate validation and secure lifecycle management using the EST protocol, and sdp-file-encrypt, which provides robust file encryption strategies compliant with NIAP MDF PP requirements. The code review identified several critical issues, including a namespace mismatch in NiapCertHelper that prevents configuration loading, sensitive cryptographic key material being logged to Logcat, potential file descriptor leaks in TinkEncryptionProvider, and thread-safety concerns in NiapCertManager. Additionally, optimizations were suggested to prevent performance bottlenecks during binder buffer flushing and to avoid potential null pointer exceptions in NiapCertValidator.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to include this file in the repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. These were included for the LLM to reference during agentic coding, so they should not have been committed. I'll remove the documents.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to include device specific testing docs in the repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I removed the documents directory from repository.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of including the CC and CEM documents directly in the repo, should something like the readme point to the docs at their official source?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I removed the documents directory from repository.

KVVat added 10 commits October 20, 2026 11:23
…mparison provider

- Defer RawHybridKeyProvider streaming DEK destruction until stream close() so locked/BFU StreamingAead encryption no longer fails with AEADBadTagException while preserving FCS_CKM_EXT.4 explicit zeroization.
- Add EncryptionManager.sweepAndRewrapDirectory(File) with atomic temp-file replacement and NotImplementedError handling for post-unlock 0x01 -> 0x02 sweeps.
- Expose EncryptionManager.providerType and add KeyProviderType.NONE (NoOpKeyProvider) for side-by-side plaintext contrast demos.
…eams

Replace CipherOutputStream/CipherInputStream in RawHybridKeyProvider and
ByteArrayOutputStream/ByteArrayInputStream in TinkEncryptionProvider with
wire-compatible ZeroizingStreams (ZeroizingByteArrayOutputStream,
ZeroizingByteArrayInputStream, ZeroizingCipherEncryptOutputStream, and
ZeroizingCipherDecryptInputStream).

Calling Cipher.doFinal directly on zeroizable buffers avoids Conscrypt's
unzeroed OpenSSLAeadCipher.buf and CipherInputStream.obuffer remnants on
the ART heap, eliminating plaintext remanence after close() while keeping
existing EHBR 0x01/0x02 wire format and DEK destruction intact.
…afeHkdf

- Upgrade RawHybridKeyProvider symmetric streaming path (newEncryptingStreamSymmetric
  and newDecryptingStream 0x02) to Solution 2 ECDH (symmetric_ec + flushKeystoreBinderBuffer)
  so raw 32-byte DEKs never cross Binder IPC into keystore2/keymint-trusty or linger in
  AndroidKeyStoreCipherSpiBase chunked buffers, unifying the 0x02 wire format with
  encryptSymmetric and rewrapKeyToSymmetricUdr (with legacy 0x02 decrypt fallback).
- Clear wrap/unwrap/data Cipher state consistently and delete all 4 RawHybrid aliases
  in destroy().
- Eliminate unzeroed ByteArrayOutputStream / toByteArray() 64-byte KEK buffers in
  SafeHkdf.computeHkdf() and add SafeHkdfTest verifying RFC 5869 HMAC-SHA512 equivalence.
- Add optional null-default SecurityAuditLogger.keyMaterialObserver hook for forensic
  key-remanence verification.
…rypt

- Drop unused legacy non-ECDH 0x02 fallback branch in newDecryptingStream()
  and unify 0x01/0x02 ECDH streaming decryption into one shared flow.
- Remove dead unused _encryptSymmetric() helper and zeroize
  ephemeralPublicKeyBytes in AEAD symmetric decrypt finally block.
Regenerate niap-cc/niap-android-cert-ext from the source of truth by
following docs/SUBMISSION.md of the source repository (no hand edits).

Source:
  Repository: https://github.com/KVVat/niap-android-cert-ext
  Tag:        resubmission-2026-12-04 (tag object 9741b0fa2d2b)
  Commit:     832ff9e7c0068eb68b185150f588efd56d65aafe
  Branch:     fix/tls-lab-findings
  Package:    dist/20261204-final
              (MANIFEST.txt: Date (UTC) 2026-12-03T20:13:02Z, Tree State: clean)

The niap-cc/niap-android-cert-ext tree is identical to the root tree of
commit 832ff9e (tree 7f49efc). Compared with the previous drop
(submission/2026-11-19): 88 files, 21 modified, 28 added, 0 removed.

SHA256SUMS of the delivered artifacts:
  bf970fbb68ceb623118fae118232c0f3409768dbe2cc7c98057f2570724095de  cert-lib-release.aar
  c69fbe8a5c90ebb486b572616fc8f51fd9a657e52b101fb367e50f3a99a5de81  cert-manager-debug.apk
  f869e3267ba51cb5b09691ecc93948c3b655b9597142647fb39df2ca68e91d8e  cert-test-app-debug.apk
  7e15b49e2435767dd92339b02b8e82633465c8fbac354f6958e1820ecaa54325  niap-android-cert-ext.zip
  fddb160f08360070be0940d02e5a019b665b7be6a786021425746ec4672bd716  niap-cert-lib-release.zip
  3e6fda4c0014e878a36d3911a30cf710274fbd3e63f114f4e11a4d9707d5f157  validator-test-app-relaxed-debug.apk
  3e80acbbe34548cf6c8130fa72f32816e7d64155efe790e2920cd512a8ac87aa  validator-test-app-strict-debug.apk
  5d9e23791297d883bbc3746521be9750d67721113330d587c7ee3b98dcade167  MANIFEST.txt

In-place verification (docs/SUBMISSION.md step 3):
  ./gradlew --console=plain -PskipTestbedCopy=true \
    :cert-lib:testDebugUnitTest :cert-lib:assembleRelease \
    :validator-test-app:assembleStrictDebug
  BUILD SUCCESSFUL; 56 cert-lib unit tests passed (0 failures);
  the rebuilt cert-lib-release.aar is byte-identical to the delivered AAR.
Delete the macOS Finder metadata files .DS_Store and niap-cc/.DS_Store and add a root .gitignore entry so that .DS_Store files are not committed again.
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.

2 participants