|
SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
|
Bounded representation helpers; parsing does not establish certificate trust.
Files | |
| file | SharkSslASN1.h |
| ASN.1 macros. | |
Functions | |
| int | SharkSslParseASN1_getLength (SharkSslParseASN1 *o) |
| Read an ASN.1 length and advance past its encoding. More... | |
| SHARKSSL_API int | SharkSslParseASN1_getSetSeq (SharkSslParseASN1 *o, U8 ASN1id) |
| Consume an expected tag and its length, leaving the cursor at its content. More... | |
| SHARKSSL_API int | SharkSslParseASN1_getType (SharkSslParseASN1 *o, U8 ASN1type) |
| Read one tagged value and expose its borrowed content in dataptr/datalen. More... | |
| int | SharkSslParseASN1_getContextSpecific (SharkSslParseASN1 *o, U8 *tag) |
| Read a context-specific value and advance past it. More... | |
| int | SharkSslParseASN1_parseCertSignatureAlgorithm (SharkSslParseASN1 *o) |
| Consume a certificate signature AlgorithmIdentifier. More... | |
| SHARKSSL_API U8 | SharkSslParseASN1_getAlgoID (const SharkSslParseASN1 *o) |
| Map an already parsed OID to a SharkSSL algorithm identifier. More... | |
| SHARKSSL_API U8 | SharkSslParseASN1_getCurveID (const SharkSslParseASN1 *o) |
| Map an already parsed OID to a SharkSSL curve identifier. More... | |
| SHARKSSL_API int | sharkssl_PEM_getSeqVersion (SharkSslParseASN1 *parseKey, U32 len) |
| Enter an ASN.1 key sequence and read its one-byte version. More... | |
| SHARKSSL_API void | SharkSslASN1Create_constructor (SharkSslASN1Create *o, U8 *buf, int bufSize) |
| Initialize an encoder that writes backward from the end of a buffer. More... | |
| SHARKSSL_API int | SharkSslASN1Create_length (SharkSslASN1Create *o, int len) |
| Prepend a definite ASN.1 length. More... | |
| SHARKSSL_API int | SharkSslASN1Create_tag (SharkSslASN1Create *o, U8 ASN1type) |
| Prepend a one-byte ASN.1 tag. More... | |
| SHARKSSL_API int | SharkSslASN1Create_int (SharkSslASN1Create *o, const U8 *intptr, int len) |
| Prepend a nonnegative ASN.1 INTEGER. More... | |
| SHARKSSL_API int | SharkSslASN1Create_raw (SharkSslASN1Create *o, const void *data, int size) |
| Prepend raw bytes without a tag or length. More... | |
| SHARKSSL_API int | SharkSslASN1Create_oid (SharkSslASN1Create *o, const U8 *oid, int oidLen) |
| Prepend an ASN.1 OBJECT IDENTIFIER. More... | |
| SHARKSSL_API int | SharkSslASN1Create_email (SharkSslASN1Create *o, const U8 *oid, int oidLen, const U8 *email, int emailLen) |
| Prepend a distinguished-name attribute using IA5String. More... | |
| SHARKSSL_API int | SharkSslASN1Create_name (SharkSslASN1Create *o, const U8 *oid, int oidLen, const U8 *name, int nameLen) |
| Prepend a distinguished-name attribute using PrintableString. More... | |
| SHARKSSL_API int | SharkSslASN1Create_boolean (SharkSslASN1Create *o, U8 boolean) |
| Prepend an ASN.1 BOOLEAN. More... | |
| int sharkssl_PEM_getSeqVersion | ( | SharkSslParseASN1 * | parseKey, |
| U32 | len | ||
| ) |
Enter an ASN.1 key sequence and read its one-byte version.
Requires the PEM API implementation; it does not validate the remaining key fields.
| parseKey | SharkSslParseASN1 *; Required initialized cursor over a borrowed bounded input buffer. Updated in place; discard cursor state after a parse failure. |
| len | U32; Maximum accepted sequence content length in bytes. |
| int SharkSslASN1Create_boolean | ( | SharkSslASN1Create * | o, |
| U8 | boolean | ||
| ) |
Prepend an ASN.1 BOOLEAN.
Requires CSR signing.
| o | SharkSslASN1Create *; Required initialized reverse encoder; output buffer remains caller-owned. On failure discard the partial encoding. |
| boolean | U8; Zero for FALSE; any nonzero value for TRUE. |
| void SharkSslASN1Create_constructor | ( | SharkSslASN1Create * | o, |
| U8 * | buf, | ||
| int | bufSize | ||
| ) |
Initialize an encoder that writes backward from the end of a buffer.
No allocation is performed. Retrieve the completed bytes with SharkSslASN1Create_getData and SharkSslASN1Create_getLen.
| o | SharkSslASN1Create *; Required uninitialized encoder storage, owned by the caller. |
| buf | U8 *; Required writable caller-owned buffer, retained until encoding ends. |
| bufSize | int; Nonnegative buffer capacity in bytes. |
| int SharkSslASN1Create_email | ( | SharkSslASN1Create * | o, |
| const U8 * | oid, | ||
| int | oidLen, | ||
| const U8 * | email, | ||
| int | emailLen | ||
| ) |
Prepend a distinguished-name attribute using IA5String.
Writes a SET containing the OID/value SEQUENCE. Requires CSR creation or signing.
| o | SharkSslASN1Create *; Required initialized reverse encoder; output buffer remains caller-owned. On failure discard the partial encoding. |
| oid | const U8 *; Required encoded attribute OID content, borrowed for the call. |
| oidLen | int; OID content length in bytes. |
| const U8 *; Required attribute bytes, borrowed for the call; the caller ensures they fit the selected string type. | |
| emailLen | int; Nonnegative attribute length in bytes, excluding any terminator. |
| int SharkSslASN1Create_int | ( | SharkSslASN1Create * | o, |
| const U8 * | intptr, | ||
| int | len | ||
| ) |
Prepend a nonnegative ASN.1 INTEGER.
Leading zeros are removed and a sign-protecting zero is inserted when necessary. Negative integers are not supported.
| o | SharkSslASN1Create *; Required initialized reverse encoder; output buffer remains caller-owned. On failure discard the partial encoding. |
| intptr | const U8 *; Big-endian unsigned magnitude, borrowed for the call; required for nonzero len. |
| len | int; Magnitude length in bytes, 0 through 32767; provide at least one byte for a DER INTEGER value. |
| int SharkSslASN1Create_length | ( | SharkSslASN1Create * | o, |
| int | len | ||
| ) |
Prepend a definite ASN.1 length.
| o | SharkSslASN1Create *; Required initialized reverse encoder; output buffer remains caller-owned. On failure discard the partial encoding. |
| len | int; Content length in bytes, from 0 through 65535. |
| int SharkSslASN1Create_name | ( | SharkSslASN1Create * | o, |
| const U8 * | oid, | ||
| int | oidLen, | ||
| const U8 * | name, | ||
| int | nameLen | ||
| ) |
Prepend a distinguished-name attribute using PrintableString.
Writes a SET containing the OID/value SEQUENCE. Requires CSR creation or signing.
| o | SharkSslASN1Create *; Required initialized reverse encoder; output buffer remains caller-owned. On failure discard the partial encoding. |
| oid | const U8 *; Required encoded attribute OID content, borrowed for the call. |
| oidLen | int; OID content length in bytes. |
| name | const U8 *; Required attribute bytes, borrowed for the call; the caller ensures they fit the selected string type. |
| nameLen | int; Nonnegative attribute length in bytes, excluding any terminator. |
| int SharkSslASN1Create_oid | ( | SharkSslASN1Create * | o, |
| const U8 * | oid, | ||
| int | oidLen | ||
| ) |
Prepend an ASN.1 OBJECT IDENTIFIER.
Available with CSR creation, CSR signing or ASN.1 key creation.
| o | SharkSslASN1Create *; Required initialized reverse encoder; output buffer remains caller-owned. On failure discard the partial encoding. |
| oid | const U8 *; Required encoded OID content bytes, without tag/length; borrowed for the call. |
| oidLen | int; Nonnegative OID content length in bytes. |
| int SharkSslASN1Create_raw | ( | SharkSslASN1Create * | o, |
| const void * | data, | ||
| int | size | ||
| ) |
Prepend raw bytes without a tag or length.
Available with CSR creation, CSR signing or ASN.1 key creation.
| o | SharkSslASN1Create *; Required initialized reverse encoder; output buffer remains caller-owned. On failure discard the partial encoding. |
| data | const void *; Required readable byte buffer, borrowed for the call; must not overlap the destination. |
| size | int; Nonnegative number of bytes to copy. |
| int SharkSslASN1Create_tag | ( | SharkSslASN1Create * | o, |
| U8 | ASN1type | ||
| ) |
Prepend a one-byte ASN.1 tag.
| o | SharkSslASN1Create *; Required initialized reverse encoder; output buffer remains caller-owned. On failure discard the partial encoding. |
| ASN1type | U8; One-byte tag including class and constructed bits. |
| U8 SharkSslParseASN1_getAlgoID | ( | const SharkSslParseASN1 * | o | ) |
Map an already parsed OID to a SharkSSL algorithm identifier.
| o | const SharkSslParseASN1 *; Required cursor whose dataptr/datalen describe the OID content; borrowed and unchanged. |
| int SharkSslParseASN1_getContextSpecific | ( | SharkSslParseASN1 * | o, |
| U8 * | tag | ||
| ) |
Read a context-specific value and advance past it.
| o | SharkSslParseASN1 *; Required initialized cursor over a borrowed bounded input buffer. Updated in place; discard cursor state after a parse failure. |
| tag | U8 *; Required output for the tag with the context-specific class bit removed; the constructed bit is retained. |
| U8 SharkSslParseASN1_getCurveID | ( | const SharkSslParseASN1 * | o | ) |
Map an already parsed OID to a SharkSSL curve identifier.
| o | const SharkSslParseASN1 *; Required cursor whose dataptr/datalen describe the OID content; borrowed and unchanged. |
| int SharkSslParseASN1_getLength | ( | SharkSslParseASN1 * | o | ) |
Read an ASN.1 length and advance past its encoding.
| o | SharkSslParseASN1 *; Required initialized cursor over a borrowed bounded input buffer. Updated in place; discard cursor state after a parse failure. |
| int SharkSslParseASN1_getSetSeq | ( | SharkSslParseASN1 * | o, |
| U8 | ASN1id | ||
| ) |
Consume an expected tag and its length, leaving the cursor at its content.
| o | SharkSslParseASN1 *; Required initialized cursor over a borrowed bounded input buffer. Updated in place; discard cursor state after a parse failure. |
| ASN1id | U8; Expected one-byte tag, including class and constructed bits. |
| int SharkSslParseASN1_getType | ( | SharkSslParseASN1 * | o, |
| U8 | ASN1type | ||
| ) |
Read one tagged value and expose its borrowed content in dataptr/datalen.
Advances past the content. INTEGER removes one leading zero where applicable; an OID also consumes an immediately following NULL parameter. This is a representation helper, not certificate validation.
| o | SharkSslParseASN1 *; Required initialized cursor over a borrowed bounded input buffer. Updated in place; discard cursor state after a parse failure. |
| ASN1type | U8; Expected one-byte ASN.1 tag. |
| int SharkSslParseASN1_parseCertSignatureAlgorithm | ( | SharkSslParseASN1 * | o | ) |
Consume a certificate signature AlgorithmIdentifier.
RSA-PSS accepts matching supported hash/MGF1 hash, a digest-length salt and trailer field 1. Parsing does not verify a signature.
| o | SharkSslParseASN1 *; Required initialized cursor over a borrowed bounded input buffer. Updated in place; discard cursor state after a parse failure. |