pEpObjCAdapterFramework/PEPTypes.h
author Dirk Zimmermann <dz@pep.security>
Fri, 01 Mar 2019 16:03:28 +0100
branchIOS-1480
changeset 845 39908620a3f8
parent 844 872af49fe668
permissions -rw-r--r--
IOS-1480 PEPTypes needs foundation.
     1 //
     2 //  PEPTypes.h
     3 //  pEpObjCAdapter
     4 //
     5 //  Created by Dirk Zimmermann on 27.02.19.
     6 //  Copyright © 2019 p≡p. All rights reserved.
     7 //
     8 
     9 #ifndef PEPTypes_h
    10 #define PEPTypes_h
    11 
    12 #import <Foundation/Foundation.h>
    13 
    14 typedef NSDictionary<NSString *, id> PEPDict;
    15 typedef NSMutableDictionary<NSString *, id> PEPMutableDict;
    16 typedef NSArray<NSString *> PEPStringList;
    17 
    18 typedef enum _ObjC_PEP_decrypt_flags {
    19     PEPDecryptFlagOwnPrivateKey = 0x1, // PEP_decrypt_flag_own_private_key = 0x1,
    20     PEPDecryptFlagConsume = 0x2, // PEP_decrypt_flag_consume = 0x2,
    21     PEPDecryptFlagIgnore = 0x4, // PEP_decrypt_flag_ignore = 0x4,
    22     PEPDecryptFlagSrcModified = 0x8, // PEP_decrypt_flag_src_modified = 0x8,
    23     // input flags
    24     PEPDecryptFlagUntrustedServer = 0x100 // PEP_decrypt_flag_untrusted_server = 0x100
    25 } PEPDecryptFlags; // PEP_decrypt_flags;
    26 
    27 typedef enum _ObjC_PEP_enc_format {
    28     PEPEncNone = 0, // PEP_enc_none = 0, // message is not encrypted
    29     PEPEncPieces, // PEP_enc_pieces, // inline PGP + PGP extensions
    30     PEPEncSMIME, // PEP_enc_S_MIME, // RFC5751
    31     PEPEncPGPMIME, // PEP_enc_PGP_MIME, // RFC3156
    32     PEPEncPEP, // PEP_enc_PEP, // pEp encryption format
    33     PEPEncPGPMIMEOutlook1 // PEP_enc_PGP_MIME_Outlook1 // Message B0rken by Outlook type 1
    34 } PEPEncFormat;
    35 
    36 typedef enum _ObjC_PEP_rating {
    37     PEPRatingUndefined = 0,// PEP_rating_undefined = 0,
    38     PEPRatingCannotDecrypt, // PEP_rating_cannot_decrypt,
    39     PEPRatingHaveNoKey, // PEP_rating_have_no_key,
    40     PEPRatingUnencrypted, // PEP_rating_unencrypted,
    41     PEPRatingUnencryptedForSome, // PEP_rating_unencrypted_for_some, // don't use this any more
    42     PEPRatingUnreliable, // PEP_rating_unreliable,
    43     PEPRatingReliable, // PEP_rating_reliable,
    44     PEPRatingTrusted, // PEP_rating_trusted,
    45     PEPRatingTrustedAndAnonymized, // PEP_rating_trusted_and_anonymized,
    46     PEPRatingFullyAnonymous, // PEP_rating_fully_anonymous,
    47 
    48     PEPRatingMistrust = -1, // PEP_rating_mistrust = -1,
    49     PEPRatingB0rken = -2, // PEP_rating_b0rken = -2,
    50     PEPRatingUnderAttack = -3 // PEP_rating_under_attack = -3
    51 } PEPRating;
    52 
    53 typedef enum {
    54     PEPStatusOK                                   = 0, // PEP_STATUS_OK
    55 
    56     PEPInitCannotLoadGPME                      = 0x0110, // PEP_INIT_CANNOT_LOAD_GPGME
    57     PEPInitGPGMEInitFailed                      = 0x0111, // PEP_INIT_GPGME_INIT_FAILED
    58     PEPInitNoGPGHome                            = 0x0112, // PEP_INIT_NO_GPG_HOME
    59     PEPInitNETPGPInitFailed                     = 0x0113, // PEP_INIT_NETPGP_INIT_FAILED
    60     PEPInitCannotDetermineGPGVersion           = 0x0114, // PEP_INIT_CANNOT_DETERMINE_GPG_VERSION
    61     PEPInitUnsupportedGPGVersion                = 0x0115, // PEP_INIT_UNSUPPORTED_GPG_VERSION
    62     PEPInitCannotConfigGPGAgent                = 0x0116, // PEP_INIT_CANNOT_CONFIG_GPG_AGENT
    63 
    64     PEPInitSqlite3WithoutMutex                  = 0x0120, // PEP_INIT_SQLITE3_WITHOUT_MUTEX
    65     PEPInitCannotOpenDB                         = 0x0121, // PEP_INIT_CANNOT_OPEN_DB
    66     PEPInitCannotOpenSystemDB                  = 0x0122, // PEP_INIT_CANNOT_OPEN_SYSTEM_DB
    67     PEPUnknownDBError                            = 0x01ff, // PEP_UNKNOWN_DB_ERROR
    68 
    69     PEPKeyNotFound                               = 0x0201, // PEP_KEY_NOT_FOUND
    70     PEPKeyHasAmbigName                          = 0x0202, // PEP_KEY_HAS_AMBIG_NAME
    71     PEPGetKeyFailed                              = 0x0203, // PEP_GET_KEY_FAILED
    72     PEPCannotExportKey                           = 0x0204, // PEP_CANNOT_EXPORT_KEY
    73     PEPCannotEditKey                             = 0x0205, // PEP_CANNOT_EDIT_KEY
    74     PEPKeyUnsuitable                              = 0x0206, // PEP_KEY_UNSUITABLE
    75     PEPMalformedKeyResetMsg                     = 0x0210, // PEP_MALFORMED_KEY_RESET_MSG
    76     PEPKeyNotReset                               = 0x0211, // PEP_KEY_NOT_RESET
    77 
    78     PEPKeyImported                                = 0x0220, // PEP_KEY_IMPORTED
    79     PEPNoKeyImported                             = 0x0221, // PEP_NO_KEY_IMPORTED
    80     PEPKeyImportStatusUnknown                   = 0x0222, // PEP_KEY_IMPORT_STATUS_UNKNOWN
    81 
    82     PEPCannotFindIdentity                        = 0x0301, // PEP_CANNOT_FIND_IDENTITY
    83     PEPCannotSetPerson                           = 0x0381, // PEP_CANNOT_SET_PERSON
    84     PEPCannotSetPGPKeyPair                      = 0x0382, // PEP_CANNOT_SET_PGP_KEYPAIR
    85     PEPCannotSetIdentity                         = 0x0383, // PEP_CANNOT_SET_IDENTITY
    86     PEPCannotSetTrust                            = 0x0384, // PEP_CANNOT_SET_TRUST
    87     PEPKeyBlacklisted                             = 0x0385, // PEP_KEY_BLACKLISTED
    88     PEPCannotFindPerson                          = 0x0386, // PEP_CANNOT_FIND_PERSON
    89 
    90     PEPCannotFindAlias                           = 0x0391, // PEP_CANNOT_FIND_ALIAS
    91     PEPCannotSetAlias                            = 0x0392, // PEP_CANNOT_SET_ALIAS
    92 
    93     PEPUnencrypted                                 = 0x0400, // PEP_UNENCRYPTED
    94     PEPVerified                                    = 0x0401, // PEP_VERIFIED
    95     PEPDecrypted                                   = 0x0402, // PEP_DECRYPTED
    96     PEPDecryptedAndVerified                      = 0x0403, // PEP_DECRYPTED_AND_VERIFIED
    97     PEPDecryptWrongFormat                        = 0x0404, // PEP_DECRYPT_WRONG_FORMAT
    98     PEPDecryptNoKey                              = 0x0405, // PEP_DECRYPT_NO_KEY
    99     PEPDecryptSignatureDoesNotMatch            = 0x0406, // PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH
   100     PEPVerifyNoKey                               = 0x0407, // PEP_VERIFY_NO_KEY
   101     PEPVerifiedAndTrusted                        = 0x0408, // PEP_VERIFIED_AND_TRUSTED
   102     PEPCannotReencrypt                            = 0x0409, // PEP_CANNOT_REENCRYPT
   103     PEPCannotDecryptUnknown                      = 0x04ff, // PEP_CANNOT_DECRYPT_UNKNOWN
   104 
   105     PEPTrustwordNotFound                         = 0x0501, // PEP_TRUSTWORD_NOT_FOUND
   106     PEPTrustwordsFPRWrongLength                 = 0x0502, // PEP_TRUSTWORDS_FPR_WRONG_LENGTH
   107     PEPTrustwordsDuplicateFPR                    = 0x0503, // PEP_TRUSTWORDS_DUPLICATE_FPR
   108 
   109     PEPCannotCreateKey                           = 0x0601, // PEP_CANNOT_CREATE_KEY
   110     PEPCannotSendKey                             = 0x0602, // PEP_CANNOT_SEND_KEY
   111 
   112     PEPPhraseNotFound                            = 0x0701, // PEP_PHRASE_NOT_FOUND
   113 
   114     PEPSendFunctionNotRegistered                = 0x0801, // PEP_SEND_FUNCTION_NOT_REGISTERED
   115     PEPConstraintsViolated                         = 0x0802, // PEP_CONTRAINTS_VIOLATED
   116     PEPCannotEncode                               = 0x0803, // PEP_CANNOT_ENCODE
   117 
   118     PEPSyncNoNotifyCallback                     = 0x0901, // PEP_SYNC_NO_NOTIFY_CALLBACK
   119     PEPSyncIllegalMessage                        = 0x0902, // PEP_SYNC_ILLEGAL_MESSAGE
   120     PEPSyncNoInjectCallback                     = 0x0903, // PEP_SYNC_NO_INJECT_CALLBACK
   121     PEPSyncNoChannel                             = 0x0904, // PEP_SYNC_NO_CHANNEL
   122     PEPSyncCannotEncrypt                         = 0x0905, // PEP_SYNC_CANNOT_ENCRYPT
   123     PEPSyncNoMessageSendCallback               = 0x0906, // PEP_SYNC_NO_MESSAGE_SEND_CALLBACK
   124 
   125     PEPCannotIncreaseSequence                    = 0x0971, // PEP_CANNOT_INCREASE_SEQUENCE
   126 
   127     PEPStatemachineError                          = 0x0980, // PEP_STATEMACHINE_ERROR
   128     PEPNoTrust                                    = 0x0981, // PEP_NO_TRUST
   129     PEPStatemachineInvalidState                  = 0x0982, // PEP_STATEMACHINE_INVALID_STATE
   130     PEPStatemachineInvalidEvent                  = 0x0983, // PEP_STATEMACHINE_INVALID_EVENT
   131     PEPStatemachineInvalidCondition              = 0x0984, // PEP_STATEMACHINE_INVALID_CONDITION
   132     PEPStatemachineInvalidAction                 = 0x0985, // PEP_STATEMACHINE_INVALID_ACTION
   133     PEPStatemachineInhibitedEvent                = 0x0986, // PEP_STATEMACHINE_INHIBITED_EVENT
   134     PEPStatemachineCannotSend                    = 0x0987, // PEP_STATEMACHINE_CANNOT_SEND
   135 
   136     PEPCommitFailed                               = 0xff01, // PEP_COMMIT_FAILED
   137     PEPMessageConsume                             = 0xff02, // PEP_MESSAGE_CONSUME
   138     PEPMessageIgnore                              = 0xff03, // PEP_MESSAGE_IGNORE
   139 
   140     PEPRecordNotFound                            = -6, // PEP_RECORD_NOT_FOUND
   141     PEPCannotCreateTempFile                     = -5, // PEP_CANNOT_CREATE_TEMP_FILE
   142     PEPIllegalValue                               = -4, // PEP_ILLEGAL_VALUE
   143     PEPBufferTooSmall                            = -3, // PEP_BUFFER_TOO_SMALL
   144     PEPOutOfMemory                               = -2, // PEP_OUT_OF_MEMORY
   145     PEPUnknownError                               = -1, // PEP_UNKNOWN_ERROR
   146 
   147     PEPVersionMismatch                            = -7, // PEP_VERSION_MISMATCH
   148 } PEPStatus;
   149 
   150 typedef enum _ObjC_identity_flags {
   151     // the first octet flags are app defined settings
   152     PEPIdfNotForSync = 0x0001, // PEP_idf_not_for_sync = 0x0001,   // don't use this identity for sync
   153     PEPIdfList = 0x0002, // PEP_idf_list = 0x0002,           // identity of list of persons
   154     // the second octet flags are calculated
   155     PEPIdfDeviceGroup = 0x0100 // PEP_idf_devicegroup = 0x0100     // identity of a device group member
   156 } PEPIdentityFlags;
   157 
   158 typedef enum _ObjC_sync_handshake_result {
   159     PEPSyncHandshakeResultCancel = -1, // SYNC_HANDSHAKE_CANCEL = -1,
   160     PEPSyncHandshakeResultAccepted = 0, // SYNC_HANDSHAKE_ACCEPTED = 0,
   161     PEPSyncHandshakeResultRejected = 1 // SYNC_HANDSHAKE_REJECTED = 1
   162 } PEPSyncHandshakeResult;
   163 
   164 typedef enum _PEPCommType {
   165     PEPCtUnknown = 0, // PEP_ct_unknown = 0,
   166 
   167     // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
   168 
   169     PEPCtNoEncryption = 0x01, // PEP_ct_no_encryption = 0x01,                // generic
   170     PEPCtNoEncrypted_channel = 0x02, // PEP_ct_no_encrypted_channel = 0x02,
   171     PEPCtKeyNotFound = 0x03, // PEP_ct_key_not_found = 0x03,
   172     PEPCtKeyExpired = 0x04, // PEP_ct_key_expired = 0x04,
   173     PEPCtKeyRevoked = 0x05, // PEP_ct_key_revoked = 0x05,
   174     PEPCtKeyBr0ken = 0x06, // PEP_ct_key_b0rken = 0x06,
   175     PEPCtKeyExpiredButConfirmed = 0x07, // PEP_ct_key_expired_but_confirmed = 0x07, // NOT with confirmed bit. Just retaining info here in case of renewal.
   176     PEPCtMyKeyNotIncluded = 0x09, // PEP_ct_my_key_not_included = 0x09,
   177 
   178     PEPCtSecurityByObscurity = 0x0a, // PEP_ct_security_by_obscurity = 0x0a,
   179     PEPCtBr0kenCrypto = 0x0b, // PEP_ct_b0rken_crypto = 0x0b,
   180     PEPCtKeyTooShort = 0x0c, // PEP_ct_key_too_short = 0x0c,
   181 
   182     PEPCtCompromised = 0x0e, // PEP_ct_compromized = 0x0e,                  // deprecated misspelling
   183     PEPCtMistrusted = 0x0f, // PEP_ct_mistrusted = 0x0f,                   // known mistrusted key
   184 
   185     // range 0x10 to 0x3f: unconfirmed encryption
   186 
   187     PEPCtUnconfirmedEncryption = 0x10, // PEP_ct_unconfirmed_encryption = 0x10,       // generic
   188     PEPCtOpenPGPWeakUnconfirmed = 0x11, // PEP_ct_OpenPGP_weak_unconfirmed = 0x11,     // RSA 1024 is weak
   189 
   190     PEPCtToBeChecked = 0x20, // PEP_ct_to_be_checked = 0x20,                // generic
   191     PEPCtSMIMEUnconfirmed = 0x21, // PEP_ct_SMIME_unconfirmed = 0x21,
   192     PEPCtCMSUnconfirmed = 0x22, // PEP_ct_CMS_unconfirmed = 0x22,
   193 
   194     PEPCtStongButUnconfirmed = 0x30, // PEP_ct_strong_but_unconfirmed = 0x30,       // generic
   195     PEPCtOpenPGPUnconfirmed = 0x38, // PEP_ct_OpenPGP_unconfirmed = 0x38,          // key at least 2048 bit RSA or EC
   196     PEPCtOTRUnconfirmed = 0x3a, // PEP_ct_OTR_unconfirmed = 0x3a,
   197 
   198     // range 0x40 to 0x7f: unconfirmed encryption and anonymization
   199 
   200     PEPCtUnconfirmedEncAnon = 0x40, // PEP_ct_unconfirmed_enc_anon = 0x40,         // generic
   201     PEPCtPEPUnconfirmed = 0x7f, // PEP_ct_pEp_unconfirmed = 0x7f,
   202 
   203     PEPCtConfirmed = 0x80, // PEP_ct_confirmed = 0x80,                    // this bit decides if trust is confirmed
   204 
   205     // range 0x81 to 0x8f: reserved
   206     // range 0x90 to 0xbf: confirmed encryption
   207 
   208     PEPCtConfirmedEncryption = 0x90, // PEP_ct_confirmed_encryption = 0x90,         // generic
   209     PEPCtOpenPGPWeak = 0x91, // PEP_ct_OpenPGP_weak = 0x91,                 // RSA 1024 is weak (unused)
   210 
   211     PEPCtToBeCheckedConfirmed = 0xa0, // PEP_ct_to_be_checked_confirmed = 0xa0,      // generic
   212     PEPCtSMIME = 0xa1, // PEP_ct_SMIME = 0xa1,
   213     PEPCtCMS = 0xa2, // PEP_ct_CMS = 0xa2,
   214 
   215     PEPCtStongEncryption = 0xb0, // PEP_ct_strong_encryption = 0xb0,            // generic
   216     PEPCtOpenPGP = 0xb8, // PEP_ct_OpenPGP = 0xb8,                      // key at least 2048 bit RSA or EC
   217     PEPCtOTR = 0xba, // PEP_ct_OTR = 0xba,
   218 
   219     // range 0xc0 to 0xff: confirmed encryption and anonymization
   220 
   221     PEPCtConfirmedEncAnon = 0xc0, // PEP_ct_confirmed_enc_anon = 0xc0,           // generic
   222     PEPCtPEP = 0xff // PEP_ct_pEp = 0xff
   223 } PEPCommType;
   224 
   225 typedef enum _ObjC_PEP_msg_direction {
   226     PEPDirIncoming = 0,
   227     PEPDirOutgoing
   228 } PEPMsgDirection;
   229 
   230 #endif /* PEPTypes_h */