Merge branch 'master' into ENGINE-847

ENGINE-847
Krista Bennett 2 years ago
commit d450746875

@ -19,7 +19,7 @@ STORAGE_FILES = $(addsuffix .asn1, $(STORAGE))
.PHONY: all clean install uninstall
all: Sync.c Distribution.c Storage.c PEPMessage.c
all: Sync.c Distribution.c Storage.c ASN1Message.c
$(MAKE) libasn1.a
libasn1.a: $(ALL_OBJECTS)
@ -43,10 +43,10 @@ Storage.c: $(STORAGE_FILES) pEp.asn1
rm -f converter-sample.c
touch Storage.c
PEPMessage.c: message.asn1 pEp.asn1
ASN1Message.c: message.asn1 pEp.asn1
$(ASN1C) -gen-PER $(ASN1C_OPTIONS) $+
rm -f converter-sample.c
touch PEPMessage.c
touch ASN1Message.c
clean:
rm -f *.a *.o *.c *.h *.sample \

@ -14,10 +14,10 @@ DEFINITIONS
AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
BEGIN
EXPORTS PEPMessage;
EXPORTS ASN1Message;
IMPORTS
PString, PStringList, Identity, IdentityList, StringPairList, Hash
PString, PStringList, Identity, IdentityList, PStringPairList, Hash
FROM PEP { iso(1) org(3) dod(6) internet(1) private(4)
enterprise(1) pEp(47878) basic(0) };
@ -33,30 +33,26 @@ ContentDisposition ::= ENUMERATED {
other (2)
}
Blob ::= SEQUENCE {
PBlob ::= SEQUENCE {
value OCTET STRING (SIZE(0..102400000)), -- up to 100 MB
mime-type PString OPTIONAL,
filename PString OPTIONAL,
disposition ContentDisposition
}
BlobList ::= SEQUENCE OF Blob
PBlobList ::= SEQUENCE OF PBlob
-- For the purposes of this profile, GeneralizedTime values MUST be
-- expressed in Coordinated Universal Time (UTC) and MUST include seconds
-- (i.e., times are YYYYMMDDHHMMSSZ), even where the number of seconds
-- is zero. GeneralizedTime values MUST NOT include fractional seconds.
-- To make this more explicit, the type-name "Timestamp" is used in this
-- profile.
Timestamp ::= GeneralizedTime
PEPMessage ::= SEQUENCE {
ASN1Message ::= SEQUENCE {
direction MessageDirection OPTIONAL, -- used only in "inner" messages
id PString OPTIONAL, -- UTF-8 string of message ID
sent Timestamp OPTIONAL, -- when the message is sent
recv Timestamp OPTIONAL, -- when the message is received
sent GeneralizedTime OPTIONAL, -- when the message is sent
recv GeneralizedTime OPTIONAL, -- when the message is received
from Identity, -- whom the message is from
-- At least one of to, cc must not be an empty list
-- FIXME: Can this be constrained?
@ -74,7 +70,7 @@ PEPMessage ::= SEQUENCE {
-- internal: refered_by _message-ref-list
keywords PStringList OPTIONAL, -- list of UTF-8 strings with keywords
comments PString OPTIONAL, -- UTF-8 string with comments
opt-fields StringPairList OPTIONAL, -- optional fields
opt-fields PStringPairList OPTIONAL, -- optional fields
sender-fpr Hash OPTIONAL, -- fingerprint of sending signer
-- At least one of shortmsg, longmsg, longmsg-formatted must be present
@ -90,7 +86,7 @@ PEPMessage ::= SEQUENCE {
longmsg-formatted UTF8String OPTIONAL, -- UTF-8 string of long message
-- (formatted)
attachments BlobList OPTIONAL -- blobs with attachments
attachments PBlobList OPTIONAL -- blobs with attachments
-- internal: rawmsg
}

@ -12,7 +12,7 @@ DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
BEGIN
EXPORTS Identity, IdentityList, TID, Hash, Version, Rating, PString, PStringList, StringPair, StringPairList;
EXPORTS Identity, IdentityList, TID, Hash, Version, Rating, PString, PStringList, PStringPair, PStringPairList;
ISO639-1 ::= PrintableString(FROM ("a".."z")) (SIZE(2))
Hex ::= PrintableString(FROM ("A".."F" | "0".."9"))
@ -63,12 +63,12 @@ Rating ::= ENUMERATED {
under-attack (-3)
}
StringPair ::= SEQUENCE {
PStringPair ::= SEQUENCE {
key PString,
value PString
}
StringPairList ::= SEQUENCE OF StringPair
PStringPairList ::= SEQUENCE OF PStringPair
END

@ -44,5 +44,5 @@ svg: $(patsubst %.dot,%.svg,$(wildcard *.dot))
$(YML2_PROC) -y gen_dot.ysl2 $< -o $@
%.svg: %.dot
dot -Tsvg -o $@ $<
dot -Tsvg $< -o $@ > /dev/null

@ -4,7 +4,7 @@
include yslt.yml2
tstylesheet {
template "protocol/fsm[count(state)>0]" document "{@name}.dot", "text"
template "/protocol/fsm[count(state)>0]"
||
digraph finite_state_machine {
rankdir=LR;

@ -1,43 +1,56 @@
<!-- Copyright 2015-2017, pEp foundation, Switzerland
<!-- Copyright 2015-2021, pEp foundation, Switzerland
This file is part of the pEp Engine
This file may be used under the terms of the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) License
See CC_BY-SA.txt -->
# Build instructions for Debian 9
# Build instructions for Debian 9 and 10
We assume the user keeps sources under `~/pep-src`. There is no single
installation prefix: each package is built, or when supported installed, in
either its source directory or in a subdirectory of its source directory.
Rationale: we do not pollute the user system, uninstalling is trivial.
This is Unix: we assume no spaces in user names.
~~~
mkdir -p ~/pep-src
~~~
# Installing packaged dependencies
~~~
# general
apt install -y mercurial
# YML2
apt install -y python-lxml
apt install -y git
# libetpan
apt install -y git build-essential automake libtool
# asn1c
apt install -y git build-essential automake libtool autoconf
# sequoia
apt install git rustc cargo clang libclang-dev make pkg-config nettle-dev libssl-dev capnproto libsqlite3-dev
# engine
apt install -y uuid-dev libgpgme-dev libsqlite3-dev sqlite3
# optional: developer documentation
apt install -y doxygen pandoc
~~~
# Installing unpackaged dependencies
## YML2
~~~
mkdir -p ~/code/yml2
git clone https://gitea.pep.foundation/fdik/yml2.git ~/code/yml2
mkdir -p ~/pep-src/yml2
git clone https://gitea.pep.foundation/fdik/yml2.git ~/pep-src/yml2
~~~
## libetpan
pEp Engine requires libetpan with a set of patches that have not been upstreamed yet.
~~~
mkdir -p ~/code/libetpan
mkdir -p ~/pep-src/libetpan
git clone https://gitea.pep.foundation/pEp.foundation/libetpan.git ~/code/libetpan
cd ~/code/libetpan
mkdir ~/code/libetpan/build
./autogen.sh --prefix="$HOME/code/libetpan/build"
git clone https://gitea.pep.foundation/pEp.foundation/libetpan.git ~/pep-src/libetpan
cd ~/pep-src/libetpan
mkdir ~/pep-src/libetpan/build
./autogen.sh --prefix="$HOME/pep-src/libetpan/build"
make
make install
~~~
@ -45,45 +58,70 @@ make install
## asn1c
~~~
mkdir -p ~/code/asn1c
git clone git://github.com/vlm/asn1c.git ~/code/asn1c
cd ~/code/asn1c
mkdir -p ~/pep-src/asn1c
git clone git://github.com/vlm/asn1c.git ~/pep-src/asn1c
cd ~/pep-src/asn1c
git checkout tags/v0.9.28 -b pep-engine
autoreconf -iv
mkdir ~/code/asn1c/build
./configure --prefix="$HOME/code/asn1c/build"
mkdir ~/pep-src/asn1c/build
./configure --prefix="$HOME/pep-src/asn1c/build"
make
make install
~~~
## sequoia
~~~
git clone https://gitlab.com/sequoia-pgp/sequoia
cd ~/pep-src/sequoia
git checkout openpgp/v1.3.0
# Make an optimised sequoia build.
cargo build --all --release -j16
~~~
This alternative for the last line above is faster, but generates compiled libraries
in `~/pep-src/sequoia/target/debug` instead of `~/pep-src/sequoia/target/release`:
several definitions below need to be adapted.
~~~
# Alternative: make a debugging sequoia build.
cargo build --all -j16
~~~
# pEp Engine
~~~
mkdir -p ~/code/pep-engine
hg clone https://pep.foundation/dev/repos/pEpEngine/ ~/code/pep-engine
cd ~/code/pep-engine
mkdir ~/code/pep-engine/build
mkdir -p ~/pep-src/pep-engine
git clone https://gitea.pep.foundation/pEp.foundation/pEpEngine ~/pep-src/pep-engine
cd ~/pep-src/pep-engine
mkdir build
~~~
Edit the build configuration to your needs in `Makefile.conf`, or create a `local.conf` that sets any of the make variables documented in `Makefile.conf`. All the default values for the build configuration variables on each platform are documented in `Makefile.conf`.
Edit the build configuration to your needs in `Makefile.conf`, or create a `local.conf` in your source directory (the same containing `Makefile.conf`) that sets any of the make variables documented in `Makefile.conf`. All the default values for the build configuration variables on each platform are documented in `Makefile.conf`.
If a dependency is not found in your system's default include or library paths, you will have to specify the according paths in a make variable. Typically, this has to be done at least for YML2, libetpan and asn1c.
For a more detailed explanation of the mechanics of these build configuration files, and overriding defaults, see the comments in `Makefile.conf`.
Below is a sample `./local.conf` file, for orientation.
The following `./local.conf` example should work in the configuration described here.
~~~
PREFIX=$(HOME)/code/pep-engine/build
PREFIX=$(HOME)/pep-src/pep-engine/build
PER_MACHINE_DIRECTORY=$(PREFIX)/share/pEp
YML2_PATH=$(HOME)/code/yml2
YML2_PATH=$(HOME)/pep-src/yml2
ETPAN_LIB=-L$(HOME)/pep-src/libetpan/build/lib
ETPAN_INC=-I$(HOME)/pep-src/libetpan/build/include
ASN1C=$(HOME)/pep-src/asn1c/build/bin/asn1c
ASN1C_INC=-I$(HOME)/pep-src/asn1c/build/share/asn1c
ETPAN_LIB=-L$(HOME)/code/libetpan/build/lib
ETPAN_INC=-I$(HOME)/code/libetpan/build/include
SEQUOIA_INC=-I$(HOME)/pep-src/sequoia/openpgp-ffi/include
SEQUOIA_LDFLAGS=-L$(HOME)/pep-src/sequoia/target/release
ASN1C=$(HOME)/code/asn1c/build/bin/asn1c
ASN1C_INC=-I$(HOME)/code/asn1c/build/share/asn1c
GTEST_SRC_DIR=$(HOME)/pep-src/googletest/googletest
GTEST_INC_DIR=$(HOME)/pep-src/googletest/googletest/include
GTEST_PL=$(HOME)/pep-src/gtest-parallel/gtest_parallel.py
~~~
The engine is built as follows:

@ -131,7 +131,6 @@ IdentityList_t *IdentityList_from_identity_list(
{
bool allocated = !result;
assert(list && list->ident);
if (!(list && list->ident))
return NULL;
@ -190,9 +189,9 @@ enomem:
return NULL;
}
StringPair_t *StringPair_from_Struct(
PStringPair_t *PStringPair_from_Struct(
const stringpair_t *value,
StringPair_t *result
PStringPair_t *result
)
{
bool allocated = !result;
@ -202,7 +201,7 @@ StringPair_t *StringPair_from_Struct(
return NULL;
if (allocated)
result = (StringPair_t *) calloc(1, sizeof(StringPair_t));
result = (PStringPair_t *) calloc(1, sizeof(PStringPair_t));
assert(result);
if (!result)
return NULL;
@ -223,11 +222,11 @@ StringPair_t *StringPair_from_Struct(
enomem:
if (allocated)
ASN_STRUCT_FREE(asn_DEF_StringPair, result);
ASN_STRUCT_FREE(asn_DEF_PStringPair, result);
return NULL;
}
stringpair_t *StringPair_to_Struct(StringPair_t *value)
stringpair_t *PStringPair_to_Struct(PStringPair_t *value)
{
assert(value);
if (!value)
@ -257,19 +256,19 @@ enomem:
return NULL;
}
StringPairList_t *StringPairList_from_stringpair_list(
PStringPairList_t *PStringPairList_from_stringpair_list(
const stringpair_list_t *list,
StringPairList_t *result
PStringPairList_t *result
)
{
bool allocated = !result;
assert(list && list->value);
assert(list);
if (!(list && list->value))
return NULL;
if (allocated) {
result = (StringPairList_t *) calloc(1, sizeof(StringPairList_t));
result = (PStringPairList_t *) calloc(1, sizeof(PStringPairList_t));
assert(result);
if (!result)
return NULL;
@ -279,9 +278,9 @@ StringPairList_t *StringPairList_from_stringpair_list(
}
for (const stringpair_list_t *l = list; l && l->value; l=l->next) {
StringPair_t *value = StringPair_from_Struct(l->value, NULL);
PStringPair_t *value = PStringPair_from_Struct(l->value, NULL);
if (ASN_SEQUENCE_ADD(&result->list, value)) {
ASN_STRUCT_FREE(asn_DEF_StringPair, value);
ASN_STRUCT_FREE(asn_DEF_PStringPair, value);
goto enomem;
}
}
@ -290,12 +289,12 @@ StringPairList_t *StringPairList_from_stringpair_list(
enomem:
if (allocated)
ASN_STRUCT_FREE(asn_DEF_StringPairList, result);
ASN_STRUCT_FREE(asn_DEF_PStringPairList, result);
return NULL;
}
stringpair_list_t *StringPairList_to_stringpair_list(
StringPairList_t *list,
stringpair_list_t *PStringPairList_to_stringpair_list(
PStringPairList_t *list,
stringpair_list_t *result
)
{
@ -312,7 +311,7 @@ stringpair_list_t *StringPairList_to_stringpair_list(
stringpair_list_t *r = result;
for (int i=0; i<list->list.count; i++) {
stringpair_t *value = StringPair_to_Struct(list->list.array[i]);
stringpair_t *value = PStringPair_to_Struct(list->list.array[i]);
r = stringpair_list_add(r, value);
if (!r)
goto enomem;
@ -333,7 +332,7 @@ PStringList_t *PStringList_from_stringlist(
{
bool allocated = !result;
assert(list && list->value);
assert(list);
if (!(list && list->value))
return NULL;
@ -406,9 +405,9 @@ enomem:
return NULL;
}
BlobList_t *BlobList_from_bloblist(
PBlobList_t *PBlobList_from_bloblist(
bloblist_t *list,
BlobList_t *result,
PBlobList_t *result,
bool copy,
size_t max_blob_size
)
@ -417,12 +416,12 @@ BlobList_t *BlobList_from_bloblist(
if (!max_blob_size)
max_blob_size = SIZE_MAX;
assert(list && list->value);
assert(list);
if (!(list && list->value))
return NULL;
if (allocated) {
result = (BlobList_t *) calloc(1, sizeof(BlobList_t));
result = (PBlobList_t *) calloc(1, sizeof(PBlobList_t));
assert(result);
if (!result)
return NULL;
@ -434,7 +433,7 @@ BlobList_t *BlobList_from_bloblist(
size_t rest_blob_size = max_blob_size;
for (bloblist_t *l = list; l && l->value; l=l->next) {
Blob_t *element = (Blob_t *) calloc(1, sizeof(Blob_t));
PBlob_t *element = (PBlob_t *) calloc(1, sizeof(PBlob_t));
assert(element);
if (!element)
goto enomem;
@ -503,7 +502,7 @@ BlobList_t *BlobList_from_bloblist(
}
if (ASN_SEQUENCE_ADD(&result->list, element)) {
ASN_STRUCT_FREE(asn_DEF_Blob, element);
ASN_STRUCT_FREE(asn_DEF_PBlob, element);
goto enomem;
}
}
@ -512,12 +511,12 @@ BlobList_t *BlobList_from_bloblist(
enomem:
if (allocated)
ASN_STRUCT_FREE(asn_DEF_BlobList, result);
ASN_STRUCT_FREE(asn_DEF_PBlobList, result);
return NULL;
}
bloblist_t *BlobList_to_bloblist(
BlobList_t *list,
bloblist_t *PBlobList_to_bloblist(
PBlobList_t *list,
bloblist_t *result,
bool copy,
size_t max_blob_size
@ -618,9 +617,9 @@ enomem:
return NULL;
}
PEPMessage_t *PEPMessage_from_message(
ASN1Message_t *ASN1Message_from_message(
message *msg,
PEPMessage_t *result,
ASN1Message_t *result,
bool copy,
size_t max_blob_size
)
@ -634,7 +633,7 @@ PEPMessage_t *PEPMessage_from_message(
return NULL;
if (allocated) {
result = (PEPMessage_t *) calloc(1, sizeof(PEPMessage_t));
result = (ASN1Message_t *) calloc(1, sizeof(ASN1Message_t));
assert(result);
if (!result)
return NULL;
@ -659,7 +658,7 @@ PEPMessage_t *PEPMessage_from_message(
}
if (msg->sent) {
Timestamp_t *ts = asn_time2GT(NULL, msg->sent, 1);
GeneralizedTime_t *ts = asn_time2GT(NULL, msg->sent, 1);
if (!ts)
goto enomem;
@ -667,7 +666,7 @@ PEPMessage_t *PEPMessage_from_message(
}
if (msg->recv) {
Timestamp_t *ts = asn_time2GT(NULL, msg->recv, 1);
GeneralizedTime_t *ts = asn_time2GT(NULL, msg->recv, 1);
if (!ts)
goto enomem;
@ -756,7 +755,7 @@ PEPMessage_t *PEPMessage_from_message(
}
if (msg->opt_fields && msg->opt_fields->value) {
StringPairList_t *l = StringPairList_from_stringpair_list(msg->opt_fields, NULL);
PStringPairList_t *l = PStringPairList_from_stringpair_list(msg->opt_fields, NULL);
if (!l)
goto enomem;
@ -844,7 +843,7 @@ PEPMessage_t *PEPMessage_from_message(
}
if (msg->attachments && msg->attachments->value) {
BlobList_t *bl = BlobList_from_bloblist(msg->attachments, NULL, copy,
PBlobList_t *bl = PBlobList_from_bloblist(msg->attachments, NULL, copy,
rest_blob_size);
if (!bl)
goto enomem;
@ -855,12 +854,12 @@ PEPMessage_t *PEPMessage_from_message(
enomem:
if (allocated)
ASN_STRUCT_FREE(asn_DEF_PEPMessage, result);
ASN_STRUCT_FREE(asn_DEF_ASN1Message, result);
return NULL;
}
message *PEPMessage_to_message(
PEPMessage_t *msg,
message *ASN1Message_to_message(
ASN1Message_t *msg,
message *result,
bool copy,
size_t max_blob_size
@ -1000,7 +999,7 @@ message *PEPMessage_to_message(
if (msg->opt_fields) {
stringpair_list_t *l =
StringPairList_to_stringpair_list(msg->opt_fields, NULL);
PStringPairList_to_stringpair_list(msg->opt_fields, NULL);
if (!l)
goto enomem;
@ -1073,7 +1072,7 @@ message *PEPMessage_to_message(
}
if (msg->attachments) {
bloblist_t *a = BlobList_to_bloblist(msg->attachments, NULL, copy,
bloblist_t *a = PBlobList_to_bloblist(msg->attachments, NULL, copy,
rest_blob_size);
if (!a)
goto enomem;

@ -8,7 +8,7 @@
#define MAP_ASN1_H
#include "message.h"
#include "../asn.1/PEPMessage.h"
#include "ASN1Message.h"
#ifdef __cplusplus
extern "C" {
@ -89,12 +89,12 @@ identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list
/**
* <!-- StringPair_from_Struct() -->
* <!-- PStringPair_from_Struct() -->
*
* @brief Convert stringpair_t into ASN.1 StringPair_t
* @brief Convert stringpair_t into ASN.1 PStringPair_t
*
* @param value[in] stringpair_t to convert
* @param result[in,out] StringPair_t to update or NULL to alloc a new one
* @param result[in,out] PStringPair_t to update or NULL to alloc a new one
*
* @retval pointer to updated or allocated result
*
@ -102,18 +102,18 @@ identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list
*
*/
StringPair_t *StringPair_from_Struct(
PStringPair_t *PStringPair_from_Struct(
const stringpair_t *value,
StringPair_t *result
PStringPair_t *result
);
/**
* <!-- StringPair_to_Struct() -->
* <!-- PStringPair_to_Struct() -->
*
* @brief Convert ASN.1 StringPair_t into stringpair_t
* @brief Convert ASN.1 PStringPair_t into stringpair_t
*
* @param value[in] StringPair_t to convert
* @param value[in] PStringPair_t to convert
*
* @retval pointer to updated or allocated result
*
@ -121,16 +121,16 @@ StringPair_t *StringPair_from_Struct(
*
*/
stringpair_t *StringPair_to_Struct(StringPair_t *value);
stringpair_t *PStringPair_to_Struct(PStringPair_t *value);
/**
* <!-- StringPairList_from_stringpair_list() -->
* <!-- PStringPairList_from_stringpair_list() -->
*
* @brief Convert stringpair_list_t into ASN.1 StringPairList_t
* @brief Convert stringpair_list_t into ASN.1 PStringPairList_t
*
* @param list[in] stringpair_list to convert
* @param result[inout] StringPairList_t to update or NULL to alloc a new one
* @param result[inout] PStringPairList_t to update or NULL to alloc a new one
*
* @retval pointer to updated or allocated result
*
@ -138,17 +138,17 @@ stringpair_t *StringPair_to_Struct(StringPair_t *value);
*
*/
StringPairList_t *StringPairList_from_stringpair_list(
PStringPairList_t *PStringPairList_from_stringpair_list(
const stringpair_list_t *list,
StringPairList_t *result
PStringPairList_t *result
);
/**
* <!-- StringPairList_to_stringpair_list() -->
* <!-- PStringPairList_to_stringpair_list() -->
*
* @brief Convert ASN.1 StringPairList_t to stringpair_list_t
* @brief Convert ASN.1 PStringPairList_t to stringpair_list_t
*
* @param list[in] ASN.1 StringPairList_t to convert
* @param list[in] ASN.1 PStringPairList_t to convert
* @param result[inout] stringpair_list_t to update or NULL to alloc a new one
*
* @retval pointer to updated or allocated result
@ -157,8 +157,8 @@ StringPairList_t *StringPairList_from_stringpair_list(
*
*/
stringpair_list_t *StringPairList_to_stringpair_list(
StringPairList_t *list,
stringpair_list_t *PStringPairList_to_stringpair_list(
PStringPairList_t *list,
stringpair_list_t *result
);
@ -199,12 +199,12 @@ stringlist_t *PStringList_to_stringlist(PStringList_t *list);
/**
* <!-- BlobList_from_bloblist() -->
* <!-- PBlobList_from_bloblist() -->
*
* @brief Convert bloblist_t into ASN.1 BlobList_t
* @brief Convert bloblist_t into ASN.1 PBlobList_t
*
* @param list[in] bloblist to convert
* @param result[inout] BlobList_t to update or NULL to alloc a new one
* @param result[inout] PBlobList_t to update or NULL to alloc a new one
* @param copy copy data if true, move data otherwise
* @param max_blob_size reject if sum(blob.size) > max_blob_size
* to disable set to 0
@ -215,20 +215,20 @@ stringlist_t *PStringList_to_stringlist(PStringList_t *list);
*
*/
BlobList_t *BlobList_from_bloblist(
PBlobList_t *PBlobList_from_bloblist(
bloblist_t *list,
BlobList_t *result,
PBlobList_t *result,
bool copy,
size_t max_blob_size
);
/**
* <!-- BlobList_to_bloblist() -->
* <!-- PBlobList_to_bloblist() -->
*
* @brief Convert ASN.1 BlobList_t to bloblist_t
* @brief Convert ASN.1 PBlobList_t to bloblist_t
*
* @param list[in] ASN.1 BlobList_t to convert
* @param list[in] ASN.1 PBlobList_t to convert
* @param result[inout] bloblist_t to update or NULL to alloc a new one
* @param copy copy data if true, move data otherwise
* @param max_blob_size reject if sum(blob.size) > max_blob_size
@ -240,8 +240,8 @@ BlobList_t *BlobList_from_bloblist(
*
*/
bloblist_t *BlobList_to_bloblist(
BlobList_t *list,
bloblist_t *PBlobList_to_bloblist(
PBlobList_t *list,
bloblist_t *result,
bool copy,
size_t max_blob_size
@ -249,12 +249,12 @@ bloblist_t *BlobList_to_bloblist(
/**
* <!-- PEPMessage_from_message() -->
* <!-- ASN1Message_from_message() -->
*
* @brief Convert message into ASN.1 PEPMessage_t
* @brief Convert message into ASN.1 ASN1Message_t
*
* @param msg[in] message to convert
* @param result[inout] PEPMessage_t to update or NULL to alloc a new one
* @param result[inout] ASN1Message_t to update or NULL to alloc a new one
* @param copy copy data if true, move data otherwise
* @param max_blob_size reject if sum(blob.size) > max_blob_size
* to disable set to 0
@ -265,20 +265,20 @@ bloblist_t *BlobList_to_bloblist(
*
*/
PEPMessage_t *PEPMessage_from_message(
ASN1Message_t *ASN1Message_from_message(
message *msg,
PEPMessage_t *result,
ASN1Message_t *result,
bool copy,
size_t max_blob_size
);
/**
* <!-- PEPMessage_to_message() -->
* <!-- ASN1Message_to_message() -->
*
* @brief Convert ASN.1 PEPMessage_t to message
* @brief Convert ASN.1 ASN1Message_t to message
*
* @param msg[in] ASN.1 PEPMessage_t to convert
* @param msg[in] ASN.1 ASN1Message_t to convert
* @param result[inout] message to update or NULL to alloc a new one
* @param copy copy data if true, move data otherwise
* @param max_blob_size reject if sum(blob.size) > max_blob_size
@ -290,8 +290,8 @@ PEPMessage_t *PEPMessage_from_message(
*
*/
message *PEPMessage_to_message(
PEPMessage_t *msg,
message *ASN1Message_to_message(
ASN1Message_t *msg,
message *result,
bool copy,
size_t max_blob_size

@ -1,6 +1,6 @@
/**
* @file PEPMessage_codec.c
* @brief Implementation for PEPMessage encode and decode functions which transform message payloads to
* @file ASN1Message_codec.c
* @brief Implementation for ASN1Message encode and decode functions which transform message payloads to
* and from PER-encoded data, and XER text to and from PER
*
* @see https://www.itu.int/en/ITU-T/asn1/Pages/introduction.aspx
@ -11,14 +11,14 @@
#include "platform.h"
#include "distribution_codec.h"
#include "../asn.1/PEPMessage.h"
#include "../asn.1/ASN1Message.h"
#include "pEp_internal.h"
#include "growing_buf.h"
DYNAMIC_API PEP_STATUS decode_PEPMessage_message(
DYNAMIC_API PEP_STATUS decode_ASN1Message_message(
const char *data,
size_t size,
PEPMessage_t **msg
ASN1Message_t **msg
)
{
assert(data && msg);
@ -26,8 +26,8 @@ DYNAMIC_API PEP_STATUS decode_PEPMessage_message(
return PEP_ILLEGAL_VALUE;
*msg = NULL;
PEPMessage_t *_msg = NULL;
uper_decode_complete(NULL, &asn_DEF_PEPMessage, (void **) &_msg, data, size);
ASN1Message_t *_msg = NULL;
uper_decode_complete(NULL, &asn_DEF_ASN1Message, (void **) &_msg, data, size);
if (!_msg)
return PEP_PEPMESSAGE_ILLEGAL_MESSAGE;
@ -35,8 +35,8 @@ DYNAMIC_API PEP_STATUS decode_PEPMessage_message(
return PEP_STATUS_OK;
}
PEP_STATUS encode_PEPMessage_message(
PEPMessage_t *msg,
PEP_STATUS encode_ASN1Message_message(
ASN1Message_t *msg,
char **data,
size_t *size
)
@ -49,7 +49,7 @@ PEP_STATUS encode_PEPMessage_message(
*size = 0;
char *_data = NULL;
ssize_t _size = uper_encode_to_new_buffer(&asn_DEF_PEPMessage, NULL, msg,
ssize_t _size = uper_encode_to_new_buffer(&asn_DEF_ASN1Message, NULL, msg,
(void **) &_data);
if (_size == -1)
return PEP_CANNOT_ENCODE;
@ -60,7 +60,7 @@ PEP_STATUS encode_PEPMessage_message(
return PEP_STATUS_OK;
}
PEP_STATUS PER_to_XER_PEPMessage_msg(
PEP_STATUS PER_to_XER_ASN1Message_msg(
const char *data,
size_t size,
char **text
@ -75,8 +75,8 @@ PEP_STATUS PER_to_XER_PEPMessage_msg(
*text = NULL;
PEPMessage_t *msg = NULL;
status = decode_PEPMessage_message(data, size, &msg);
ASN1Message_t *msg = NULL;
status = decode_ASN1Message_message(data, size, &msg);
if (status)
goto the_end;
@ -86,7 +86,7 @@ PEP_STATUS PER_to_XER_PEPMessage_msg(
goto the_end;
}
asn_enc_rval_t er = xer_encode(&asn_DEF_PEPMessage, msg, XER_F_BASIC,
asn_enc_rval_t er = xer_encode(&asn_DEF_ASN1Message, msg, XER_F_BASIC,
(asn_app_consume_bytes_f *) growing_buf_consume, (void *) dst);
if (er.encoded == -1) {
status = PEP_CANNOT_ENCODE;
@ -98,11 +98,11 @@ PEP_STATUS PER_to_XER_PEPMessage_msg(
the_end:
free_growing_buf(dst);
ASN_STRUCT_FREE(asn_DEF_PEPMessage, msg);
ASN_STRUCT_FREE(asn_DEF_ASN1Message, msg);
return status;
}
PEP_STATUS XER_to_PER_PEPMessage_msg(
PEP_STATUS XER_to_PER_ASN1Message_msg(
const char *text,
char **data,
size_t *size
@ -117,8 +117,8 @@ PEP_STATUS XER_to_PER_PEPMessage_msg(
*data = NULL;
*size = 0;
PEPMessage_t *msg = NULL;
asn_dec_rval_t dr = xer_decode(NULL, &asn_DEF_PEPMessage, (void **) &msg,
ASN1Message_t *msg = NULL;
asn_dec_rval_t dr = xer_decode(NULL, &asn_DEF_ASN1Message, (void **) &msg,
(const void *) text, strlen(text));
if (dr.code != RC_OK) {
status = PEP_PEPMESSAGE_ILLEGAL_MESSAGE;
@ -127,7 +127,7 @@ PEP_STATUS XER_to_PER_PEPMessage_msg(
char *_data = NULL;
size_t _size = 0;
status = encode_PEPMessage_message(msg, &_data, &_size);
status = encode_ASN1Message_message(msg, &_data, &_size);
if (status)
goto the_end;
@ -135,7 +135,7 @@ PEP_STATUS XER_to_PER_PEPMessage_msg(
*size = (size_t) _size;
the_end:
ASN_STRUCT_FREE(asn_DEF_PEPMessage, msg);
ASN_STRUCT_FREE(asn_DEF_ASN1Message, msg);
return status;
}

@ -1,6 +1,6 @@
/**
* @file PEPMessage_codec.h
* @brief Definitions for PEPMessage encode and decode functions which transform message payloads to
* @file ASN1Message_codec.h
* @brief Definitions for ASN1Message encode and decode functions which transform message payloads to
* and from PER-encoded data, and XER text to and from PER
*
* @see https://www.itu.int/en/ITU-T/asn1/Pages/introduction.aspx
@ -20,33 +20,33 @@ extern "C" {
#endif
struct PEPMessage;
struct ASN1Message;
/**
* <!-- decode_PEPMessage_message() -->
* <!-- decode_ASN1Message_message() -->
*
* @brief decode PER encoded PEPMessage message
* @brief decode PER encoded ASN1Message message
*
* @param[in] data PER encoded data
* @param[in] size size of PER encoded data
* @param[out] msg decoded PEPMessage message
* @param[out] msg decoded ASN1Message message
*
* @retval status
*
* @ownership msg goes into the ownership of the caller
*/
DYNAMIC_API PEP_STATUS decode_PEPMessage_message(
DYNAMIC_API PEP_STATUS decode_ASN1Message_message(
const char *data,
size_t size,
struct PEPMessage **msg
struct ASN1Message **msg
);
/**
* <!-- encode_PEPMessage_message() -->
* <!-- encode_ASN1Message_message() -->
*
* @brief decode PER encoded PEPMessage message
* @brief decode PER encoded ASN1Message message
*
* @param[in] msg PEPMessage message to encode
* @param[in] msg ASN1Message message to encode
* @param[out] data PER encoded data
* @param[out] size size of PER encoded data
*
@ -54,42 +54,42 @@ DYNAMIC_API PEP_STATUS decode_PEPMessage_message(
*
* @ownership msg goes into the ownership of the caller
*/
DYNAMIC_API PEP_STATUS encode_PEPMessage_message(
struct PEPMessage *msg,
DYNAMIC_API PEP_STATUS encode_ASN1Message_message(
struct ASN1Message *msg,
char **data,
size_t *size
);
/**
* <!-- PER_to_XER_PEPMessage_msg() -->
* <!-- PER_to_XER_ASN1Message_msg() -->
*
* @brief decode PEPMessage message from PER into XER
* @brief decode ASN1Message message from PER into XER
*
* @param[in] data PER encoded data
* @param[in] size size of PER encoded data
* @param[out] text XER text of the same PEPMessage message
* @param[out] text XER text of the same ASN1Message message
*
* @retval status
*/
DYNAMIC_API PEP_STATUS PER_to_XER_PEPMessage_msg(
DYNAMIC_API PEP_STATUS PER_to_XER_ASN1Message_msg(
const char *data,
size_t size,
char **text
);
/**
* <!-- XER_to_PER_PEPMessage_msg() -->
* <!-- XER_to_PER_ASN1Message_msg() -->
*
* @brief encode PEPMessage message from XER into PER
* @brief encode ASN1Message message from XER into PER
*
* @param[in] text string text with XER text of the PEPMessage message
* @param[in] text string text with XER text of the ASN1Message message
* @param[out] data PER encoded data
* @param[out] size size of PER encoded data
*
* @retval status
*/
DYNAMIC_API PEP_STATUS XER_to_PER_PEPMessage_msg(
DYNAMIC_API PEP_STATUS XER_to_PER_ASN1Message_msg(
const char *text,
char **data,
size_t *size

@ -29,7 +29,7 @@ extern "C" {
#define PEP_ENGINE_VERSION_MAJOR 3
#define PEP_ENGINE_VERSION_MINOR 2
#define PEP_ENGINE_VERSION_PATCH 0
#define PEP_ENGINE_VERSION_RC 2
#define PEP_ENGINE_VERSION_RC 5
#define PEP_OWN_USERID "pEp_own_userId"
@ -163,6 +163,21 @@ typedef enum {
PEP_STORAGE_ILLEGAL_MESSAGE = 0x1102,
PEP_PEPMESSAGE_ILLEGAL_MESSAGE = 0x1202,
// transport cannot init at all
PEP_TRANSPORT_CANNOT_INIT = 0x2000,
// transport can init recv but not send
PEP_TRANSPORT_CANNOT_INIT_SEND = 0x2001,
// transport can init send but not recv
PEP_TRANSPORT_CANNOT_INIT_RECV = 0x2002,
// transport init good but temporary down
PEP_TRANSPORT_DOWN = 0x2003,
// general error in transport
PEP_TRANSPORT_ERROR = 0x20ff,
PEP_COMMIT_FAILED = 0xff01,
PEP_MESSAGE_CONSUME = 0xff02,
PEP_MESSAGE_IGNORE = 0xff03,

@ -6,14 +6,46 @@
#include "trans_auto.h"
PEP_STATUS auto_sendto(PEP_SESSION session, const message *msg)
PEP_STATUS auto_configure(PEP_transport_t *transport,
transport_config_t *config, PEP_transport_status_code *tsc)
{
return PEP_STATUS_OK;
}
PEP_STATUS auto_readnext(PEP_SESSION session, message **msg, PEP_transport_t **via)
PEP_STATUS auto_startup(PEP_transport_t *transport,
PEP_transport_status_code *tsc)
{
return PEP_STATUS_OK;
}
PEP_STATUS auto_shutdown(PEP_transport_t *transport,
PEP_transport_status_code *tsc)
{
return PEP_STATUS_OK;
}
PEP_STATUS auto_sendto(PEP_SESSION session, message *msg,
PEP_transport_status_code *tsc)
{
return PEP_STATUS_OK;
}
PEP_STATUS auto_recvnext(PEP_SESSION session, message **msg,
PEP_transport_status_code *tsc)
{
return PEP_STATUS_OK;
}
PEP_STATUS auto_notify(signal_statuschange_t status_change,
signal_sendto_result_t sendto_result,
signal_incoming_message_t incoming, callback_execution cbe)
{
return PEP_STATUS_OK;
}

@ -9,17 +9,23 @@
#include "transport.h"
PEP_STATUS auto_sendto(PEP_SESSION session, const message *msg);
/**
* <!-- auto_readnext() -->
*
* @brief TODO
*
* @param[in] session PEP_SESSION
* @param[out] msg message**
* @param[out] via PEP_transport_t**
*
*/
PEP_STATUS auto_readnext(PEP_SESSION session, message **msg, PEP_transport_t **via);
PEP_STATUS auto_configure(PEP_transport_t *transport,
transport_config_t *config, PEP_transport_status_code *tsc);
PEP_STATUS auto_startup(PEP_transport_t *transport,
PEP_transport_status_code *tsc);
PEP_STATUS auto_shutdown(PEP_transport_t *transport,
PEP_transport_status_code *tsc);
PEP_STATUS auto_sendto(PEP_SESSION session, message *msg,
PEP_transport_status_code *tsc);
PEP_STATUS auto_recvnext(PEP_SESSION session, message **msg,
PEP_transport_status_code *tsc);
PEP_STATUS auto_notify(signal_statuschange_t status_change,
signal_sendto_result_t sendto_result,
signal_incoming_message_t incoming, callback_execution cbe);
#endif

@ -22,8 +22,16 @@ PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first)
memset(transports, 0, sizeof(PEP_transport_t) * PEP_trans__count);
transports[PEP_trans_auto].id = PEP_trans_auto;
transports[PEP_trans_auto].uri_scheme = "";
transports[PEP_trans_auto].configure = auto_configure;
transports[PEP_trans_auto].startup = auto_startup;
transports[PEP_trans_auto].shutdown = auto_shutdown;
transports[PEP_trans_auto].sendto = auto_sendto;
transports[PEP_trans_auto].readnext = auto_readnext;
transports[PEP_trans_auto].recvnext = auto_recvnext;
transports[PEP_trans_auto].notify = auto_notify;
}
return PEP_STATUS_OK;

@ -15,25 +15,83 @@ extern "C" {
#endif
/**
* @enum PEP_transports
* @enum PEP_transport_id
*
* @brief TODO
*
*/
typedef enum _PEP_transports {
typedef enum _PEP_transport_id {
// auto transport chooses transport per message automatically
PEP_trans_auto = 0,
// PEP_trans_email,
// PEP_trans_whatsapp,
// PEP_trans_Email = 0x01,
// PEP_trans_RCE = 0x02,
// PEP_trans_PDL = 0x03,
PEP_trans__count
} PEP_transports;
PEP_trans__count,
PEP_trans_CC = 0xfe
} PEP_transport_id;
typedef struct _transport_config {
// set size field when initializing
size_t size;
// expand here
// in C++ this must be POD
} transport_config_t;
// transports are delivering the transport status code
// this is defined here:
// https://dev.pep.foundation/Engine/TransportStatusCode
typedef uint32_t PEP_transport_status_code;
typedef struct _PEP_transport_t PEP_transport_t;
typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, const message *msg);
typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, message **msg,
PEP_transport_t **via);
// functions offered by transport
typedef PEP_STATUS (*configure_transport_t)(PEP_transport_t *transport,
transport_config_t *config, PEP_transport_status_code *tsc);
typedef PEP_STATUS (*startup_transport_t)(PEP_transport_t *transport,
PEP_transport_status_code *tsc);
typedef PEP_STATUS (*shutdown_transport_t)(PEP_transport_t *transport,
PEP_transport_status_code *tsc);
typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, message *msg,
PEP_transport_status_code *tsc);
typedef PEP_STATUS (*recvnext_t)(PEP_SESSION session, message **msg,
PEP_transport_status_code *tsc);
// callbacks
typedef PEP_STATUS (*signal_statuschange_t)(PEP_transport_id id,
PEP_transport_status_code tsc);
typedef PEP_STATUS (*signal_sendto_result_t)(PEP_transport_id id, char *message_id,
char *address, PEP_transport_status_code tsc);
typedef PEP_STATUS (*signal_incoming_message_t)(PEP_transport_id id,
PEP_transport_status_code tsc);
// call this to receive signals
typedef enum _callback_execution {
PEP_cbe_polling = 0, // execute callbacks immediately only
PEP_cbe_async, // execute callbacks multiple times later on any
// thread; call with PEP_cbe_polling to disable
// the last one is for the transport system only
// do not implement it in transports
PEP_cbe_blocking = 255
} callback_execution;
// provide NULL for callbacks to avoid being called
typedef PEP_STATUS (*notify_transport_t)(signal_statuschange_t status_change,
signal_sendto_result_t sendto_result,
signal_incoming_message_t incoming, callback_execution cbe);
/**
* @struct _PEP_transport_t
@ -42,13 +100,27 @@ typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, message **msg,
*
*/
struct _PEP_transport_t {
uint8_t id; // transport ID
sendto_t sendto; // sendto function
readnext_t readnext; // readnext function
bool long_message_supported; // flag if this transport supports
// long messages
bool formatted_message_supported; // flag if this transport supports
// formatted messages
PEP_transport_id id; // transport ID
const char *uri_scheme; // URI scheme this transport is
// covering
// functions offered by transport
configure_transport_t configure;
startup_transport_t startup;
shutdown_transport_t shutdown;
sendto_t sendto;
recvnext_t recvnext;
notify_transport_t notify;
bool is_online_transport;
bool shortmsg_supported;
bool longmsg_supported;
bool longmsg_formatted_supported;
PEP_text_format native_text_format; // native format of the transport
};

@ -80,40 +80,61 @@ Ubuntu](https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/))
1. Get the source, Fred. (Luke is tired of the source, I hear.)
```
git clone https://github.com/google/googletest.git
mkdir -p ~/pep-src/googletest
git clone https://github.com/google/googletest.git ~/pep-src/googletest
```
2. Switch into the source directory and find the directory
containing the `src` and `include` directories. Mark this directory
for later. (For me, this is `./googletest/googletest`)
3. Edit `CMakeLists.txt` here to contain the following line at the top:
2. Switch into the source directory and find the subdirectory of
`googletest` (the source distribution of googletest also contains a
`googlemock` library which is not useful to us here)
containing the `src` and `include` directories. Remember this
directory's path. For me it is `~/pep-src/googletest/googletest` .
3. Edit the file `CMakeLists.txt` in that directory, adding the
following line at the top:
```
set (CMAKE_CXX_STANDARD 11)
```
(If you don't, it won't compile, and I will shake my fist at you.)
4. Execute, in this directory:
4. Go to the googletest source directory (it should be the parent
directory of the directory containing the file you edited) and build
the library.
```
cd ~/pep-src/googletest
cmake CMakeLists.txt
make
```
5. In the lib directory of your current directory are located the
library files you'll use (`lib/*.a`). Copy or symlink them to the library
library files you'll use (`lib/*.a`). You may leave them there without
installing them, if you accept running a more complex command line than
```
make test
```
later. If you want to install the library, read on.
Copy or symlink them to the library
location of your choice (make sure this is a directory that can be seen
during the test build process - i.e. one that's in one of the library paths
used in building. Mine are located in `$HOME/lib`.
6. See `Makefile` and `local.conf` under "Building the test suite" below -
See `Makefile` and `local.conf` under "Building the test suite" below -
In this scenario, I set `GTEST_SRC_DIR` as `<clone_path>/googletest/googletest`
(i.e. the absolute path of where the `src` and `include` directories were
above - for me, `/Users/krista/googletest/googletest`).
above - for example, `/Users/krista/googletest/googletest`).
### Installing `gtest-parallel`
Pick a source directory and put your `gtest-parallel` source there
(e.g. via `git clone https://github.com/google/gtest-parallel.git`).
(e.g. via `git clone https://github.com/google/gtest-parallel.git`):
```
mkdir -p ~/pep-src/gtest-parallel
git clone https://github.com/google/gtest-parallel.git ~/pep-src/gtest-parallel
```
This library is written in Python and does not require any actual build.
We'll deal more with this when preparing to compile the test suite.
@ -133,13 +154,43 @@ are:
* `GTEST_INC_DIR`: This is where the include files for googletest are located
(defaults to `$(GTEST_SRC_DIR)/include`)
* `GTEST_PL`: This is the full path to the *python file* for `gtest_parallel`
* `GTEST_PL`: This is the full path to the *python file* for `gtest_parallel.py`
(default presumes you cloned it under `src` in your home directory, i.e. it is
`$(HOME)/src/gtest-parallel/gtest_parallel.py`)
The sample `local.conf` included in `../doc/build-debian.md` contains correct
definitions for these variables, assuming the user installed from sources under
`~/pep-src` as described here.
### Building
Presuming the above works, then from the top test directory, simply run make.
Presuming the above works and you installed every library, then from the top test
directory, simply run ``make``.
Libraries which have not been installed into the `lib` subdirectory of some
standard prefix will not be found automatically. But this problem is easy to
circumbent by setting environment libraries (on system using the GNU
linked-loader `LD_LIBRARY_PATH` for dynamic libraries, `LIBRARY_PATH` for static
libraries).
For example, this should be sufficient to run the test suite under a debian
system following the instruction at `../doc/build-debian.md`:
```
cd ~/pep-src/pep-engine
LIBRARY_PATH=$LIBRARY_PATH:$HOME/pep-src/googletest/lib LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/pep-src/pep-engine/src:$HOME/pep-src/sequoia/target/release:$HOME/pep-src/libetpan/build/lib make test
```
Such variable definitions may be prepended to the command lines below for running
individual tests or the entire test suite.
In case of test failures remember to build the database, on which the test suite
depends, and to copy it into the system directory:
```
make dbinstall
```