finished interface of StructuringInfo struct and added implementation of setting it's parameters in our cryptplug signMessage and
encryptmessage functions (setting of parameters in gpgsmplug.c is still missing)
This commit is contained in:
parent
9b1da5342b
commit
95bed553e4
@ -46,7 +46,6 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
@ -57,6 +56,66 @@
|
||||
#define GPGMEPLUG_PROTOCOL GPGME_PROTOCOL_OpenPGP
|
||||
#endif
|
||||
|
||||
#ifndef GPGMEPLUG_SIGN_MAKE_MIME_OBJECT
|
||||
#define GPGMEPLUG_SIGN_INCLUDE_CLEARTEXT true
|
||||
#define GPGMEPLUG_SIGN_MAKE_MIME_OBJECT true
|
||||
#define GPGMEPLUG_SIGN_MAKE_MULTI_MIME true
|
||||
#define GPGMEPLUG_SIGN_CTYPE_MAIN "multipart/signed; protocol=application/pgp-signature; micalg=pgp-sha1"
|
||||
#define GPGMEPLUG_SIGN_CDISP_MAIN ""
|
||||
#define GPGMEPLUG_SIGN_CTENC_MAIN ""
|
||||
#define GPGMEPLUG_SIGN_CTYPE_VERSION ""
|
||||
#define GPGMEPLUG_SIGN_CDISP_VERSION ""
|
||||
#define GPGMEPLUG_SIGN_CTENC_VERSION ""
|
||||
#define GPGMEPLUG_SIGN_BTEXT_VERSION ""
|
||||
#define GPGMEPLUG_SIGN_CTYPE_CODE "application/pgp-signature"
|
||||
#define GPGMEPLUG_SIGN_CDISP_CODE ""
|
||||
#define GPGMEPLUG_SIGN_CTENC_CODE ""
|
||||
#define GPGMEPLUG_SIGN_FLAT_PREFIX ""
|
||||
#define GPGMEPLUG_SIGN_FLAT_SEPARATOR ""
|
||||
#define GPGMEPLUG_SIGN_FLAT_POSTFIX ""
|
||||
#endif
|
||||
#ifndef GPGMEPLUG_ENC_MAKE_MIME_OBJECT
|
||||
#define GPGMEPLUG_ENC_INCLUDE_CLEARTEXT false
|
||||
#define GPGMEPLUG_ENC_MAKE_MIME_OBJECT true
|
||||
#define GPGMEPLUG_ENC_MAKE_MULTI_MIME true
|
||||
#define GPGMEPLUG_ENC_CTYPE_MAIN "multipart/encrypted; protocol=application/pgp-encrypted"
|
||||
#define GPGMEPLUG_ENC_CDISP_MAIN ""
|
||||
#define GPGMEPLUG_ENC_CTENC_MAIN ""
|
||||
#define GPGMEPLUG_ENC_CTYPE_VERSION "application/pgp-encrypted"
|
||||
#define GPGMEPLUG_ENC_CDISP_VERSION "attachment"
|
||||
#define GPGMEPLUG_ENC_CTENC_VERSION ""
|
||||
#define GPGMEPLUG_ENC_BTEXT_VERSION "Version: 1"
|
||||
#define GPGMEPLUG_ENC_CTYPE_CODE "application/octet-stream"
|
||||
#define GPGMEPLUG_ENC_CDISP_CODE "inline; filename=\"msg.asc\""
|
||||
#define GPGMEPLUG_ENC_CTENC_CODE ""
|
||||
#define GPGMEPLUG_ENC_FLAT_PREFIX ""
|
||||
#define GPGMEPLUG_ENC_FLAT_SEPARATOR ""
|
||||
#define GPGMEPLUG_ENC_FLAT_POSTFIX ""
|
||||
#endif
|
||||
// Note: The following specification will result in
|
||||
// function encryptAndSignMessage() producing
|
||||
// _empty_ mails.
|
||||
// This must be changed as soon as our plugin
|
||||
// is supporting the encryptAndSignMessage() function.
|
||||
#ifndef GPGMEPLUG_ENCSIGN_MAKE_MIME_OBJECT
|
||||
#define GPGMEPLUG_ENCSIGN_INCLUDE_CLEARTEXT false
|
||||
#define GPGMEPLUG_ENCSIGN_MAKE_MIME_OBJECT false
|
||||
#define GPGMEPLUG_ENCSIGN_MAKE_MULTI_MIME false
|
||||
#define GPGMEPLUG_ENCSIGN_CTYPE_MAIN ""
|
||||
#define GPGMEPLUG_ENCSIGN_CDISP_MAIN ""
|
||||
#define GPGMEPLUG_ENCSIGN_CTENC_MAIN ""
|
||||
#define GPGMEPLUG_ENCSIGN_CTYPE_VERSION ""
|
||||
#define GPGMEPLUG_ENCSIGN_CDISP_VERSION ""
|
||||
#define GPGMEPLUG_ENCSIGN_CTENC_VERSION ""
|
||||
#define GPGMEPLUG_ENCSIGN_BTEXT_VERSION ""
|
||||
#define GPGMEPLUG_ENCSIGN_CTYPE_CODE ""
|
||||
#define GPGMEPLUG_ENCSIGN_CDISP_CODE ""
|
||||
#define GPGMEPLUG_ENCSIGN_CTENC_CODE ""
|
||||
#define GPGMEPLUG_ENCSIGN_FLAT_PREFIX ""
|
||||
#define GPGMEPLUG_ENCSIGN_FLAT_SEPARATOR ""
|
||||
#define GPGMEPLUG_ENCSIGN_FLAT_POSTFIX ""
|
||||
#endif
|
||||
|
||||
#include "cryptplug.h"
|
||||
|
||||
|
||||
@ -694,9 +753,22 @@ bool certificateValidity( const char* certificate,
|
||||
int* level ){ return true; }
|
||||
|
||||
|
||||
void storeNewCharPtr( char** dest, const char* src )
|
||||
{
|
||||
int sLen;
|
||||
if( *dest && src ) {
|
||||
sLen = strlen( src );
|
||||
*dest = malloc( sLen + 1 );
|
||||
strncpy( *dest, src, sLen );
|
||||
*dest[sLen] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool signMessage( const char* cleartext,
|
||||
const char** ciphertext,
|
||||
const char* certificate )
|
||||
const char* certificate,
|
||||
struct StructuringInfo* structuring )
|
||||
{
|
||||
GpgmeCtx ctx;
|
||||
GpgmeError err;
|
||||
@ -720,6 +792,8 @@ bool signMessage( const char* cleartext,
|
||||
|
||||
|
||||
|
||||
init_StructuringInfo( structuring );
|
||||
|
||||
if( !ciphertext )
|
||||
return false;
|
||||
|
||||
@ -777,6 +851,42 @@ bool signMessage( const char* cleartext,
|
||||
gpgme_data_release( data );
|
||||
gpgme_release (ctx);
|
||||
|
||||
if( bOk && structuring ) {
|
||||
structuring->includeCleartext = GPGMEPLUG_SIGN_INCLUDE_CLEARTEXT;
|
||||
structuring->makeMimeObject = GPGMEPLUG_SIGN_MAKE_MIME_OBJECT;
|
||||
if( structuring->makeMimeObject ) {
|
||||
structuring->makeMultiMime = GPGMEPLUG_SIGN_MAKE_MULTI_MIME;
|
||||
storeNewCharPtr( &structuring->contentTypeMain,
|
||||
GPGMEPLUG_SIGN_CTYPE_MAIN );
|
||||
storeNewCharPtr( &structuring->contentDispMain,
|
||||
GPGMEPLUG_SIGN_CDISP_MAIN );
|
||||
storeNewCharPtr( &structuring->contentTEncMain,
|
||||
GPGMEPLUG_SIGN_CTENC_MAIN );
|
||||
if( structuring->makeMultiMime ) {
|
||||
storeNewCharPtr( &structuring->contentTypeVersion,
|
||||
GPGMEPLUG_SIGN_CTYPE_VERSION );
|
||||
storeNewCharPtr( &structuring->contentDispVersion,
|
||||
GPGMEPLUG_SIGN_CDISP_VERSION );
|
||||
storeNewCharPtr( &structuring->contentTEncVersion,
|
||||
GPGMEPLUG_SIGN_CTENC_VERSION );
|
||||
storeNewCharPtr( &structuring->bodyTextVersion,
|
||||
GPGMEPLUG_SIGN_BTEXT_VERSION );
|
||||
storeNewCharPtr( &structuring->contentTypeCode,
|
||||
GPGMEPLUG_SIGN_CTYPE_CODE );
|
||||
storeNewCharPtr( &structuring->contentDispCode,
|
||||
GPGMEPLUG_SIGN_CDISP_CODE );
|
||||
storeNewCharPtr( &structuring->contentTEncCode,
|
||||
GPGMEPLUG_SIGN_CTENC_CODE );
|
||||
}
|
||||
} else {
|
||||
storeNewCharPtr( &structuring->flatTextPrefix,
|
||||
GPGMEPLUG_SIGN_FLAT_PREFIX );
|
||||
storeNewCharPtr( &structuring->flatTextSeparator,
|
||||
GPGMEPLUG_SIGN_FLAT_SEPARATOR );
|
||||
storeNewCharPtr( &structuring->flatTextPostfix,
|
||||
GPGMEPLUG_SIGN_FLAT_POSTFIX );
|
||||
}
|
||||
}
|
||||
return bOk;
|
||||
}
|
||||
|
||||
@ -905,7 +1015,8 @@ bool storeCertificatesFromMessage(
|
||||
|
||||
bool encryptMessage( const char* cleartext,
|
||||
const char** ciphertext,
|
||||
const char* addressee )
|
||||
const char* addressee,
|
||||
struct StructuringInfo* structuring )
|
||||
{
|
||||
GpgmeCtx ctx;
|
||||
GpgmeError err;
|
||||
@ -915,6 +1026,8 @@ bool encryptMessage( const char* cleartext,
|
||||
char* rCiph = 0;
|
||||
bool bOk = false;
|
||||
|
||||
init_StructuringInfo( structuring );
|
||||
|
||||
gpgme_new (&ctx);
|
||||
gpgme_set_protocol (ctx, GPGMEPLUG_PROTOCOL);
|
||||
|
||||
@ -973,13 +1086,97 @@ bool encryptMessage( const char* cleartext,
|
||||
|
||||
fflush( stderr );
|
||||
|
||||
if( bOk && structuring ) {
|
||||
structuring->includeCleartext = GPGMEPLUG_ENC_INCLUDE_CLEARTEXT;
|
||||
structuring->makeMimeObject = GPGMEPLUG_ENC_MAKE_MIME_OBJECT;
|
||||
if( structuring->makeMimeObject ) {
|
||||
structuring->makeMultiMime = GPGMEPLUG_ENC_MAKE_MULTI_MIME;
|
||||
storeNewCharPtr( &structuring->contentTypeMain,
|
||||
GPGMEPLUG_ENC_CTYPE_MAIN );
|
||||
storeNewCharPtr( &structuring->contentDispMain,
|
||||
GPGMEPLUG_ENC_CDISP_MAIN );
|
||||
storeNewCharPtr( &structuring->contentTEncMain,
|
||||
GPGMEPLUG_ENC_CTENC_MAIN );
|
||||
if( structuring->makeMultiMime ) {
|
||||
storeNewCharPtr( &structuring->contentTypeVersion,
|
||||
GPGMEPLUG_ENC_CTYPE_VERSION );
|
||||
storeNewCharPtr( &structuring->contentDispVersion,
|
||||
GPGMEPLUG_ENC_CDISP_VERSION );
|
||||
storeNewCharPtr( &structuring->contentTEncVersion,
|
||||
GPGMEPLUG_ENC_CTENC_VERSION );
|
||||
storeNewCharPtr( &structuring->bodyTextVersion,
|
||||
GPGMEPLUG_ENC_BTEXT_VERSION );
|
||||
storeNewCharPtr( &structuring->contentTypeCode,
|
||||
GPGMEPLUG_ENC_CTYPE_CODE );
|
||||
storeNewCharPtr( &structuring->contentDispCode,
|
||||
GPGMEPLUG_ENC_CDISP_CODE );
|
||||
storeNewCharPtr( &structuring->contentTEncCode,
|
||||
GPGMEPLUG_ENC_CTENC_CODE );
|
||||
}
|
||||
} else {
|
||||
storeNewCharPtr( &structuring->flatTextPrefix,
|
||||
GPGMEPLUG_ENC_FLAT_PREFIX );
|
||||
storeNewCharPtr( &structuring->flatTextSeparator,
|
||||
GPGMEPLUG_ENC_FLAT_SEPARATOR );
|
||||
storeNewCharPtr( &structuring->flatTextPostfix,
|
||||
GPGMEPLUG_ENC_FLAT_POSTFIX );
|
||||
}
|
||||
}
|
||||
return bOk;
|
||||
}
|
||||
|
||||
|
||||
bool encryptAndSignMessage( const char* cleartext,
|
||||
const char** ciphertext, const char* certificate,
|
||||
struct SignatureMetaData* sigmeta ){ return true; }
|
||||
const char** ciphertext,
|
||||
const char* certificate,
|
||||
struct StructuringInfo* structuring )
|
||||
{
|
||||
bool bOk;
|
||||
|
||||
init_StructuringInfo( structuring );
|
||||
|
||||
bOk = false;
|
||||
|
||||
// implementation of this function is still missing
|
||||
|
||||
if( bOk && structuring ) {
|
||||
structuring->includeCleartext = GPGMEPLUG_ENCSIGN_INCLUDE_CLEARTEXT;
|
||||
structuring->makeMimeObject = GPGMEPLUG_ENCSIGN_MAKE_MIME_OBJECT;
|
||||
if( structuring->makeMimeObject ) {
|
||||
structuring->makeMultiMime = GPGMEPLUG_ENCSIGN_MAKE_MULTI_MIME;
|
||||
storeNewCharPtr( &structuring->contentTypeMain,
|
||||
GPGMEPLUG_ENCSIGN_CTYPE_MAIN );
|
||||
storeNewCharPtr( &structuring->contentDispMain,
|
||||
GPGMEPLUG_ENCSIGN_CDISP_MAIN );
|
||||
storeNewCharPtr( &structuring->contentTEncMain,
|
||||
GPGMEPLUG_ENCSIGN_CTENC_MAIN );
|
||||
if( structuring->makeMultiMime ) {
|
||||
storeNewCharPtr( &structuring->contentTypeVersion,
|
||||
GPGMEPLUG_ENCSIGN_CTYPE_VERSION );
|
||||
storeNewCharPtr( &structuring->contentDispVersion,
|
||||
GPGMEPLUG_ENCSIGN_CDISP_VERSION );
|
||||
storeNewCharPtr( &structuring->contentTEncVersion,
|
||||
GPGMEPLUG_ENCSIGN_CTENC_VERSION );
|
||||
storeNewCharPtr( &structuring->bodyTextVersion,
|
||||
GPGMEPLUG_ENCSIGN_BTEXT_VERSION );
|
||||
storeNewCharPtr( &structuring->contentTypeCode,
|
||||
GPGMEPLUG_ENCSIGN_CTYPE_CODE );
|
||||
storeNewCharPtr( &structuring->contentDispCode,
|
||||
GPGMEPLUG_ENCSIGN_CDISP_CODE );
|
||||
storeNewCharPtr( &structuring->contentTEncCode,
|
||||
GPGMEPLUG_ENCSIGN_CTENC_CODE );
|
||||
}
|
||||
} else {
|
||||
storeNewCharPtr( &structuring->flatTextPrefix,
|
||||
GPGMEPLUG_ENCSIGN_FLAT_PREFIX );
|
||||
storeNewCharPtr( &structuring->flatTextSeparator,
|
||||
GPGMEPLUG_ENCSIGN_FLAT_SEPARATOR );
|
||||
storeNewCharPtr( &structuring->flatTextPostfix,
|
||||
GPGMEPLUG_ENCSIGN_FLAT_POSTFIX );
|
||||
}
|
||||
}
|
||||
return bOk;
|
||||
}
|
||||
|
||||
bool decryptMessage( const char* ciphertext,
|
||||
const char** cleartext,
|
||||
|
Loading…
Reference in New Issue
Block a user