小编典典

JKS密钥库格式的规范

java

我想知道是否存在Java中使用的JKS密钥存储格式的正式规范?我想编写一个往返PKCS#12的转换器,但不是用Java编写的,因此不幸的是,不能选择使用keytool或Java代码。

在一个十六进制编辑器中查看一个告诉我,它可能不是ASN.1。在我开始研究OpenJDK之前,尝试对格式进行逆向工程,是否有人知道是否存在规范?到目前为止我找不到任何东西,将不胜感激!


阅读 446

收藏
2020-11-16

共1个答案

小编典典

我认为您应该从JDK
来源开始研究。那里有一些非常有用的评论。例如

/*
         * KEYSTORE FORMAT:
         *
         * Magic number (big-endian integer),
         * Version of this file format (big-endian integer),
         *
         * Count (big-endian integer),
         * followed by "count" instances of either:
         *
         *     {
         *      tag=1 (big-endian integer),
         *      alias (UTF string)
         *      timestamp
         *      encrypted private-key info according to PKCS #8
         *          (integer length followed by encoding)
         *      cert chain (integer count, then certs; for each cert,
         *          integer length followed by encoding)
         *     }
         *
         * or:
         *
         *     {
         *      tag=2 (big-endian integer)
         *      alias (UTF string)
         *      timestamp
         *      cert (integer length followed by encoding)
         *     }
         *
         * ended by a keyed SHA1 hash (bytes only) of
         *     { password + whitener + preceding body }
         */
2020-11-16