Top |
Functions
Properties
GckAttributes * | parsed-attributes | Read |
gchar * | parsed-description | Read |
gchar * | parsed-label | Read |
Types and Values
#define | GCR_DATA_ERROR |
enum | GcrDataError |
enum | GcrDataFormat |
struct | GcrParser |
struct | GcrParserClass |
GcrParsed |
Description
A GcrParser can parse various certificate and key files such as OpenSSL PEM files, DER encoded certifictes, PKCS#8 keys and so on. Each various format is identified by a value in the GcrDataFormat enumeration.
In order to parse data, a new parser is created with gcr_parser_new()
and
then the “authenticate” and “parsed” signals should be
connected to. Data is then fed to the parser via gcr_parser_parse_data()
or gcr_parser_parse_stream()
.
During the “parsed” signal the attributes that make up the currently
parsed item can be retrieved using the gcr_parser_get_parsed_attributes()
function.
Functions
gcr_parser_parse_bytes ()
gboolean gcr_parser_parse_bytes (GcrParser *self
,GBytes *data
,GError **error
);
Parse the data. The “parsed” and “authenticate” signals may fire during the parsing.
gcr_parser_parse_data ()
gboolean gcr_parser_parse_data (GcrParser *self
,const guchar *data
,gsize n_data
,GError **error
);
Parse the data. The “parsed” and “authenticate” signals may fire during the parsing.
A copy of the data will be made. Use gcr_parser_parse_bytes()
to avoid this.
gcr_parser_parse_stream ()
gboolean gcr_parser_parse_stream (GcrParser *self
,GInputStream *input
,GCancellable *cancellable
,GError **error
);
Parse items from the data in a GInputStream. This function may block while
reading from the input stream. Use gcr_parser_parse_stream_async()
for
a non-blocking variant.
The “parsed” and “authenticate” signals may fire during the parsing.
gcr_parser_parse_stream_async ()
void gcr_parser_parse_stream_async (GcrParser *self
,GInputStream *input
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Parse items from the data in a GInputStream. This function completes asyncronously and doesn't block.
The “parsed” and “authenticate” signals may fire during the parsing.
gcr_parser_parse_stream_finish ()
gboolean gcr_parser_parse_stream_finish (GcrParser *self
,GAsyncResult *result
,GError **error
);
Complete an operation to parse a stream.
gcr_parser_format_enable ()
void gcr_parser_format_enable (GcrParser *self
,GcrDataFormat format
);
Enable parsing of the given format. Use GCR_FORMAT_ALL
to enable all the formats.
gcr_parser_format_disable ()
void gcr_parser_format_disable (GcrParser *self
,GcrDataFormat format
);
Disable parsing of the given format. Use GCR_FORMAT_ALL
to disable all the formats.
gcr_parser_format_supported ()
gboolean gcr_parser_format_supported (GcrParser *self
,GcrDataFormat format
);
Check whether the given format is supported by the parser.
gcr_parser_add_password ()
void gcr_parser_add_password (GcrParser *self
,const gchar *password
);
Add a password to the set of passwords to try when parsing locked or encrypted items. This is usually called from the “authenticate” signal.
gcr_parser_get_parsed_label ()
const gchar *
gcr_parser_get_parsed_label (GcrParser *self
);
Get the label of the currently parsed item. This is generally only valid during the “parsed” signal.
gcr_parser_get_parsed_description ()
const gchar *
gcr_parser_get_parsed_description (GcrParser *self
);
Get a description for the type of the currently parsed item. This is generally only valid during the “parsed” signal.
gcr_parser_get_parsed_attributes ()
GckAttributes *
gcr_parser_get_parsed_attributes (GcrParser *self
);
Get the attributes which make up the currently parsed item. This is generally only valid during the “parsed” signal.
gcr_parser_get_parsed_block ()
const guchar * gcr_parser_get_parsed_block (GcrParser *self
,gsize *n_block
);
Get the raw data block that represents this parsed object. This is only valid during the “parsed” signal.
gcr_parser_get_parsed_bytes ()
GBytes *
gcr_parser_get_parsed_bytes (GcrParser *self
);
Get the raw data block that represents this parsed object. This is only valid during the “parsed” signal.
gcr_parser_get_parsed_format ()
GcrDataFormat
gcr_parser_get_parsed_format (GcrParser *self
);
Get the format of the raw data block that represents this parsed object.
This corresponds with the data returned from gcr_parser_get_parsed_block()
.
This is only valid during the “parsed” signal.
gcr_parser_get_filename ()
const gchar *
gcr_parser_get_filename (GcrParser *self
);
Get the filename of the parser item.
gcr_parser_set_filename ()
void gcr_parser_set_filename (GcrParser *self
,const gchar *filename
);
Sets the filename of the parser item.
gcr_parsed_ref ()
GcrParsed *
gcr_parsed_ref (GcrParsed *parsed
);
Add a reference to a parsed item. An item may not be shared across threads until it has been referenced at least once.
gcr_parsed_unref ()
void
gcr_parsed_unref (gpointer parsed
);
Unreferences a parsed item which was referenced with gcr_parsed_ref()
gcr_parsed_get_attributes ()
GckAttributes *
gcr_parsed_get_attributes (GcrParsed *parsed
);
Get the attributes which make up the parsed item.
gcr_parsed_get_data ()
const guchar * gcr_parsed_get_data (GcrParsed *parsed
,gsize *n_data
);
Get the raw data block for the parsed item.
gcr_parsed_get_bytes ()
GBytes *
gcr_parsed_get_bytes (GcrParsed *parsed
);
Get the raw data block for the parsed item.
gcr_parsed_get_description ()
const gchar *
gcr_parsed_get_description (GcrParsed *parsed
);
Get the descirption for a parsed item.
gcr_parsed_get_format ()
GcrDataFormat
gcr_parsed_get_format (GcrParsed *parsed
);
Get the format of the parsed item.
gcr_parsed_get_label ()
const gchar *
gcr_parsed_get_label (GcrParsed *parsed
);
Get the label for the parsed item.
gcr_parser_get_parsed ()
GcrParsed *
gcr_parser_get_parsed (GcrParser *self
);
Get the currently parsed item
gcr_parsed_get_filename ()
const gchar *
gcr_parsed_get_filename (GcrParsed *parsed
);
Get the filename of the parsed item.
Types and Values
GCR_DATA_ERROR
#define GCR_DATA_ERROR (gcr_data_error_get_domain ())
A domain for data errors with codes from GcrDataError
enum GcrDataFormat
The various format identifiers.
Members
Represents all the formats, when enabling or disabling |
||
Not a valid format |
||
DER encoded private key |
||
DER encoded RSA private key |
||
DER encoded DSA private key |
||
DER encoded EC private key |
||
DER encoded SubjectPublicKeyInfo |
||
DER encoded X.509 certificate |
||
DER encoded PKCS#7 container file which can contain certificates |
||
DER encoded PKCS#8 file which can contain a key |
||
Unencrypted DER encoded PKCS#8 file which can contain a key |
||
Encrypted DER encoded PKCS#8 file which can contain a key |
||
DER encoded PKCS#10 certificate request file |
||
DER encoded SPKAC as generated by HTML5 keygen element |
||
OpenSSL style SPKAC data |
||
DER encoded PKCS#12 file which can contain certificates and/or keys |
||
OpenSSH v1 or v2 public key |
||
OpenPGP key packet(s) |
||
OpenPGP public or private key armor encoded data |
||
An OpenSSL style PEM file with unspecified contents |
||
An OpenSSL style PEM file with a private RSA key |
||
An OpenSSL style PEM file with a private DSA key |
||
An OpenSSL style PEM file with an X.509 certificate |
||
An OpenSSL style PEM file containing PKCS#7 |
||
Unencrypted OpenSSL style PEM file containing PKCS#8 |
||
Encrypted OpenSSL style PEM file containing PKCS#8 |
||
An OpenSSL style PEM file containing PKCS#12 |
||
An OpenSSL style PEM file with a private key |
||
An OpenSSL style PEM file containing PKCS#10 |
||
An OpenSSL style PEM file with a private EC key |
||
An OpenSSL style PEM file containing a SubjectPublicKeyInfo |
struct GcrParserClass
struct GcrParserClass { GObjectClass parent_class; /* signals --------------------------------------------------------- */ /* A callback for each password needed */ gboolean (*authenticate) (GcrParser *self, gint count); void (*parsed) (GcrParser *self); };
The class for GcrParser
Property Details
The “parsed-attributes”
property
“parsed-attributes” GckAttributes *
Get the attributes that make up the currently parsed item. This is generally only valid during a “parsed” signal.
Flags: Read
The “parsed-description”
property
“parsed-description” gchar *
The description of the type of the currently parsed item. This is generally only valid during a “parsed” signal.
Flags: Read
Default value: ""
The “parsed-label”
property
“parsed-label” gchar *
The label of the currently parsed item. This is generally only valid during a “parsed” signal.
Flags: Read
Default value: ""
Signal Details
The “authenticate”
signal
gboolean user_function (GcrParser *self, gint count, gpointer user_data)
This signal is emitted when an item needs to be unlocked or decrypted before
it can be parsed. The count
argument specifies the number of times
the signal has been emitted for a given item. This can be used to
display a message saying the previous password was incorrect.
Typically the gcr_parser_add_password()
function is called in
response to this signal.
If FALSE
is returned, then the authentication was not handled. If
no handlers return TRUE
then the item is not parsed and an error
with the code GCR_ERROR_CANCELLED
will be raised.
Parameters
self |
the parser |
|
count |
the number of times this item has been authenticated |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
The “parsed”
signal
void user_function (GcrParser *self, gpointer user_data)
This signal is emitted when an item is sucessfully parsed. To access
the information about the item use the gcr_parser_get_parsed_label()
,
gcr_parser_get_parsed_attributes()
and gcr_parser_get_parsed_description()
functions.
Flags: Run First