Next: Error handling functions, Previous: ASN.1 field functions, Up: Function reference
len: value to convert.
ans: string returned.
ans_len: number of meaningful bytes of ANS (ans[0]..ans[ans_len-1]).
Creates the DER coding for the LEN parameter (only the length). The
ans
buffer is pre-allocated and must have room for the output.
str: OCTET string.
str_len: STR length (str[0]..str[str_len-1]).
der: string returned.
der_len: number of meaningful bytes of DER (der[0]..der[ans_len-1]).
Creates the DER coding for an OCTET type (length included).
str: BIT string.
bit_len: number of meaningful bits in STR.
der: string returned.
der_len: number of meaningful bytes of DER (der[0]..der[ans_len-1]).
Creates the DER coding for a BIT STRING type (length and pad included).
element: pointer to an ASN1 element
name: the name of the structure you want to encode (it must be inside *POINTER).
ider: vector that will contain the DER encoding. DER must be a pointer to memory cells already allocated.
len: number of bytes of *
ider
:ider
[0]..ider
[len-1], Initialy holds the sizeof of der vector.Creates the DER encoding for the NAME structure (inside *POINTER structure).
Returns: ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element.
ASN1_VALUE_NOT_FOUND: There is an element without a value.
ASN1_MEM_ERROR:
ider
vector isn't big enough. Also in this case LEN will contain the length needed.
der: DER data to decode.
der_len: Length of DER data to decode.
len: Output variable containing the length of the DER length field.
Extract a length field from DER data.
Return value: Return the decoded length value, or -1 on indefinite length, or -2 when the value was too big.
der: DER data to decode.
der_len: Length of DER data to decode.
class: Output variable containing decoded class.
len: Output variable containing the length of the DER TAG data.
tag: Output variable containing the decoded tag.
Decode the class and TAG from DER code.
Return value: Returns ASN1_SUCCESS on success, or an error.
der: DER data to decode containing the OCTET SEQUENCE.
der_len: Length of DER data to decode.
ret_len: Output variable containing the length of the DER data.
str: Pre-allocated output buffer to put decoded OCTET SEQUENCE in.
str_size: Length of pre-allocated output buffer.
str_len: Output variable containing the length of the OCTET SEQUENCE.
Extract an OCTET SEQUENCE from DER data.
Return value: Returns ASN1_SUCCESS on success, or an error.
der: DER data to decode containing the BIT SEQUENCE.
der_len: Length of DER data to decode.
ret_len: Output variable containing the length of the DER data.
str: Pre-allocated output buffer to put decoded BIT SEQUENCE in.
str_size: Length of pre-allocated output buffer.
bit_len: Output variable containing the size of the BIT SEQUENCE.
Extract a BIT SEQUENCE from DER data.
Return value: Return ASN1_SUCCESS on success, or an error.
element: pointer to an ASN1 structure.
ider: vector that contains the DER encoding.
len: number of bytes of *
ider
:ider
[0]..ider
[len-1].errorDescription: null-terminated string contains details when an error occurred.
Fill the structure *ELEMENT with values of a DER encoding string. The sructure must just be created with function 'create_stucture'. If an error occurs during the decoding procedure, the *ELEMENT is deleted and set equal to
ASN1_TYPE_EMPTY
.Returns: ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE_EMPTY.
ASN1_TAG_ERROR,ASN1_DER_ERROR: The der encoding doesn't match the structure NAME. *ELEMENT deleted.
structure: pointer to an ASN1 structure
elementName: name of the element to fill
ider: vector that contains the DER encoding of the whole structure.
len: number of bytes of *der: der[0]..der[len-1]
errorDescription: null-terminated string contains details when an error occurred.
Fill the element named ELEMENTNAME with values of a DER encoding string. The sructure must just be created with function 'create_stucture'. The DER vector must contain the encoding string of the whole STRUCTURE. If an error occurs during the decoding procedure, the *STRUCTURE is deleted and set equal to
ASN1_TYPE_EMPTY
.Returns: ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE_EMPTY or elementName == NULL.
ASN1_TAG_ERROR,ASN1_DER_ERROR: The der encoding doesn't match the structure STRUCTURE. *ELEMENT deleted.
element: pointer to an ASN1 element
ider: vector that contains the DER encoding.
len: number of bytes of *
ider
:ider
[0]..ider
[len-1]name_element: an element of NAME structure.
start: the position of the first byte of NAME_ELEMENT decoding (
ider
[*start])end: the position of the last byte of NAME_ELEMENT decoding (
ider
[*end])Find the start and end point of an element in a DER encoding string. I mean that if you have a der encoding and you have already used the function "asn1_der_decoding" to fill a structure, it may happen that you want to find the piece of string concerning an element of the structure.
Example: the sequence "tbsCertificate" inside an X509 certificate.
Returns: ASN1_SUCCESS: DER encoding OK.
ASN1_ELEMENT_NOT_FOUND: ELEMENT is ASN1_TYPE EMPTY or NAME_ELEMENT is not a valid element.
ASN1_TAG_ERROR,ASN1_DER_ERROR: the der encoding doesn't match the structure ELEMENT.
definitions: ASN1 definitions
element: pointer to an ASN1 structure
Expands every "ANY DEFINED BY" element of a structure created from a DER decoding process (asn1_der_decoding function). The element ANY must be defined by an OBJECT IDENTIFIER. The type used to expand the element ANY is the first one following the definition of the actual value of the OBJECT IDENTIFIER.
Returns: ASN1_SUCCESS: Substitution OK.
ASN1_ERROR_TYPE_ANY: Some "ANY DEFINED BY" element couldn't be expanded due to a problem in OBJECT_ID -> TYPE association.
other errors: Result of der decoding process.
definitions: ASN1 definitions
element: pointer to an ASN1 structure
octetName: name of the OCTECT STRING field to expand.
objectName: name of the OBJECT IDENTIFIER field to use to define the type for expansion.
Expands an "OCTET STRING" element of a structure created from a DER decoding process (asn1_der_decoding function). The type used for expansion is the first one following the definition of the actual value of the OBJECT IDENTIFIER indicated by OBJECTNAME.
Returns: ASN1_SUCCESS: Substitution OK.
ASN1_ELEMENT_NOT_FOUND: OBJECTNAME or OCTETNAME are not correct.
ASN1_VALUE_NOT_VALID: Wasn't possible to find the type to use for expansion.
other errors: result of der decoding process.