|
|
|
@ -30,28 +30,30 @@ struct rdf_enum types = {
|
|
|
|
|
.filter = type_filter,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct rdf_serialize_field ap_activity_rdf[];
|
|
|
|
|
struct rdf_serialize_field ap_object_rdf[];
|
|
|
|
|
|
|
|
|
|
static struct rdf_serialize_field activity_ref_types[] = {
|
|
|
|
|
{ (char*)apaot_ref, offsetof( struct ap_activity, object.ref ), &rdf_string_field },
|
|
|
|
|
{ (char*)apaot_activity, offsetof( struct ap_activity, object.ptr ), &rdf_object_field, &ap_activity_rdf },
|
|
|
|
|
{ (char*)apaot_ref, offsetof( struct ap_object, object.ref ), &rdf_string_field },
|
|
|
|
|
{ (char*)apaot_activity, offsetof( struct ap_object, object.ptr ), &rdf_object_field, &ap_object_rdf },
|
|
|
|
|
{ NULL },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct rdf_serialize_field ap_activity_rdf[] = {
|
|
|
|
|
{ "", offsetof( struct ap_activity, id ), &rdf_id_field },
|
|
|
|
|
{ "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>", offsetof( struct ap_activity, type ), &rdf_enum_field, &types },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#actor>", offsetof( struct ap_activity, actor ), &rdf_string_ref_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#content>", offsetof( struct ap_activity, content ), &rdf_string_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#published>", offsetof( struct ap_activity, published ), &rdf_date_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#to>", offsetof( struct ap_activity, to ), &rdf_array_of_field, &rdf_string_ref_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#cc>", offsetof( struct ap_activity, cc ), &rdf_array_of_field, &rdf_string_ref_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#bcc>", offsetof( struct ap_activity, bcc ), &rdf_array_of_field, &rdf_string_ref_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#object>", offsetof( struct ap_activity, object.tag ), &rdf_tagged_union_field, activity_ref_types },
|
|
|
|
|
{ NULL, sizeof(struct ap_activity) },
|
|
|
|
|
#define OBJ_TYPE struct ap_object
|
|
|
|
|
struct rdf_serialize_field ap_object_rdf[] = {
|
|
|
|
|
{ "", offsetof( OBJ_TYPE, id ), &rdf_id_field },
|
|
|
|
|
{ "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>", offsetof( OBJ_TYPE, type ), &rdf_enum_field, &types },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#actor>", offsetof( OBJ_TYPE, actor ), &rdf_string_ref_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#content>", offsetof( OBJ_TYPE, content ), &rdf_string_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#published>", offsetof( OBJ_TYPE, published ), &rdf_date_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#to>", offsetof( OBJ_TYPE, to ), &rdf_array_of_field, &rdf_string_ref_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#cc>", offsetof( OBJ_TYPE, cc ), &rdf_array_of_field, &rdf_string_ref_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#bcc>", offsetof( OBJ_TYPE, bcc ), &rdf_array_of_field, &rdf_string_ref_field },
|
|
|
|
|
{ "<https://www.w3.org/ns/activitystreams#object>", offsetof( OBJ_TYPE, object.tag ), &rdf_tagged_union_field, activity_ref_types },
|
|
|
|
|
{ NULL, sizeof(struct ap_object) },
|
|
|
|
|
};
|
|
|
|
|
#undef OBJ_TYPE
|
|
|
|
|
|
|
|
|
|
struct rdf_serialize_field ap_activity_signature_rdf[] = {
|
|
|
|
|
struct rdf_serialize_field ap_signature_rdf[] = {
|
|
|
|
|
{ "", 0, &rdf_id_blank },
|
|
|
|
|
{ "<http://purl.org/dc/terms/creator>", offsetof( struct ap_signature, creator ), &rdf_string_ref_field },
|
|
|
|
|
{ "<http://purl.org/dc/terms/created>", offsetof( struct ap_signature, created ), &rdf_date_field },
|
|
|
|
@ -84,9 +86,9 @@ static void write_normalized_rdf( struct rdf_serialize_field* layout, void* obje
|
|
|
|
|
free((char*)rs.graph);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ap_activity_write_normalized_rdf( struct ap_activity* act, FILE* out )
|
|
|
|
|
void ap_activity_write_normalized_rdf( struct ap_object* act, FILE* out )
|
|
|
|
|
{
|
|
|
|
|
write_normalized_rdf( ap_activity_rdf, act, out );
|
|
|
|
|
write_normalized_rdf( ap_object_rdf, act, out );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char* serialize_normalized_object( struct rdf_serialize_field* layout, void* object, size_t* result_size )
|
|
|
|
@ -131,7 +133,7 @@ static bool calculate_hash_for_object( struct rdf_serialize_field* layout, void*
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ap_activity_create_rsa_signature_2017( struct ap_activity* act, struct crypto_keys* keys )
|
|
|
|
|
bool ap_activity_create_rsa_signature_2017( struct ap_object* act, struct crypto_keys* keys )
|
|
|
|
|
{
|
|
|
|
|
char* signature_buf = NULL;
|
|
|
|
|
printf( "ap_activity_create_rsa_signature_2017\n" );
|
|
|
|
@ -141,8 +143,8 @@ bool ap_activity_create_rsa_signature_2017( struct ap_activity* act, struct cryp
|
|
|
|
|
act->signature.created = time(NULL);
|
|
|
|
|
|
|
|
|
|
char raw_hash[64];
|
|
|
|
|
if( !calculate_hash_for_object( ap_activity_rdf, act, &raw_hash[0] ) ) { return NULL; }
|
|
|
|
|
if( !calculate_hash_for_object( ap_activity_signature_rdf, &act->signature, &raw_hash[32] ) ) { return NULL; }
|
|
|
|
|
if( !calculate_hash_for_object( ap_object_rdf, act, &raw_hash[0] ) ) { return NULL; }
|
|
|
|
|
if( !calculate_hash_for_object( ap_signature_rdf, &act->signature, &raw_hash[32] ) ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
char* sign = crypto_keys_sign( keys, raw_hash, 64 );
|
|
|
|
|
act->signature.value = sign;
|
|
|
|
|