Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Java KeyStore

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

JKS (magic 0xFEEDFEED) and JCEKS (0xCECECECE) keystore files: big-endian DataOutputStream layout with entry tags 1 (private key) and 2 (trusted certificate) and a trailing SHA-1 keyed digest.

Header and entries

From OpenJDK JavaKeyStore.java and JceKeyStore.java (see Fact:Java KeyStore/magic/JKS and JCEKS magic): big-endian uint32 magic (JKS 0xFEEDFEED, JCEKS 0xCECECECE), uint32 version (1 or 2; writers always write 2), uint32 entry count, then per entry a uint32 tag.

Tag 1 (private key): writeUTF alias (uint16 length + modified UTF-8), int64 creation time in milliseconds, uint32 length + protected private key bytes, uint32 chain length, then per certificate (version 2) writeUTF type (e.g. X.509), uint32 length, DER bytes. Tag 2 (trusted certificate): alias, int64 date, type, length, DER bytes. Version 1 has no certificate type strings and assumes X.509.

After the entries the file ends with a SHA-1 digest of: password bytes, the ASCII string Mighty Aphrodite, then everything written before. Reading with no password skips the check, so a file is parsable without it.

Known file extensions: Unverified: .jks, .keystore, .jceks. PKCS12 is the default keystore type in current Java; see Format:PKCS12. Unverified: Android BKS (Bouncy Castle) and Apple keychain files were not examined.

Technique:Recognizing embedded keys and certificates

Code & repositories

  • https://github.com/openjdk/jdk @ 042f64e81f8e11e677062717d0f5bfc43212e7ab · license: GPL-2.0
    OpenJDK: JavaKeyStore.java (JKS) and JceKeyStore.java (JCEKS) show the keystore byte layout.
    Tested on: source read, not run: source reading only · checked 2026-10-19; last activity 2026-10-19