pEpCOMServerAdapter.idl
author Markus Schaber <markus@pep-security.net>
Mon, 03 Oct 2016 19:15:35 +0200
branchkeysync
changeset 171 44bfd5428aa9
parent 169 d776268c12a7
child 172 112b0fac353d
permissions -rw-r--r--
COM-31: Rename opt_field to StringPair
     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 typedef enum _sync_handshake_result_s {
    12 	SYNC_HANDSHAKE_CANCEL_S = -1,
    13 	SYNC_HANDSHAKE_ACCEPTED_S = 0,
    14 	SYNC_HANDSHAKE_REJECTED_S = 1
    15 } sync_handshake_result_s;
    16 
    17 [
    18 	object,
    19 	uuid(3BA1B15B-27EF-433C-B780-0D08F46B0FF3),
    20 	oleautomation,
    21 	nonextensible,
    22 	pointer_default(unique)
    23 ]
    24 interface IpEpEngineCallbacks : IUnknown {
    25 	[id(1)] HRESULT MessageToSend([in] struct text_message * msg);
    26 	[id(2)] HRESULT ShowHandshake([in] struct pEp_identity_s * self, [in] struct pEp_identity_s * partner, [out, retval] sync_handshake_result_s * result);
    27 };
    28 
    29 
    30 [
    31     object,
    32     uuid(9A9F4422-CF0A-45D7-90CD-1D1B7B2A4540),
    33     oleautomation,
    34     nonextensible,
    35     pointer_default(unique)
    36 ]
    37 interface IpEpEngine : IUnknown {
    38     // runtime config of the adapter
    39 
    40     HRESULT verbose_logging([in] VARIANT_BOOL enable);
    41 
    42     // runtime config of the engine
    43 
    44     HRESULT passive_mode([in] VARIANT_BOOL enable);
    45     HRESULT unencrypted_subject([in] VARIANT_BOOL enable);
    46 
    47     // basic API
    48 
    49     typedef enum _pEp_STATUS {
    50         pEp_STATUS_OK = 0,
    51 
    52         pEp_INIT_CANNOT_LOAD_GPGME = 0x0110,
    53         pEp_INIT_GPGME_INIT_FAILED = 0x0111,
    54         pEp_INIT_NO_GPG_HOME = 0x0112,
    55         pEp_INIT_NETPGP_INIT_FAILED = 0x0113,
    56 
    57         pEp_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
    58         pEp_INIT_CANNOT_OPEN_DB = 0x0121,
    59         pEp_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
    60 
    61         pEp_KEY_NOT_FOUND = 0x0201,
    62         pEp_KEY_HAS_AMBIG_NAME = 0x0202,
    63         pEp_GET_KEY_FAILED = 0x0203,
    64 
    65         pEp_CANNOT_FIND_IDENTITY = 0x0301,
    66         pEp_CANNOT_SET_PERSON = 0x0381,
    67         pEp_CANNOT_SET_PGP_KEYPAIR = 0x0382,
    68         pEp_CANNOT_SET_IDENTITY = 0x0383,
    69         pEp_CANNOT_SET_TRUST = 0x0384,
    70 
    71         pEp_UNENCRYPTED = 0x0400,
    72         pEp_VERIFIED = 0x0401,
    73         pEp_DECRYPTED = 0x0402,
    74         pEp_DECRYPTED_AND_VERIFIED = 0x0403,
    75         pEp_DECRYPT_WRONG_FORMAT = 0x0404,
    76         pEp_DECRYPT_NO_KEY = 0x0405,
    77         pEp_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
    78         pEp_VERIFY_NO_KEY = 0x0407,
    79         pEp_VERIFIED_AND_TRUSTED = 0x0408,
    80         pEp_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
    81 
    82         pEp_TRUSTWORD_NOT_FOUND = 0x0501,
    83 
    84         pEp_CANNOT_CREATE_KEY = 0x0601,
    85         pEp_CANNOT_SEND_KEY = 0x0602,
    86 
    87         pEp_PHRASE_NOT_FOUND = 0x0701,
    88 
    89         pEp_COMMIT_FAILED = 0xff01,
    90 
    91         pEp_CANNOT_CREATE_TEMP_FILE = -5,
    92         pEp_ILLEGAL_VALUE = -4,
    93         pEp_BUFFER_TOO_SMALL = -3,
    94         pEp_OUT_OF_MEMORY = -2,
    95         pEp_UNKNOWN_ERROR = -1
    96     } pEp_STATUS;
    97 
    98     HRESULT log([in] BSTR title, [in] BSTR entity, [in, defaultvalue("")] BSTR description, [in, defaultvalue("")] BSTR comment);
    99     HRESULT decrypt([in] BSTR ctext, [out] BSTR * ptext, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEp_STATUS * decrypt_status);
   100     HRESULT decrypt_b([in] BSTR ctext, [out] SAFEARRAY(BYTE) * ptext, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEp_STATUS * decrypt_status);
   101     HRESULT encrypt([in] SAFEARRAY(BSTR) key_list, [in] BSTR ptext, [out] BSTR * ctext, [out, retval] pEp_STATUS * status);
   102     HRESULT encrypt_b([in] SAFEARRAY(BSTR) key_list, [in] SAFEARRAY(BYTE) ptext, [out] BSTR * ctext, [out, retval] pEp_STATUS * status);
   103     HRESULT verify([in] BSTR text, [in] BSTR signature, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEp_STATUS * verify_status);
   104     HRESULT trustword([in] LONG value, [in, defaultvalue("en")] BSTR lang, [out, retval] BSTR * word);
   105     HRESULT trustwords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG max_words, [out, retval] BSTR * words);
   106     HRESULT get_crashdump_log([in, defaultvalue(0)] LONG maxlines, [out, retval] BSTR * log);
   107     HRESULT get_engine_version([out, retval] BSTR * engine_version);
   108     HRESULT get_languagelist([out, retval] BSTR * languages);
   109     HRESULT get_phrase([in] BSTR lang, [in] LONG phrase_id, [out, retval] BSTR * phrase);
   110 
   111     typedef enum _pEp_comm_type {
   112         pEp_ct_unknown = 0,
   113 
   114         // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
   115 
   116         pEp_ct_no_encryption = 0x01,                // generic
   117         pEp_ct_no_encrypted_channel = 0x02,
   118         pEp_ct_key_not_found = 0x03,
   119         pEp_ct_key_expired = 0x04,
   120         pEp_ct_key_revoked = 0x05,
   121         pEp_ct_key_b0rken = 0x06,
   122         pEp_ct_my_key_not_included = 0x09,
   123 
   124         pEp_ct_security_by_obscurity = 0x0a,
   125         pEp_ct_b0rken_crypto = 0x0b,
   126         pEp_ct_key_too_short = 0x0c,
   127 
   128         pEp_ct_compromized = 0x0e,                  // known compromized connection
   129         pEp_ct_mistrusted = 0x0f,                   // known mistrusted key
   130 
   131         // range 0x10 to 0x3f: unconfirmed encryption
   132 
   133         pEp_ct_unconfirmed_encryption = 0x10,       // generic
   134         pEp_ct_OpenPGP_weak_unconfirmed = 0x11,     // RSA 1024 is weak
   135 
   136         pEp_ct_to_be_checked = 0x20,                // generic
   137         pEp_ct_SMIME_unconfirmed = 0x21,
   138         pEp_ct_CMS_unconfirmed = 0x22,
   139 
   140         pEp_ct_strong_but_unconfirmed = 0x30,       // generic
   141         pEp_ct_OpenPGP_unconfirmed = 0x38,          // key at least 2048 bit RSA or EC
   142         pEp_ct_OTR_unconfirmed = 0x3a,
   143 
   144         // range 0x40 to 0x7f: unconfirmed encryption and anonymization
   145 
   146         pEp_ct_unconfirmed_enc_anon = 0x40,         // generic
   147         pEp_ct_pEp_unconfirmed = 0x7f,
   148 
   149         pEp_ct_confirmed = 0x80,                    // this bit decides if trust is confirmed
   150 
   151         // range 0x81 to 0x8f: reserved
   152         // range 0x90 to 0xbf: confirmed encryption
   153 
   154         pEp_ct_confirmed_encryption = 0x90,         // generic
   155         pEp_ct_OpenPGP_weak = 0x91,                 // RSA 1024 is weak
   156 
   157         pEp_ct_to_be_checked_confirmed = 0xa0,      //generic
   158         pEp_ct_SMIME = 0xa1,
   159         pEp_ct_CMS = 0xa2,
   160 
   161         pEp_ct_strong_encryption = 0xb0,            // generic
   162         pEp_ct_OpenPGP = 0xb8,                      // key at least 2048 bit RSA or EC
   163         pEp_ct_OTR = 0xba,
   164 
   165         // range 0xc0 to 0xff: confirmed encryption and anonymization
   166 
   167         pEp_ct_confirmed_enc_anon = 0xc0,           // generic
   168         pEp_ct_pEp = 0xff
   169     } pEp_comm_type;
   170 
   171     [uuid(0CB90E62-8A6A-4CA0-99D7-481704051FF0)] struct pEp_identity_s {
   172         BSTR address;
   173         BSTR fpr;
   174         BSTR user_id;
   175         BSTR username;
   176         pEp_comm_type comm_type;
   177         BSTR lang;
   178     };
   179 
   180     HRESULT get_identity([in] BSTR address, [in] BSTR user_id, [out, retval] struct pEp_identity_s * ident);
   181     HRESULT set_identity([in] struct pEp_identity_s * ident);
   182     HRESULT generate_keypair([in] struct pEp_identity_s * ident, [out, retval] BSTR * fpr);
   183     HRESULT delete_keypair([in] BSTR fpr);
   184     HRESULT import_key([in] BSTR key_data);
   185     HRESULT import_key_b([in] SAFEARRAY(BYTE) key_data);
   186     HRESULT export_key([in] BSTR fpr, [out, retval] BSTR * key_data);
   187     HRESULT recv_key([in] BSTR pattern);
   188     HRESULT find_keys([in] BSTR pattern, [out, retval] SAFEARRAY(BSTR) * key_list);
   189     HRESULT send_key([in] BSTR pattern);
   190 
   191     HRESULT start_keyserver_lookup();
   192     HRESULT stop_keyserver_lookup();
   193 
   194     HRESULT examine_identity([in] struct pEp_identity_s * ident);
   195     HRESULT myself([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
   196     HRESULT update_identity([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
   197     HRESULT key_mistrusted([in] struct pEp_identity_s *ident);
   198     HRESULT key_reset_trust([in] struct pEp_identity_s *ident);
   199     HRESULT trust_personal_key([in] struct pEp_identity_s *ident, [out, retval] struct pEp_identity_s *result);
   200 
   201     // Blacklist API
   202 
   203     HRESULT blacklist_add([in] BSTR fpr);
   204     HRESULT blacklist_delete([in] BSTR fpr);
   205     HRESULT blacklist_is_listed([in] BSTR fpr, [out, retval] VARIANT_BOOL *listed);
   206     HRESULT blacklist_retrieve([out, retval] SAFEARRAY(BSTR) *blacklist);
   207 
   208 	// PGP compatibility functions
   209 	HRESULT OpenPGP_list_keyinfo([in] BSTR search_pattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfo_list);
   210 
   211     // Message API
   212 
   213 	typedef enum _pEp_rating {
   214 		pEp_rating_undefined = 0,
   215 		pEp_rating_cannot_decrypt,
   216 		pEp_rating_have_no_key,
   217 		pEp_rating_unencrypted,
   218 		pEp_rating_unencrypted_for_some,
   219 		pEp_rating_unreliable,
   220 		pEp_rating_reliable,
   221 		pEp_rating_trusted,
   222 		pEp_rating_trusted_and_anonymized,
   223 		pEp_rating_fully_anonymous,
   224 
   225 		pEp_rating_mistrust = -1,
   226 		pEp_rating_b0rken = -2,
   227 		pEp_rating_under_attack = -3
   228 	} pEp_rating;
   229 
   230 	typedef enum _pEp_color {
   231 		pEp_color_no_color = 0,
   232 		pEp_color_yellow,
   233 		pEp_color_green,
   234 		pEp_color_red = -1,
   235 	} pEp_color;
   236 
   237 	typedef [v1_enum] enum pEpEncryptFlags {
   238 		pEpEncryptFlagsNone = 0,
   239 		pEpEncryptFlagForceEncryption = 0x1,
   240 	} pEpEncryptFlags;
   241 
   242 	typedef [v1_enum] enum pEpDecryptFlags {
   243 		pEpDecryptFlagsNone = 0,
   244 		pEpDecryptFlagOwnPrivateKey = 0x1
   245 	} pEpDecryptFlags;
   246 
   247     typedef  enum _pEp_msg_direction {
   248         pEp_dir_incoming = 0,
   249         pEp_dir_outgoing
   250     } pEp_msg_direction;
   251 
   252     typedef  enum _pEp_enc_format {
   253         pEp_enc_none = 0,                       // message is not encrypted
   254         pEp_enc_pieces,                         // inline PGP + PGP extensions
   255         pEp_enc_S_MIME,                         // RFC5751
   256         pEp_enc_PGP_MIME,                       // RFC3156
   257         pEp_enc_pEp                             // pEp encryption format
   258     } pEp_enc_format;
   259 
   260     [uuid(3A8A4F13-3402-4C4C-94AB-598D87869380)] struct StringPair {
   261         BSTR name;
   262         BSTR value;
   263     };
   264 
   265     [uuid(61DA7AD4-192E-4616-8678-B19AEFB45B45)] struct blob {
   266         SAFEARRAY(BYTE) value;
   267         BSTR mime_type;
   268         BSTR filename;
   269     };
   270 
   271     [uuid(D763A8F3-BA23-4229-A037-1BB7BDC3E0C8)] struct text_message {
   272         pEp_msg_direction dir;
   273         BSTR id;
   274         BSTR shortmsg;
   275         BSTR longmsg;
   276         BSTR longmsg_formatted;
   277         SAFEARRAY(struct blob) attachments;
   278         hyper sent;
   279         hyper recv;
   280         struct pEp_identity_s from;
   281         SAFEARRAY(struct pEp_identity_s) to;
   282         struct pEp_identity_s recv_by;
   283         SAFEARRAY(struct pEp_identity_s) cc;
   284         SAFEARRAY(struct pEp_identity_s) bcc;
   285         SAFEARRAY(struct pEp_identity_s) reply_to;
   286         SAFEARRAY(BSTR) references;
   287         SAFEARRAY(BSTR) keywords;
   288         BSTR comments;
   289         SAFEARRAY(struct StringPair) opt_fields;
   290     };
   291 
   292     HRESULT encrypt_message([in] struct text_message *src, [out] struct text_message * dst, [in] SAFEARRAY(BSTR) extra, [in, defaultvalue(pEpEncryptFlagsNone)] pEpEncryptFlags flags);
   293     HRESULT decrypt_message([in] struct text_message *src, [out] struct text_message * dst, [out] SAFEARRAY(BSTR) *keylist, [out] pEpDecryptFlags* flags, [out, retval] pEp_rating *rating);
   294     HRESULT outgoing_message_rating([in] struct text_message *msg, [out, retval] pEp_rating * pVal);
   295     HRESULT identity_rating([in] struct pEp_identity_s * ident, [out, retval] pEp_rating * pVal);
   296 	HRESULT color_from_rating([in] pEp_rating rating, [out, retval] pEp_color* pVal);
   297 
   298 	HRESULT register_callbacks([in] IpEpEngineCallbacks* new_callback);
   299 
   300 	HRESULT unregister_callbacks([in] IpEpEngineCallbacks* obsolete_callback);
   301 };
   302 
   303 [
   304     uuid(3EC2E1A4-40E8-48E4-A7B0-1876D34F9462),
   305     version(1.0),
   306 ]
   307 library pEpCOMServerAdapterLib
   308 {
   309     importlib("stdole2.tlb");
   310     [
   311         uuid(B6BC9B8E-D9E2-4419-A3A4-7B4B58175549)
   312     ]
   313     dispinterface _IpEpEngineEvents
   314     {
   315     properties:
   316     methods:
   317 		// test code - remove before shipping
   318 		// [id(1)] HRESULT TestEvent([in] LONG test,[in] BSTR testtest);
   319 	};
   320     [
   321         uuid(EF1B073D-5058-4E0E-829E-B4D22CA21EA2)
   322     ]
   323     coclass pEpEngine {
   324         [default] interface IpEpEngine;
   325         [default, source] dispinterface _IpEpEngineEvents;
   326     };
   327 };