Skip to content

Commit

Permalink
what?
Browse files Browse the repository at this point in the history
  • Loading branch information
acagliano committed Sep 29, 2023
1 parent 2a8d454 commit 38a7cd7
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 213 deletions.
201 changes: 101 additions & 100 deletions docs/doxygen/xml/cryptx_8h.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/doxygen/xml/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<member refid="structcryptx__pkcs8__privkeyinfo_1a1a78aa66dd55e2114830d6a61c8ee5a2" kind="variable"><name>rsa</name></member>
<member refid="structcryptx__pkcs8__privkeyinfo_1a8ff17aa067c3f2ce8ab189f2ef06983f" kind="variable"><name>curveid</name></member>
<member refid="structcryptx__pkcs8__privkeyinfo_1a59674716d2290d0b3b5890a036ef0e66" kind="variable"><name>private</name></member>
<member refid="structcryptx__pkcs8__privkeyinfo_1a8cd9baca23da0f4ce6fb5abad574f011" kind="variable"><name>compressed</name></member>
<member refid="structcryptx__pkcs8__privkeyinfo_1ac1142f13a9d238790f6b504d50bbd51d" kind="variable"><name>public</name></member>
<member refid="structcryptx__pkcs8__privkeyinfo_1a7638a55e2e4660f6808a1781359e8043" kind="variable"><name>ec</name></member>
<member refid="structcryptx__pkcs8__privkeyinfo_1ab23b960497349441d3af88eeb9ee024d" kind="variable"><name>privatekey</name></member>
Expand All @@ -89,6 +90,7 @@
<member refid="structcryptx__pkcs8__pubkeyinfo_1a7c2e360f603268bc369d9aeca5e039e1" kind="variable"><name>exponent</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1aa2bfea80da29c8b891a76724848dee31" kind="variable"><name>rsa</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1a62a828fdac5d4b36828cb93511b02224" kind="variable"><name>curveid</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1aedbb421fe79269c230a93728f805efa7" kind="variable"><name>compressed</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1a7d54d6cbd0f72e933f202848b83dab9d" kind="variable"><name>ec</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1a9990f2870686421fc2e8e22f9790e65d" kind="variable"><name>publickey</name></member>
</compound>
Expand Down
6 changes: 3 additions & 3 deletions docs/doxygen/xml/structcryptx__ecc__point.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="725" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="725" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="726" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="726" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__ecc__point_1ada79cb09d73636479cf469e6de935973" prot="public" static="no" mutable="no">
<type>uint8_t</type>
Expand All @@ -30,15 +30,15 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="726" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="726" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="727" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="727" bodyend="-1"/>
</memberdef>
</sectiondef>
<briefdescription>
<para>Defines a point for use with elliptic curve arithmetic. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="724" column="1" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="724" bodyend="727"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="725" column="1" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="725" bodyend="728"/>
<listofallmembers>
<member refid="structcryptx__ecc__point_1a7a6b80237baf8237385a5827601d1337" prot="public" virt="non-virtual"><scope>cryptx_ecc_point</scope><name>x</name></member>
<member refid="structcryptx__ecc__point_1ada79cb09d73636479cf469e6de935973" prot="public" virt="non-virtual"><scope>cryptx_ecc_point</scope><name>y</name></member>
Expand Down
55 changes: 35 additions & 20 deletions docs/doxygen/xml/structcryptx__pkcs8__privkeyinfo.xml

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions docs/doxygen/xml/structcryptx__pkcs8__pubkeyinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,21 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="584" column="23"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="584" column="21"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__pkcs8__pubkeyinfo_1aedbb421fe79269c230a93728f805efa7" prot="public" static="no" mutable="no">
<type>bool</type>
<definition>bool cryptx_pkcs8_pubkeyinfo::compressed</definition>
<argsstring></argsstring>
<name>compressed</name>
<qualifiedname>cryptx_pkcs8_pubkeyinfo::compressed</qualifiedname>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="585" column="12" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="585" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__pkcs8__pubkeyinfo_1a7d54d6cbd0f72e933f202848b83dab9d" prot="public" static="no" mutable="no">
<type>struct <ref refid="structcryptx__pkcs8__pubkeyinfo" kindref="compound">cryptx_pkcs8_pubkeyinfo</ref></type>
Expand All @@ -114,7 +128,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="586" column="8"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="587" column="8"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__pkcs8__pubkeyinfo_1a9990f2870686421fc2e8e22f9790e65d" prot="public" static="no" mutable="no">
<type>union <ref refid="structcryptx__pkcs8__pubkeyinfo" kindref="compound">cryptx_pkcs8_pubkeyinfo</ref></type>
Expand All @@ -128,17 +142,18 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="587" column="13"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="588" column="13"/>
</memberdef>
</sectiondef>
<briefdescription>
<para>Defines a structure for holding imported RSA or ECC public key data. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="576" column="1" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="576" bodyend="588"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="576" column="1" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="576" bodyend="589"/>
<listofallmembers>
<member refid="structcryptx__pkcs8__pubkeyinfo_1a0e1c00600dfd4f60829534060ed0f163" prot="public" virt="non-virtual"><scope>cryptx_pkcs8_pubkeyinfo</scope><name>bytes</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1aedbb421fe79269c230a93728f805efa7" prot="public" virt="non-virtual"><scope>cryptx_pkcs8_pubkeyinfo</scope><name>compressed</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1a62a828fdac5d4b36828cb93511b02224" prot="public" virt="non-virtual"><scope>cryptx_pkcs8_pubkeyinfo</scope><name>curveid</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1a7d54d6cbd0f72e933f202848b83dab9d" prot="public" virt="non-virtual"><scope>cryptx_pkcs8_pubkeyinfo</scope><name>ec</name></member>
<member refid="structcryptx__pkcs8__pubkeyinfo_1a7c2e360f603268bc369d9aeca5e039e1" prot="public" virt="non-virtual"><scope>cryptx_pkcs8_pubkeyinfo</scope><name>exponent</name></member>
Expand Down
54 changes: 29 additions & 25 deletions docs/modules/pkcs8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,46 @@ __________
.. doxygenfunction:: cryptx_pkcs8_import_privatekey
:project: CryptX

You can import a keyfile and then access its data like so:
You can import your keyfiles like so:

.. code-block:: c
char *fname = "MyKey";
char *pubkey_fname = "MyPub";
char *privkey_fname = "MyPriv";
uint8_t fp;
pkcs_error_t err;
cryptx_pkcs8_pubkeyinfo pubkey;
cryptx_pkcs8_privkeyinfo privkey;
uint8_t *key_data;
size_t key_len;
// load the key from AppVar file
// requires FILEIOC library
if(!(fp = ti_Open(fname, "r"))) return; // failed to open file
uint8_t *pkcs_data = ti_GetDataPtr(fp);
size_t pkcs_len = ti_GetSize(fp);
// load pubkey from file (requires FILEIOC library)
if(!(fp = ti_Open(pubkey_fname, "r"))) return; // failed to open file
key_data = ti_GetDataPtr(fp);
key_len = ti_GetSize(fp);
ti_Close(fp);
err = cryptx_pkcs8_import_publickey(key_data, key_len, &pubkey);
if(err) return;
pkcs_error_t err;
cryptx_pkcs8_pubkeyinfo key;
err = cryptx_pkcs8_import_publickey(pkcs_data, pkcs_len, &key);
// load pubkey from file (requires FILEIOC library)
if(!(fp = ti_Open(privkey_fname, "r"))) return; // failed to open file
key_data = ti_GetDataPtr(fp);
key_len = ti_GetSize(fp);
ti_Close(fp);
err = cryptx_pkcs8_import_privatekey(key_data, key_len, &privkey);
if(err) return;
key.objectid.data; // pointer to object id (bytes)
key.objectid.len; // length of object id
// For RSA
key.publickey.rsa.data; // public modulus data (bytes)
key.publickey.rsa.len; // length of rsa modulus (size_t)
key.publickey.rsa.exponent; // public exponent (uint24_t)
// For EC
key.publickey.ec.curveid.data; // pointer to curve id (bytes)
key.publickey.ec.curveid.len; // length of curve id (size_t)
key.publickey.ec.data; // public key (bytes)
key.publickey.ec.len; // length of public key
// these structs can be passed directly to the TLS implementation (coming soon)
// or the members can be accessed directly for advanced usage.
.. _spec:

PKCS#8 Encoding Specification
______________________________
Additional Info
________________

PKCS#8 Specification
^^^^^^^^^^^^^^^^^^^^^

This section details the PKCS#8 encoding format for public and private key files.

Expand Down Expand Up @@ -163,7 +167,7 @@ For some key formats the *PublicKey* field further encodes a structure from a di
-- first octet of key is 0x04 for uncompressed or 0x03 or 0x02 for compressed
Object Identifier Reference
___________________________
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This section lists object identifiers for algorithms supported by this library. Developers should generally never need to use these as the library should handle it internally, but if you need them for other projects or even for custom implementations, here they are.

Expand Down
56 changes: 30 additions & 26 deletions docs/www/_sources/modules/pkcs8.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,46 @@ __________
.. doxygenfunction:: cryptx_pkcs8_import_privatekey
:project: CryptX

You can import a keyfile and then access its data like so:
You can import your keyfiles like so:

.. code-block:: c
char *fname = "MyKey";
char *pubkey_fname = "MyPub";
char *privkey_fname = "MyPriv";
uint8_t fp;
pkcs_error_t err;
cryptx_pkcs8_pubkeyinfo pubkey;
cryptx_pkcs8_privkeyinfo privkey;
uint8_t *key_data;
size_t key_len;
// load the key from AppVar file
// requires FILEIOC library
if(!(fp = ti_Open(fname, "r"))) return; // failed to open file
uint8_t *pkcs_data = ti_GetDataPtr(fp);
size_t pkcs_len = ti_GetSize(fp);
// load pubkey from file (requires FILEIOC library)
if(!(fp = ti_Open(pubkey_fname, "r"))) return; // failed to open file
key_data = ti_GetDataPtr(fp);
key_len = ti_GetSize(fp);
ti_Close(fp);
err = cryptx_pkcs8_import_publickey(key_data, key_len, &pubkey);
if(err) return;
pkcs_error_t err;
cryptx_pkcs8_pubkeyinfo key;
err = cryptx_pkcs8_import_publickey(pkcs_data, pkcs_len, &key);
// load pubkey from file (requires FILEIOC library)
if(!(fp = ti_Open(privkey_fname, "r"))) return; // failed to open file
key_data = ti_GetDataPtr(fp);
key_len = ti_GetSize(fp);
ti_Close(fp);
err = cryptx_pkcs8_import_privatekey(key_data, key_len, &privkey);
if(err) return;
key.objectid.data; // pointer to object id (bytes)
key.objectid.len; // length of object id
// For RSA
key.publickey.rsa.data; // public modulus data (bytes)
key.publickey.rsa.len; // length of rsa modulus (size_t)
key.publickey.rsa.exponent; // public exponent (uint24_t)
// For EC
key.publickey.ec.curveid.data; // pointer to curve id (bytes)
key.publickey.ec.curveid.len; // length of curve id (size_t)
key.publickey.ec.data; // public key (bytes)
key.publickey.ec.len; // length of public key
// these structs can be passed directly to the TLS implementation (coming soon)
// or the members can be accessed directly for advanced usage.
.. _spec:

PKCS#8 Encoding Specification
______________________________
Additional Info
________________

PKCS#8 Specification
^^^^^^^^^^^^^^^^^^^^^

This section details the PKCS#8 encoding format for public and private key files.

Expand Down Expand Up @@ -158,12 +162,12 @@ For some key formats the *PublicKey* field further encodes a structure from a di
publicKey [1] BIT STRING OPTIONAL
}
-- from SECG1, src: rfc5915 1.3
-- from SECG1, src: rfc5915 2.2
ECPublicKey ::= ECPoint ::= OCTET STRING
-- first octet of key is 0x04 for uncompressed or 0x03 or 0x02 for compressed
Object Identifier Reference
___________________________
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This section lists object identifiers for algorithms supported by this library. Developers should generally never need to use these as the library should handle it internally, but if you need them for other projects or even for custom implementations, here they are.

Expand Down
Loading

0 comments on commit 38a7cd7

Please sign in to comment.