pEpCOMServerAdapter.idl
author Markus Schaber <markus@pep-security.net>
Wed, 07 Feb 2018 19:42:45 +0100
branchCOM-74
changeset 272 0cd9b4cde17c
parent 271 92866cd8b0c4
child 273 30be98685afa
permissions -rw-r--r--
COM-74: Expose _PEP_enc_format to app for EncryptMessage

- Suppress exception in the now-common case of PEP_KEY_NOT_FOUND as requested by Thomas.
     1 // pEpCOMServerAdapter.idl : IDL source for pEpCOMServerAdapter
     2 //
     3 
     4 // This file will be processed by the MIDL tool to
     5 // produce the type library (pEpCOMServerAdapter.tlb) and marshalling code.
     6 
     7 import "oaidl.idl";
     8 import "ocidl.idl";
     9 
    10 [
    11     object,
    12     uuid(4DA92647-A858-448E-B01F-BE4DCB8C86A1),
    13     oleautomation,
    14     nonextensible,
    15     pointer_default(unique)
    16 ]
    17 interface IpEpEngineCallbacks : IUnknown {
    18     typedef [v1_enum] enum SyncHandshakeSignal {
    19         SyncNotifyUndefined = 0,
    20 
    21         // request show handshake dialog
    22         SyncNotifyInitAddOurDevice = 1,
    23         SyncNotifyInitAddOtherDevice = 2,
    24         SyncNotifyInitFormGroup = 3,
    25         SyncNotifyInitMoveOurDevice = 4,
    26 
    27         // handshake process timed out
    28         SyncNotifyTimeout = 5,
    29 
    30         // handshake accepted by user
    31         SyncNotifyAcceptedDeviceAdded = 6,
    32         SyncNotifyAcceptedGroupCreated = 7,
    33         SyncNotifyAcceptedDeviceMoved = 8,
    34 
    35         // handshake dialog must be closed
    36         SyncNotifyOvertaken = 9,
    37     } SyncHandshakeSignal;
    38 
    39     typedef [v1_enum] enum SyncHandshakeResult {
    40         SyncHandshakeCancel = -1,
    41         SyncHandshakeAccepted = 0,
    42         SyncHandshakeRejected = 1
    43     } SyncHandshakeResult;
    44 
    45     [id(1)] HRESULT MessageToSend([in] struct TextMessage * msg);
    46 
    47     [id(2)] HRESULT NotifyHandshake([in] struct pEpIdentity * self, [in] struct pEpIdentity * partner, [in] SyncHandshakeSignal signal, [out, retval] SyncHandshakeResult * result);
    48 
    49     [id(3)] HRESULT NeedFastPolling([in] VARIANT_BOOL enableFastPolling);
    50 };
    51 
    52 [
    53     object,
    54     uuid(045E49AF-0975-4876-A53B-8CA5AB28C0F8),
    55     oleautomation,
    56     nonextensible,
    57     pointer_default(unique)
    58 ]
    59 interface IpEpEngine : IUnknown {
    60 
    61     // runtime config of the adapter
    62 
    63     [id(1)] HRESULT VerboseLogging([in] VARIANT_BOOL enable);
    64 
    65     // runtime config of the engine
    66 
    67     [id(2)] HRESULT PassiveMode([in] VARIANT_BOOL enable);
    68     [id(3)] HRESULT UnencryptedSubject([in] VARIANT_BOOL enable);
    69 
    70     // basic API
    71 
    72     [id(4)] HRESULT ExportKey([in] BSTR fpr, [out, retval] BSTR * keyData);
    73     [id(5)] HRESULT Log([in] BSTR title, [in] BSTR entity, [in, defaultvalue("")] BSTR description, [in, defaultvalue("")] BSTR comment);
    74     [id(6)] HRESULT Trustwords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG maxWords, [out, retval] BSTR * words);
    75     [id(7)] HRESULT GetTrustwords([in] struct pEpIdentity * id1, [in] struct pEpIdentity * id2, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] VARIANT_BOOL full, [out, retval] BSTR * words);
    76     [id(8)] HRESULT GetCrashdumpLog([in, defaultvalue(0)] LONG maxlines, [out, retval] BSTR * log);
    77     [id(9)] HRESULT GetEngineVersion([out, retval] BSTR * engineVersion);
    78     [id(10)] HRESULT GetLanguageList([out, retval] BSTR * languages);
    79 
    80     typedef [v1_enum] enum pEpComType {
    81         pEpCtUnknown = 0,
    82 
    83         // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
    84 
    85         pEpCtNoEncryption = 0x01,                // generic
    86         pEpCtNoEncryptedChannel = 0x02,
    87         pEpCtKeyNotFound = 0x03,
    88         pEpCtKeyExpired = 0x04,
    89         pEpCtKeyRevoked = 0x05,
    90         pEpCtKeyB0rken = 0x06,
    91         pEpCtMyKeyNotIncluded = 0x09,
    92 
    93         pEpCtSecurityByObscurity = 0x0a,
    94         pEpCtB0rkenCrypto = 0x0b,
    95         pEpCtKeyTooShort = 0x0c,
    96 
    97         pEpCtCompromised = 0x0e,                 // known compromized connection
    98         pEpCtMistrusted = 0x0f,                  // known mistrusted key
    99 
   100         // range 0x10 to 0x3f: unconfirmed encryption
   101 
   102         pEpCtUnconfirmedEncryption = 0x10,       // generic
   103         pEpCtOpenPGPWeakUnconfirmed = 0x11,      // RSA 1024 is weak
   104 
   105         pEpCtToBeChecked = 0x20,                 // generic
   106         pEpCtSMIMEUnconfirmed = 0x21,
   107         pEpCtCMSUnconfirmed = 0x22,
   108 
   109         pEpCtStrongButUnconfirmed = 0x30,        // generic
   110         pEpCtOpenPGPUnconfirmed = 0x38,          // key at least 2048 bit RSA or EC
   111         pEpCtOTRUnconfirmed = 0x3a,
   112 
   113         // range 0x40 to 0x7f: unconfirmed encryption and anonymization
   114 
   115         pEpCtUnconfirmedEncAnon = 0x40,          // generic
   116         pEpCtpEpUnconfirmed = 0x7f,
   117 
   118         pEpCtConfirmed = 0x80,                   // this bit decides if trust is confirmed
   119 
   120         // range 0x81 to 0x8f: reserved
   121         // range 0x90 to 0xbf: confirmed encryption
   122 
   123         pEpCtConfirmedEncryption = 0x90,         // generic
   124         pEpCtOpenPGPWeak = 0x91,                 // RSA 1024 is weak
   125 
   126         pEpCtToBeCheckedConfirmed = 0xa0,        // generic
   127         pEpCtSMIME = 0xa1,
   128         pEpCtCMS = 0xa2,
   129 
   130         pEpCtStrongEncryption = 0xb0,            // generic
   131         pEpCtOpenPGP = 0xb8,                     // key at least 2048 bit RSA or EC
   132         pEpCtOTR = 0xba,
   133 
   134         // range 0xc0 to 0xff: confirmed encryption and anonymization
   135 
   136         pEpCtConfirmedEncAnon = 0xc0,            // generic
   137         pEpCtpEp = 0xff
   138     } pEpComType;
   139 
   140     typedef [v1_enum] enum pEpIdentityFlags {
   141         pEpIdfNone = 0,
   142         pEpIdfNotForSync = 0x0001,
   143         pEpIdfList = 0x0002,
   144         pEpIdfDevicegroup = 0x0100
   145     } pEpIdentityFlags;
   146 
   147     [uuid(C3A3814E-567F-4D1C-9F44-9B1DA3957A89)] struct pEpIdentity {
   148         BSTR Address;
   149         BSTR Fpr;
   150         BSTR UserId;
   151         BSTR UserName;
   152         pEpComType CommType;
   153         BSTR Lang;
   154         pEpIdentityFlags Flags;
   155     };
   156 
   157     [id(11)] HRESULT SetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
   158     [id(12)] HRESULT UnsetIdentityFlags([in] struct pEpIdentity *identity, [in] pEpIdentityFlags flags);
   159 
   160     // Keymanagement API
   161 
   162     [id(13)] HRESULT StartKeyserverLookup();
   163     [id(14)] HRESULT StopKeyserverLookup();
   164 
   165     [id(15)] HRESULT Myself([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   166     [id(16)] HRESULT UpdateIdentity([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   167     [id(17)] HRESULT KeyMistrusted([in] struct pEpIdentity *ident);
   168     [id(18)] HRESULT KeyResetTrust([in] struct pEpIdentity *ident);
   169     [id(19)] HRESULT TrustPersonalKey([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   170     [id(20)] HRESULT OwnIdentitiesRetrieve([out, retval] SAFEARRAY(struct pEpIdentity)* ownIdentities);
   171     [id(21)] HRESULT UndoLastMistrust();
   172 
   173     // Blacklist API
   174 
   175     [id(22)] HRESULT BlacklistAdd([in] BSTR fpr);
   176     [id(23)] HRESULT BlacklistDelete([in] BSTR fpr);
   177     [id(24)] HRESULT BlacklistIsListed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
   178     [id(25)] HRESULT BlacklistRetrieve([out, retval] SAFEARRAY(BSTR) *blacklist);
   179 
   180     // PGP compatibility functions
   181 
   182     [id(26)] HRESULT OpenPGPListKeyinfo([in] BSTR searchPattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfoList);
   183 
   184     // Message API
   185 
   186     typedef [v1_enum] enum pEpRating {
   187         pEpRatingUndefined = 0,
   188         pEpRatingCannotDecrypt,
   189         pEpRatingHaveNoKey,
   190         pEpRatingUnencrypted,
   191         pEpRatingUnencryptedForSome,
   192         pEpRatingUnreliable,
   193         pEpRatingReliable,
   194         pEpRatingTrusted,
   195         pEpRatingTrustedAndAnonymized,
   196         pEpRatingFullyAnonymous,
   197 
   198         pEpRatingMistrust = -1,
   199         pEpRatingB0rken = -2,
   200         pEpRatingUnderAttack = -3
   201     } pEpRating;
   202 
   203     typedef [v1_enum] enum pEpColor {
   204         pEpColorNoColor = 0,
   205         pEpColorYellow,
   206         pEpColorGreen,
   207         pEpColorRed = -1,
   208     } pEpColor;
   209 
   210     typedef [v1_enum] enum pEpEncryptFlags {
   211         pEpEncryptFlagDefault = 0,
   212         pEpEncryptFlagForceEncryption = 0x1,
   213 
   214         // This flag is for special uses and should not be used
   215         // by normal pEp clients!
   216         pEpEncryptFlagForceUnsigned = 0x2,
   217 
   218         // This flag is for special uses and should not be used
   219         // by normal pEp clients!
   220         pEpEncryptFlagForceNoAttachedKey = 0x4,
   221 
   222     } pEpEncryptFlags;
   223 
   224     typedef [v1_enum] enum pEpDecryptFlags {
   225         pEpDecryptFlagsNone = 0,
   226         pEpDecryptFlagOwnPrivateKey = 0x1,
   227         pEpDecryptFlagConsume = 0x2,
   228         pEpDecryptFlagIgnore = 0x4
   229     } pEpDecryptFlags;
   230 
   231     typedef [v1_enum] enum pEpMsgDirection {
   232         pEpDirIncoming = 0,
   233         pEpDirOutgoing
   234     } pEpMsgDirection;
   235 
   236     typedef [v1_enum] enum pEpEncFormat {
   237         pEpEncNone = 0,                       // message is not encrypted
   238         pEpEncPieces,                         // inline PGP + PGP extensions
   239         pEpEncSMime,                          // RFC5751
   240         pEpEncPgpMime,                        // RFC3156
   241         pEpEncPep,                            // pEp encryption format
   242         pEpEncPgpMimeOutlook1                 // Message B0rken by Outlook type 1
   243     } pEpEncFormat;
   244 
   245     [uuid(47FB0795-6B64-455C-BB0E-54998CAB8ACB)] struct StringPair {
   246         BSTR Name;
   247         BSTR Value;
   248     };
   249 
   250     [uuid(634EB7CE-99AA-460D-BDF8-F7CDA7232CA6)] struct Blob {
   251         SAFEARRAY(BYTE) value;
   252         BSTR MimeType;
   253         BSTR Filename;
   254     };
   255 
   256     [uuid(B6F40887-E761-4A47-B204-A0193EE0284D)] struct TextMessage {
   257         pEpMsgDirection Dir;
   258         BSTR Id;
   259         BSTR ShortMsg;
   260         BSTR LongMsg;
   261         BSTR LongMsgFormatted;
   262         SAFEARRAY(struct Blob) Attachments;
   263         hyper Sent; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
   264         hyper Recv; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
   265         struct pEpIdentity From;
   266         SAFEARRAY(struct pEpIdentity) To;
   267         struct pEpIdentity RecvBy;
   268         SAFEARRAY(struct pEpIdentity) Cc;
   269         SAFEARRAY(struct pEpIdentity) Bcc;
   270         SAFEARRAY(struct pEpIdentity) ReplyTo;
   271         SAFEARRAY(BSTR) References;
   272         SAFEARRAY(BSTR) Keywords;
   273         BSTR Comments;
   274         SAFEARRAY(struct StringPair) OptFields;
   275     };
   276 
   277     [id(27)] HRESULT EncryptMessage(
   278         [in] struct TextMessage *src,
   279         [out] struct TextMessage * dst,
   280         [in] SAFEARRAY(BSTR) extra,
   281         [in, defaultvalue(pEpEncryptFlagDefault)] pEpEncryptFlags flags,
   282         // Use pEpEncFormat.pEpEncNone for unencrypted, outgoing messages.
   283         // Default is pEpEncFormat.pEpEncPep, all other formats are only 
   284         // for compatibility and not intended for normal use.
   285         [in, defaultvalue(pEpEncPep)] pEpEncFormat encFormat);
   286 
   287     [id(28)] HRESULT DecryptMessage(
   288         [in] struct TextMessage *src,
   289         [out] struct TextMessage * dst,
   290         [out] SAFEARRAY(BSTR) *keylist,
   291         [out] pEpDecryptFlags* flags,
   292         [out, retval] pEpRating *rating);
   293 
   294     [id(29)] HRESULT OutgoingMessageRating([in] struct TextMessage *msg, [out, retval] pEpRating * pVal);
   295     [id(30)] HRESULT IdentityRating([in] struct pEpIdentity * ident, [out, retval] pEpRating * pVal);
   296     [id(31)] HRESULT ColorFromRating([in] pEpRating rating, [out, retval] pEpColor* pVal);
   297 
   298     [id(32)] HRESULT GetMessageTrustwords(
   299         [in] struct TextMessage *msg,
   300         [in] struct pEpIdentity * receivedBy,
   301         [in] SAFEARRAY(BSTR) keylist,
   302         [in, defaultvalue("en")] BSTR lang,
   303         [in, defaultvalue(0)] VARIANT_BOOL full,
   304         [out, retval] BSTR * words
   305     );
   306 
   307     [id(33)] HRESULT EncryptMessageForSelf(
   308         [in] struct pEpIdentity* targetId,
   309         [in] struct TextMessage* src,
   310         [out] struct TextMessage* dst,
   311         [in, defaultvalue(pEpEncryptFlagDefault)] pEpEncryptFlags flags
   312     );
   313 
   314     [id(34)] HRESULT ReEvaluateMessageRating(
   315         [in] struct TextMessage *src,
   316         [in] SAFEARRAY(BSTR) x_KeyList, // referring to X-KeyList mail header
   317         [in] pEpRating x_EncStatus, // referring to X-EncStatus mail header
   318         [out, retval] pEpRating *rating
   319     );
   320 
   321     // callback / keysync API
   322     [id(35)] HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* newCallback);
   323     [id(36)] HRESULT UnregisterCallbacks();
   324 };
   325 
   326 [
   327     uuid(564A4350-419E-47F1-B0DF-6FCCF0CD0BBC),
   328     version(1.0),
   329 ]
   330 library pEpCOMServerAdapterLib
   331 {
   332     importlib("stdole2.tlb");
   333 
   334     [
   335         uuid(5FF6682B-727B-4DFE-A68D-28982874C0C7)
   336     ]
   337     coclass pEpEngine {
   338         [default] interface IpEpEngine;
   339         interface IpEpEngineCallbacks;
   340     };
   341 };