static CK_RV gkm_credential_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATTRIBUTE *attr) { GkmCredential *self = GKM_CREDENTIAL (base); CK_OBJECT_HANDLE handle; gconstpointer value; gsize n_value; switch (attr->type) { case CKA_CLASS: return gkm_attribute_set_ulong (attr, CKO_G_CREDENTIAL); case CKA_PRIVATE: return gkm_attribute_set_bool (attr, TRUE); case CKA_G_OBJECT: handle = self->pv->object ? gkm_object_get_handle (self->pv->object) : 0; return gkm_attribute_set_ulong (attr, handle); case CKA_VALUE: if (gkm_session_is_for_application (session)) return CKR_ATTRIBUTE_SENSITIVE; if (!self->pv->secret) { value = NULL; n_value = 0; } else { value = gkm_secret_get (self->pv->secret, &n_value); } return gkm_attribute_set_data (attr, value, n_value); }; return GKM_OBJECT_CLASS (gkm_credential_parent_class)->get_attribute (base, session, attr); }
static gboolean buffer_add_secret (EggBuffer *buffer, GkmSecret *secret) { const guchar *data = NULL; gsize n_data = 0; if (secret != NULL) data = gkm_secret_get (secret, &n_data); return egg_buffer_add_byte_array (buffer, data, n_data); }