![]() |
![]() |
![]() |
PSKC Library Manual | ![]() |
---|---|---|---|---|
Top | Description |
int pskc_build_xml (pskc_t *container
,char **out
,size_t *len
); void pskc_done (pskc_t *container
); const char * pskc_get_id (pskc_t *container
); pskc_key_t * pskc_get_keypackage (pskc_t *container
,size_t i
); const char * pskc_get_version (pskc_t *container
); int pskc_init (pskc_t **container
); int pskc_output (pskc_t *container
,pskc_output_formats_t format
,char **out
,size_t *len
); enum pskc_output_formats_t; int pskc_parse_from_memory (pskc_t *container
,size_t len
,const char *buffer
); int pskc_validate (pskc_t *container
,int *isvalid
);
PSKC data is represented through the pskc_t type which is created
by calling pskc_init()
and destroyed by calling pskc_done()
. You
may parse PSKC data in XML form from a buffer by calling
pskc_parse_from_memory()
. To convert PSKC data to human readable
form you may use pskc_output()
. To validate PSKC data against the
XML Schema, you may use pskc_validate()
. To generate PSKC based on
the internal parsed representation you may use pskc_build_xml()
which takes a pskc_output_format enumeration to indicate output
form.
The PSKC data structure is a high-level structure that only carries
a version indicator (see pskc_get_version()
), an optional identity
field (see pskc_get_id()
) and any number of pskc_key_t types, each
containing one key (see pskc_get_keypackage()
).
int pskc_build_xml (pskc_t *container
,char **out
,size_t *len
);
This function builds a XML file from the data in container
and
converts it to a string placed in the newly allocated *out
of
length len
.
|
a pskc_t handle, from pskc_init() . |
|
pointer to output variable to hold newly allocated string. |
|
output variable holding length of *out . |
Returns : |
On success, PSKC_OK (zero) is returned, on memory
allocation errors PSKC_MALLOC_ERROR is returned. |
void pskc_done (pskc_t *container
);
This function releases the resources associated with the PSKC
container
handle.
|
a pskc_t handle, from pskc_init() . |
const char * pskc_get_id (pskc_t *container
);
Get the PSKC KeyContainer Id attribute.
|
a pskc_t handle, from pskc_init() . |
Returns : |
a constant string (must not be deallocated) holding the content, or NULL if not set. |
pskc_key_t * pskc_get_keypackage (pskc_t *container
,size_t i
);
Get a PSKC keypackage pskc_key_t handle for the i
'th key package
in container
. i
is zero-based, i.e., 0 refer to the first key
package, 1 refer to the second key package, and so on.
|
a pskc_t handle, from pskc_init() . |
|
number of keypackage to get. |
Returns : |
NULL if there is no i 'th key package, or a valid
pskc_key_t pointer. |
const char * pskc_get_version (pskc_t *container
);
Get the PSKC KeyContainer Version attribute. Normally this string is always "1.0" and a missing field is a syntax error according to the PSKC schema.
|
a pskc_t handle, from pskc_init() . |
Returns : |
a constant string (must not be deallocated) holding the content, or NULL if not set. |
int pskc_init (pskc_t **container
);
This function initializes the PSKC container
handle. The memory
allocate can be released by calling pskc_done()
.
|
pointer to a pskc_t handle to initialize. |
Returns : |
On success, PSKC_OK (zero) is returned, on memory
allocation errors PSKC_MALLOC_ERROR is returned. |
int pskc_output (pskc_t *container
,pskc_output_formats_t format
,char **out
,size_t *len
);
Convert PSKC data to a serialized string of the indicated type. This is usually used to convert the PSKC data to some human readable form.
|
a pskc_t handle, from pskc_init() . |
|
an pskc_output_formats_t enumeration type indicating format. |
|
pointer to output variable holding newly allocated string. |
|
pointer to output variable hold length of *out . |
Returns : |
PSKC_OK on success, or an error code. |
typedef enum { PSKC_OUTPUT_HUMAN_COMPLETE = 0 } pskc_output_formats_t;
Enumeration of different PSKC output formats.
int pskc_parse_from_memory (pskc_t *container
,size_t len
,const char *buffer
);
This function will parse the XML data in buffer
of len
size into
container
. If PSKC_PARSE_ERROR
is returned, parsing of some
elements have failed but the container
is still valid and contain
partially parsed information. In this situation, you may continue
but raise a warning.
|
a pskc_t handle, from pskc_init() . |
|
length of buffer . |
|
XML data to parse. |
Returns : |
On success, PSKC_OK (zero) is returned, on memory
allocation errors PSKC_MALLOC_ERROR is returned, on XML library
errors PSKC_XML_ERROR is returned, on PSKC parse errors
PSKC_PARSE_ERROR is returned. |
int pskc_validate (pskc_t *container
,int *isvalid
);
This function validate the PSKC container
handle the PSKC XML
Schema.
|
a pskc_t handle, from pskc_init() . |
|
output variable holding validation result, non-0 for valid. |
Returns : |
On success, PSKC_OK (zero) is returned, or an error code. |