gboolean
gkd_ssh_agent_proto_read_pair_dsa (EggBuffer *req, gsize *offset,
                                   GckAttributes *priv_attrs, GckAttributes *pub_attrs)
{
	GckAttribute *attr;

	g_assert (req);
	g_assert (offset);
	g_assert (priv_attrs);
	g_assert (pub_attrs);

	if (!gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_PRIME) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_SUBPRIME) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_BASE) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, pub_attrs, CKA_VALUE) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_VALUE))
		return FALSE;

	/* Copy attributes to the public key */
	attr = gck_attributes_find (priv_attrs, CKA_PRIME);
	gck_attributes_add (pub_attrs, attr);
	attr = gck_attributes_find (priv_attrs, CKA_SUBPRIME);
	gck_attributes_add (pub_attrs, attr);
	attr = gck_attributes_find (priv_attrs, CKA_BASE);
	gck_attributes_add (pub_attrs, attr);

	/* Add in your basic other required attributes */
	gck_attributes_add_ulong (priv_attrs, CKA_CLASS, CKO_PRIVATE_KEY);
	gck_attributes_add_ulong (priv_attrs, CKA_KEY_TYPE, CKK_DSA);
	gck_attributes_add_ulong (pub_attrs, CKA_CLASS, CKO_PUBLIC_KEY);
	gck_attributes_add_ulong (pub_attrs, CKA_KEY_TYPE, CKK_DSA);

	return TRUE;
}
gboolean
gkd_ssh_agent_proto_read_public_rsa (EggBuffer *req, gsize *offset, GckAttributes *attrs)
{
	g_assert (req);
	g_assert (offset);
	g_assert (attrs);

	if (!gkd_ssh_agent_proto_read_mpi (req, offset, attrs, CKA_PUBLIC_EXPONENT) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, attrs, CKA_MODULUS))
		return FALSE;

	/* Add in your basic other required attributes */
	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_PUBLIC_KEY);
	gck_attributes_add_ulong (attrs, CKA_KEY_TYPE, CKK_RSA);

	return TRUE;
}
gboolean
gkd_ssh_agent_proto_read_public_dsa (EggBuffer *req,
                                     gsize *offset,
                                     GckBuilder *attrs)
{
	g_assert (req);
	g_assert (offset);
	g_assert (attrs);

	if (!gkd_ssh_agent_proto_read_mpi (req, offset, attrs, CKA_PRIME) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, attrs, CKA_SUBPRIME) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, attrs, CKA_BASE) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, attrs, CKA_VALUE))
		return FALSE;

	/* Add in your basic other required attributes */
	gck_builder_add_ulong (attrs, CKA_CLASS, CKO_PUBLIC_KEY);
	gck_builder_add_ulong (attrs, CKA_KEY_TYPE, CKK_DSA);

	return TRUE;
}
gboolean
gkd_ssh_agent_proto_read_pair_rsa (EggBuffer *req,
                                   gsize *offset,
                                   GckBuilder *priv_attrs,
                                   GckBuilder *pub_attrs)
{
	const GckAttribute *attr;

	g_assert (req);
	g_assert (offset);
	g_assert (priv_attrs);
	g_assert (pub_attrs);

	if (!gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_MODULUS) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_PUBLIC_EXPONENT) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_PRIVATE_EXPONENT) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_COEFFICIENT) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_PRIME_1) ||
	    !gkd_ssh_agent_proto_read_mpi (req, offset, priv_attrs, CKA_PRIME_2))
		return FALSE;

	/* Copy attributes to the public key */
	attr = gck_builder_find (priv_attrs, CKA_MODULUS);
	gck_builder_add_attribute (pub_attrs, attr);
	attr = gck_builder_find (priv_attrs, CKA_PUBLIC_EXPONENT);
	gck_builder_add_attribute (pub_attrs, attr);

	/* Add in your basic other required attributes */
	gck_builder_add_ulong (priv_attrs, CKA_CLASS, CKO_PRIVATE_KEY);
	gck_builder_add_ulong (priv_attrs, CKA_KEY_TYPE, CKK_RSA);
	gck_builder_add_ulong (pub_attrs, CKA_CLASS, CKO_PUBLIC_KEY);
	gck_builder_add_ulong (pub_attrs, CKA_KEY_TYPE, CKK_RSA);

	return TRUE;
}