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); }
int gkm_rpc_message_write_space_string (GkmRpcMessage *msg, CK_UTF8CHAR* buffer, CK_ULONG length) { assert (msg); assert (buffer); assert (length); assert (!msg->signature || gkm_rpc_message_verify_part (msg, "s")); return egg_buffer_add_byte_array (&msg->buffer, buffer, length); }
int gkm_rpc_message_write_byte_array (GkmRpcMessage *msg, CK_BYTE_PTR arr, CK_ULONG num) { assert (msg); /* Make sure this is in the right order */ assert (!msg->signature || gkm_rpc_message_verify_part (msg, "ay")); /* No array, no data, just length */ if (!arr) { egg_buffer_add_byte (&msg->buffer, 0); egg_buffer_add_uint32 (&msg->buffer, num); } else { egg_buffer_add_byte (&msg->buffer, 1); egg_buffer_add_byte_array (&msg->buffer, arr, num); } return !egg_buffer_has_error (&msg->buffer); }
int gkm_rpc_message_prep (GkmRpcMessage *msg, int call_id, GkmRpcMessageType type) { int len; assert (type); assert (call_id >= GKM_RPC_CALL_ERROR); assert (call_id < GKM_RPC_CALL_MAX); gkm_rpc_message_reset (msg); if (call_id != GKM_RPC_CALL_ERROR) { /* The call id and signature */ if (type == GKM_RPC_REQUEST) msg->signature = gkm_rpc_calls[call_id].request; else if (type == GKM_RPC_RESPONSE) msg->signature = gkm_rpc_calls[call_id].response; else assert (0 && "invalid message type"); assert (msg->signature); msg->sigverify = msg->signature; } msg->call_id = call_id; msg->call_type = type; /* Encode the two of them */ egg_buffer_add_uint32 (&msg->buffer, call_id); if (msg->signature) { len = strlen (msg->signature); egg_buffer_add_byte_array (&msg->buffer, (unsigned char*)msg->signature, len); } msg->parsed = 0; return !egg_buffer_has_error (&msg->buffer); }
int gkm_rpc_message_write_attribute_array (GkmRpcMessage *msg, CK_ATTRIBUTE_PTR arr, CK_ULONG num) { CK_ULONG i; CK_ATTRIBUTE_PTR attr; unsigned char validity; assert (!num || arr); assert (msg); /* Make sure this is in the rigth order */ assert (!msg->signature || gkm_rpc_message_verify_part (msg, "aA")); /* Write the number of items */ egg_buffer_add_uint32 (&msg->buffer, num); for (i = 0; i < num; ++i) { attr = &(arr[i]); /* The attribute type */ egg_buffer_add_uint32 (&msg->buffer, attr->type); /* Write out the attribute validity */ validity = (((CK_LONG)attr->ulValueLen) == -1) ? 0 : 1; egg_buffer_add_byte (&msg->buffer, validity); /* The attribute length and value */ if (validity) { egg_buffer_add_uint32 (&msg->buffer, attr->ulValueLen); egg_buffer_add_byte_array (&msg->buffer, attr->pValue, attr->ulValueLen); } } return !egg_buffer_has_error (&msg->buffer); }
gboolean gkd_ssh_agent_proto_write_signature_dsa (EggBuffer *resp, CK_BYTE_PTR signature, CK_ULONG n_signature) { g_return_val_if_fail (n_signature == 40, FALSE); return egg_buffer_add_byte_array (resp, signature, n_signature); }
gboolean gkd_ssh_agent_proto_write_signature_rsa (EggBuffer *resp, CK_BYTE_PTR signature, CK_ULONG n_signature) { return egg_buffer_add_byte_array (resp, signature, n_signature); }