From 182ad1c481c29e40e6548ec1e87b75c49ac567fe Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Sun, 4 Apr 2021 16:09:36 +0200 Subject: [PATCH] define own protocol family for storage security --- .gitignore | 3 +++ asn.1/Makefile | 9 +++++++-- codegen/Makefile | 6 ++++-- codegen/storage.fsm | 21 +++++++++++++++++++++ src/Makefile | 4 ++-- src/pEpEngine.h | 1 + 6 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 codegen/storage.fsm diff --git a/.gitignore b/.gitignore index 222c125e..74e8685d 100644 --- a/.gitignore +++ b/.gitignore @@ -69,10 +69,13 @@ src/KeySync_* src/Sync_* src/sync_codec.* src/distribution_codec.* +src/storage_codec.* asn.1/keysync.asn1 asn.1/keyreset.asn1 asn.1/sync.asn1 asn.1/distribution.asn1 +asn.1/storage.asn1 +asn.1/messagestorage.asn1 sync/.codecs sync/.messages sync/.actions diff --git a/asn.1/Makefile b/asn.1/Makefile index 59875bc6..d1af13bd 100644 --- a/asn.1/Makefile +++ b/asn.1/Makefile @@ -10,7 +10,7 @@ ASN1C_INC+= -I. .PHONY: all clean install uninstall -all: Sync.c Distribution.c +all: Sync.c Distribution.c Storage.c $(MAKE) libasn1.a libasn1.a: $(ALL_OBJECTS) @@ -29,8 +29,13 @@ Distribution.c: distribution.asn1 keyreset.asn1 managedgroup.asn1 pEp.asn1 rm -f converter-sample.c touch Distribution.c +Storage.c: storage.asn1 messagestorage.asn1 pEp.asn1 + $(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 messagestorage.asn1 $< + rm -f converter-sample.c + touch Storage.c + clean: - rm -f *.a *.o *.c *.h *.sample sync.asn1 keysync.asn1 distribution.asn1 keyreset.asn1 managedgroup.asn1 + rm -f *.a *.o *.c *.h *.sample sync.asn1 keysync.asn1 distribution.asn1 keyreset.asn1 managedgroup.asn1 storage.asn1 messagestorage.asn1 install: diff --git a/codegen/Makefile b/codegen/Makefile index 8b586b20..a8f9b442 100644 --- a/codegen/Makefile +++ b/codegen/Makefile @@ -16,14 +16,16 @@ generated: .statemachines: sync.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2 | generated $(YML2_PROC) -y gen_statemachine.ysl2 $< -o $@ -.codecs: sync.fsm distribution.fsm gen_codec.ysl2 fsm.yml2 functions.ysl2 | generated +.codecs: sync.fsm distribution.fsm storage.fsm gen_codec.ysl2 fsm.yml2 functions.ysl2 | generated $(YML2_PROC) -y gen_codec.ysl2 $< -o $@ $(YML2_PROC) -y gen_codec.ysl2 distribution.fsm -o $@ + $(YML2_PROC) -y gen_codec.ysl2 storage.fsm -o $@ -.messages: sync.fsm distribution.fsm gen_messages.ysl2 gen_message_func.ysl2 fsm.yml2 functions.ysl2 | generated +.messages: sync.fsm distribution.fsm storage.fsm gen_messages.ysl2 gen_message_func.ysl2 fsm.yml2 functions.ysl2 | generated $(YML2_PROC) -y gen_messages.ysl2 $< -o $@ $(YML2_PROC) -y gen_message_func.ysl2 $< -o $@ $(YML2_PROC) -y gen_messages.ysl2 distribution.fsm -o $@ + $(YML2_PROC) -y gen_messages.ysl2 storage.fsm -o $@ clean: rm -rf generated diff --git a/codegen/storage.fsm b/codegen/storage.fsm new file mode 100644 index 00000000..9811c4c6 --- /dev/null +++ b/codegen/storage.fsm @@ -0,0 +1,21 @@ +// This file is under BSD License 2.0 + +// Storage protocol for p≡p +// Copyright (c) 2021, p≡p foundation + +// Written by Volker Birk + +include ./fsm.yml2 + +protocol Storage 3 { + + // this protocol is stateless + fsm MessageStorage 1 { + version 1, 0; + + message ReceiverRating 2, security=ignore { + field Rating rating; + } + } +} + diff --git a/src/Makefile b/src/Makefile index 210d1f7f..0ccd5c24 100644 --- a/src/Makefile +++ b/src/Makefile @@ -95,7 +95,7 @@ libpEpEngine.a: $(ALL_OBJECTS) clean: rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~ rm -Rf $(TARGET).dSYM - rm -f KeySync_fsm.* Sync_actions.c Sync_event.* Sync_func.* Sync_impl.* sync_codec.* distribution_codec.* + rm -f KeySync_fsm.* Sync_actions.c Sync_event.* Sync_func.* Sync_impl.* sync_codec.* distribution_codec.* storage_codec.* # CAVEAT: # install_headers is needed for building *STANDALONE* pEp MIME - it is NOT used for built-in functionality!!! @@ -105,7 +105,7 @@ install_headers: $(TARGET) cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \ timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \ cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h engine_sql.h \ - labeled_int_list.h key_reset.h base64.h sync_codec.h distribution_codec.h \ + labeled_int_list.h key_reset.h base64.h sync_codec.h distribution_codec.h storage_codec.h \ status_to_string.h aux_mime_msg.h keyreset_command.h platform.h platform_unix.h ../asn.1/*.h \ $(PREFIX)/include/pEp/ diff --git a/src/pEpEngine.h b/src/pEpEngine.h index a2f88c6f..2496191b 100644 --- a/src/pEpEngine.h +++ b/src/pEpEngine.h @@ -159,6 +159,7 @@ typedef enum { PEP_CANNOT_RETRIEVE_MEMBERSHIP_INFO = 0x0b0b, PEP_DISTRIBUTION_ILLEGAL_MESSAGE = 0x1002, + PEP_STORAGE_ILLEGAL_MESSAGE = 0x1102, PEP_COMMIT_FAILED = 0xff01, PEP_MESSAGE_CONSUME = 0xff02,