diff --git a/src/mconn-crypt.c b/src/mconn-crypt.c index 7a691c6..fdf63d5 100644 --- a/src/mconn-crypt.c +++ b/src/mconn-crypt.c @@ -22,6 +22,20 @@ #include #include "mconn-crypt.h" +typedef struct _MConnCryptPrivate MConnCryptPrivate; + +/** + * MConnCrypt: + * + * A simple wrapper for cypto operations. + **/ + +struct _MConnCrypt +{ + GObject parent; + MConnCryptPrivate *priv; +}; + struct _MConnCryptPrivate { RSA *key; /* RSA key wrapper */ @@ -87,6 +101,12 @@ MConnCrypt *mconn_crypt_new_for_key_path(const char *path) return self; } +MConnCrypt * mconn_crypt_ref(MConnCrypt *self) +{ + g_assert(IS_MCONN_CRYPT(self)); + return MCONN_CRYPT(g_object_ref(self)); +} + void mconn_crypt_unref(MConnCrypt *self) { if (self != NULL) diff --git a/src/mconn-crypt.h b/src/mconn-crypt.h index dd84f8b..a131521 100644 --- a/src/mconn-crypt.h +++ b/src/mconn-crypt.h @@ -1,6 +1,6 @@ /* ex:ts=4:sw=4:sts=4:et */ /* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/** +/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. @@ -14,14 +14,13 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * AUTHORS - * Maciek Borzecki + * Author: Maciek Borzecki */ #ifndef __MCONN_CRYPT_H__ #define __MCONN_CRYPT_H__ #include - +#include G_BEGIN_DECLS @@ -48,25 +47,54 @@ G_BEGIN_DECLS typedef struct _MConnCrypt MConnCrypt; typedef struct _MConnCryptClass MConnCryptClass; -typedef struct _MConnCryptPrivate MConnCryptPrivate; - struct _MConnCryptClass { GObjectClass parent_class; }; -struct _MConnCrypt -{ - GObject parent; - MConnCryptPrivate *priv; -}; - GType mconn_crypt_get_type (void) G_GNUC_CONST; +/** + * mconn_crypt_new_for_key_path: + * @path: key path + * + * Returns: (transfer full) (element-type MConnCrypt): new object + */ MConnCrypt *mconn_crypt_new_for_key_path(const char *path); + +/** + * mconn_crypt_unref: + * @crypt: crypt object + */ +void mconn_crypt_unref(MConnCrypt *crypt); + +/** + * mconn_crypt_ref: + * @crypt: crypt object + * + * Take reference to crypt object + * Returns: (transfer none): reffed object + */ void mconn_crypt_unref(MConnCrypt *crypt); -GBytes * mconn_crypt_decrypt(MConnCrypt *crypt, GBytes *data, GError **err); + +/** + * mconn_crypt_decrypt: + * @crypt: crypt object + * @data: (type GBytes): data + * @error: return location for a GError or NULL + * + * Returns: (transfer full): a new #GBytes with decoded data + */ +GBytes * mconn_crypt_decrypt(MConnCrypt *crypt, GBytes *data, GError **error); + +/** + * mconn_crypt_get_public_key_pem: + * @crypt: crypt object + * + * Returns: (transfer full): allocated string with public key in PEM format + */ gchar * mconn_crypt_get_public_key_pem(MConnCrypt *crypt); + G_END_DECLS #endif /* __MCONN_CRYPT_H__ */