adding the concepts of transports and cryptotech
authorvb
Mon, 01 Sep 2014 13:02:23 +0200
changeset 23dba569e54163
parent 22 e235409d570a
child 24 50887c6ab78f
adding the concepts of transports and cryptotech
pEpEngine.vcxproj
pEpEngine.vcxproj.filters
src/cryptotech.c
src/cryptotech.h
src/pEpEngine.h
src/transport.c
src/transport.h
     1.1 --- a/pEpEngine.vcxproj	Wed Aug 20 20:20:07 2014 +0200
     1.2 +++ b/pEpEngine.vcxproj	Mon Sep 01 13:02:23 2014 +0200
     1.3 @@ -81,16 +81,20 @@
     1.4      </Link>
     1.5    </ItemDefinitionGroup>
     1.6    <ItemGroup>
     1.7 +    <ClCompile Include="src\cryptotech.c" />
     1.8      <ClCompile Include="src\keymanagement.c" />
     1.9      <ClCompile Include="src\pEpEngine.c" />
    1.10      <ClCompile Include="src\platform_windows.cpp" />
    1.11      <ClCompile Include="src\sqlite3.c" />
    1.12 +    <ClCompile Include="src\transport.c" />
    1.13    </ItemGroup>
    1.14    <ItemGroup>
    1.15 +    <ClInclude Include="src\cryptotech.h" />
    1.16      <ClInclude Include="src\keymanagement.h" />
    1.17      <ClInclude Include="src\pEpEngine.h" />
    1.18      <ClInclude Include="src\platform_windows.h" />
    1.19      <ClInclude Include="src\sqlite3.h" />
    1.20 +    <ClInclude Include="src\transport.h" />
    1.21    </ItemGroup>
    1.22    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
    1.23    <ImportGroup Label="ExtensionTargets">
     2.1 --- a/pEpEngine.vcxproj.filters	Wed Aug 20 20:20:07 2014 +0200
     2.2 +++ b/pEpEngine.vcxproj.filters	Mon Sep 01 13:02:23 2014 +0200
     2.3 @@ -27,6 +27,12 @@
     2.4      <ClCompile Include="src\sqlite3.c">
     2.5        <Filter>Quelldateien</Filter>
     2.6      </ClCompile>
     2.7 +    <ClCompile Include="src\transport.c">
     2.8 +      <Filter>Quelldateien</Filter>
     2.9 +    </ClCompile>
    2.10 +    <ClCompile Include="src\cryptotech.c">
    2.11 +      <Filter>Quelldateien</Filter>
    2.12 +    </ClCompile>
    2.13    </ItemGroup>
    2.14    <ItemGroup>
    2.15      <ClInclude Include="src\keymanagement.h">
    2.16 @@ -41,5 +47,11 @@
    2.17      <ClInclude Include="src\sqlite3.h">
    2.18        <Filter>Headerdateien</Filter>
    2.19      </ClInclude>
    2.20 +    <ClInclude Include="src\transport.h">
    2.21 +      <Filter>Headerdateien</Filter>
    2.22 +    </ClInclude>
    2.23 +    <ClInclude Include="src\cryptotech.h">
    2.24 +      <Filter>Headerdateien</Filter>
    2.25 +    </ClInclude>
    2.26    </ItemGroup>
    2.27  </Project>
    2.28 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/cryptotech.c	Mon Sep 01 13:02:23 2014 +0200
     3.3 @@ -0,0 +1,20 @@
     3.4 +#include "cryptotech.h"
     3.5 +
     3.6 +#include <stdlib.h>
     3.7 +#include <memory.h>
     3.8 +#include <assert.h>
     3.9 +
    3.10 +PEP_STATUS init_cryptotech(PEP_cryptotech_t *cryptotech)
    3.11 +{
    3.12 +    assert(PEP_crypt__count == 2);
    3.13 +    memset(cryptotech, 0, sizeof(PEP_cryptotech_t) * PEP_crypt__count);
    3.14 +
    3.15 +    cryptotech[0].id = PEP_crypt_none;
    3.16 +
    3.17 +    cryptotech[1].id = PEP_crypt_OpenPGP;
    3.18 +    cryptotech[1].decrypt_and_verify = decrypt_and_verify;
    3.19 +    cryptotech[1].encrypt_and_sign = encrypt_and_sign;
    3.20 +    cryptotech[1].verify_text = verify_text;
    3.21 +
    3.22 +    return PEP_STATUS_OK;
    3.23 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/cryptotech.h	Mon Sep 01 13:02:23 2014 +0200
     4.3 @@ -0,0 +1,37 @@
     4.4 +#pragma once
     4.5 +
     4.6 +#include "pEpEngine.h"
     4.7 +
     4.8 +typedef enum _PEP_cryptotech {
     4.9 +    PEP_crypt_none = 0,
    4.10 +    PEP_crypt_OpenPGP = 0x2f,
    4.11 +//    PEP_ctypt_PEP = 0x6f,
    4.12 +//    PEP_crypt_SMIME = 0x10,
    4.13 +//    PEP_crypt_CMS = 0x20,
    4.14 +
    4.15 +    PEP_crypt__count
    4.16 +};
    4.17 +
    4.18 +typedef PEP_STATUS (*decrypt_and_verify_t)(
    4.19 +    PEP_SESSION session, const char *ctext, size_t csize,
    4.20 +    char **ptext, size_t *psize, stringlist_t **keylist
    4.21 +    );
    4.22 +
    4.23 +typedef PEP_STATUS (*verify_text_t)(
    4.24 +    PEP_SESSION session, const char *text, size_t size,
    4.25 +    const char *signature, size_t sig_size, stringlist_t **keylist
    4.26 +    );
    4.27 +
    4.28 +typedef PEP_STATUS (*encrypt_and_sign_t)(
    4.29 +    PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
    4.30 +    size_t psize, char **ctext, size_t *csize
    4.31 +    );
    4.32 +
    4.33 +typedef struct _PEP_cryptotech_t {
    4.34 +    uint8_t id;
    4.35 +    decrypt_and_verify_t decrypt_and_verify;
    4.36 +    verify_text_t verify_text;
    4.37 +    encrypt_and_sign_t encrypt_and_sign;
    4.38 +} PEP_cryptotech_t;
    4.39 +
    4.40 +typedef uint64_t cryptotech_mask;
     5.1 --- a/src/pEpEngine.h	Wed Aug 20 20:20:07 2014 +0200
     5.2 +++ b/src/pEpEngine.h	Mon Sep 01 13:02:23 2014 +0200
     5.3 @@ -1,3 +1,5 @@
     5.4 +#pragma once
     5.5 +
     5.6  #ifdef __cplusplus
     5.7  extern "C" {
     5.8  #endif
     5.9 @@ -347,6 +349,7 @@
    5.10  
    5.11      PEP_ct_unconfirmed_encryption = 0x10,       // generic
    5.12      PEP_ct_OpenPGP_1024_RSA_unconfirmed = 0x11,	// RSA 1024 is weak
    5.13 +    PEP_ct_SMIME_unconfirmed = 0x20,
    5.14      PEP_ct_CMS_unconfirmed = 0x30,
    5.15      PEP_ct_OpenPGP_unconfirmed = 0x3f,          // key at least 2048 bit RSA
    5.16      // or 1024 bit DSA
    5.17 @@ -363,6 +366,7 @@
    5.18  
    5.19      PEP_ct_confirmed_encryption = 0x90,         // generic
    5.20  	PEP_ct_OpenPGP_1024_RSA = 0x91, // RSA 1024 is weak
    5.21 +    PEP_ct_SMIME = 0xa0,
    5.22      PEP_ct_CMS = 0xb0,
    5.23  	PEP_ct_OpenPGP = 0xbf, // key at least 2048 bit RSA or 1024 bit DSA
    5.24  
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/transport.c	Mon Sep 01 13:02:23 2014 +0200
     6.3 @@ -0,0 +1,15 @@
     6.4 +#include "transport.h"
     6.5 +
     6.6 +#include <stdlib.h>
     6.7 +#include <memory.h>
     6.8 +#include <assert.h>
     6.9 +
    6.10 +PEP_STATUS init_transport_system(PEP_transport_t* transports)
    6.11 +{
    6.12 +    assert(PEP_trans__count == 1);
    6.13 +    memset(transports, 0, sizeof(PEP_transport_t) * PEP_trans__count);
    6.14 +
    6.15 +    transports[0].id = PEP_trans_auto;
    6.16 +
    6.17 +    return PEP_STATUS_OK;
    6.18 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/transport.h	Mon Sep 01 13:02:23 2014 +0200
     7.3 @@ -0,0 +1,24 @@
     7.4 +#pragma once
     7.5 +
     7.6 +#include "pEpEngine.h"
     7.7 +
     7.8 +typedef enum _PEP_transports {
     7.9 +    PEP_trans_auto = 0,
    7.10 +//    PEP_trans_email = 1,
    7.11 +//    PEP_trans_whatsapp = 2,
    7.12 +
    7.13 +    PEP_trans__count
    7.14 +} PEP_transports;
    7.15 +
    7.16 +typedef struct _PEP_transport_t PEP_transport_t;
    7.17 +
    7.18 +typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, const pEp_identity *address, const char *shortmsg, const char *longmsg, const char *longmsg_formatted);
    7.19 +typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, pEp_identity *from, pEp_identity *reached, char **shortmsg, size_t shortmsg_size, char ** longmsg, size_t longmsg_size, char ** longmsg_formatted, size_t longmsg_formatted_size, PEP_transport_t **via);
    7.20 +
    7.21 +struct _PEP_transport_t {
    7.22 +    uint8_t id;
    7.23 +    sendto_t sendto;
    7.24 +    readnext_t readnext;
    7.25 +};
    7.26 +
    7.27 +typedef uint64_t transports_mask;