Compare commits

...

27 Commits

Author SHA1 Message Date
Krista Bennett d450746875 Merge branch 'master' into ENGINE-847
2 years ago
Volker Birk 855f87655b this is needed because map_asn1.h is now an external header
2 years ago
positron c0167a12c8 Merge branch 'ENGINE-954'
2 years ago
Volker Birk 7e18d17aee adding transport ID for PDL
2 years ago
positron 1bd8d6c503 improve build system documentation
2 years ago
Volker Birk 812b8f8065 Bumped header patch number for NEXT release
2 years ago
Volker Birk 0eca1d413b correct gen_dot
2 years ago
Volker Birk 9087832330 adapt to renaming
2 years ago
Volker Birk a47fff012b avoid name clashes
2 years ago
Volker Birk 5b2a028f51 add signal_incoming_message_t
2 years ago
Volker Birk f2686c52a8 ...0
2 years ago
Volker Birk 1e80a83bda merging
2 years ago
Volker Birk 5690a3732b supporting different execution environments
2 years ago
Volker Birk 5e7c4fef87 adding configure_transport
2 years ago
Volker Birk 32956eb8b2 ...
2 years ago
Volker Birk 66da4bd67a notification concept
2 years ago
Volker Birk bebfbac516 extending transport system
2 years ago
Volker Birk e684b9ab6f slightly redesigned
2 years ago
Volker Birk cac5418227 adding configure_transport
2 years ago
Volker Birk 7fc9ab7d28 ...
2 years ago
Volker Birk f5d6017792 notification concept
2 years ago
Volker Birk f884510728 Bumped header patch number for NEXT release
2 years ago
Volker Birk e7aaeb5569 adapting test to rename of PEPMessage to ASN1Message
2 years ago
Volker Birk 46cdf6066c Bumped header patch number for NEXT release
2 years ago
Volker Birk 1b6d5d34a1 renaming PEPMessage to ASN1Message to avoid the name clash with p≡p Objective C adapter
2 years ago
Volker Birk 54e3758a3e extending transport system
2 years ago
Volker Birk cd0fdedcf5 slightly redesigned
2 years ago

@ -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
*