1 /* 2 * Copyright (c) 2017-2020, [Ribose Inc](https://www.ribose.com). 3 * All rights reserved. 4 * 5 * This code is originally derived from software contributed to 6 * The NetBSD Foundation by Alistair Crooks (agc@netbsd.org), and 7 * carried further by Ribose Inc (https://www.ribose.com). 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef REPGP_DEF_H_ 32 #define REPGP_DEF_H_ 33 34 /************************************/ 35 /* Packet Tags - RFC4880, 4.2 */ 36 /************************************/ 37 38 /** Packet Tag - Bit 7 Mask (this bit is always set). 39 * The first byte of a packet is the "Packet Tag". It always 40 * has bit 7 set. This is the mask for it. 41 * 42 * \see RFC4880 4.2 43 */ 44 #define PGP_PTAG_ALWAYS_SET 0x80 45 46 /** Packet Tag - New Format Flag. 47 * Bit 6 of the Packet Tag is the packet format indicator. 48 * If it is set, the new format is used, if cleared the 49 * old format is used. 50 * 51 * \see RFC4880 4.2 52 */ 53 #define PGP_PTAG_NEW_FORMAT 0x40 54 55 /** Old Packet Format: Mask for content tag. 56 * In the old packet format bits 5 to 2 (including) 57 * are the content tag. This is the mask to apply 58 * to the packet tag. Note that you need to 59 * shift by #PGP_PTAG_OF_CONTENT_TAG_SHIFT bits. 60 * 61 * \see RFC4880 4.2 62 */ 63 #define PGP_PTAG_OF_CONTENT_TAG_MASK 0x3c 64 /** Old Packet Format: Offset for the content tag. 65 * As described at #PGP_PTAG_OF_CONTENT_TAG_MASK the 66 * content tag needs to be shifted after being masked 67 * out from the Packet Tag. 68 * 69 * \see RFC4880 4.2 70 */ 71 #define PGP_PTAG_OF_CONTENT_TAG_SHIFT 2 72 /** Old Packet Format: Mask for length type. 73 * Bits 1 and 0 of the packet tag are the length type 74 * in the old packet format. 75 * 76 * See #pgp_ptag_of_lt_t for the meaning of the values. 77 * 78 * \see RFC4880 4.2 79 */ 80 #define PGP_PTAG_OF_LENGTH_TYPE_MASK 0x03 81 82 /* Maximum block size for symmetric crypto */ 83 #define PGP_MAX_BLOCK_SIZE 16 84 85 /* Maximum key size for symmetric crypto */ 86 #define PGP_MAX_KEY_SIZE 32 87 88 /* Salt size for hashing */ 89 #define PGP_SALT_SIZE 8 90 91 /* Size of the keyid */ 92 #define PGP_KEY_ID_SIZE 8 93 94 /* Size of the fingerprint */ 95 #define PGP_FINGERPRINT_SIZE 20 96 #define PGP_FINGERPRINT_HEX_SIZE (PGP_FINGERPRINT_SIZE * 3) + 1 97 98 /* Size of the key grip */ 99 #define PGP_KEY_GRIP_SIZE 20 100 101 /* PGP marker packet contents */ 102 #define PGP_MARKER_CONTENTS "PGP" 103 #define PGP_MARKER_LEN 3 104 105 /** Old Packet Format Lengths. 106 * Defines the meanings of the 2 bits for length type in the 107 * old packet format. 108 * 109 * \see RFC4880 4.2.1 110 */ 111 typedef enum { 112 PGP_PTAG_OLD_LEN_1 = 0x00, /* Packet has a 1 byte length - 113 * header is 2 bytes long. */ 114 PGP_PTAG_OLD_LEN_2 = 0x01, /* Packet has a 2 byte length - 115 * header is 3 bytes long. */ 116 PGP_PTAG_OLD_LEN_4 = 0x02, /* Packet has a 4 byte 117 * length - header is 5 bytes 118 * long. */ 119 PGP_PTAG_OLD_LEN_INDETERMINATE = 0x03 /* Packet has a 120 * indeterminate length. */ 121 } pgp_ptag_of_lt_t; 122 123 /** New Packet Format: Mask for content tag. 124 * In the new packet format the 6 rightmost bits 125 * are the content tag. This is the mask to apply 126 * to the packet tag. Note that you need to 127 * shift by #PGP_PTAG_NF_CONTENT_TAG_SHIFT bits. 128 * 129 * \see RFC4880 4.2 130 */ 131 #define PGP_PTAG_NF_CONTENT_TAG_MASK 0x3f 132 /** New Packet Format: Offset for the content tag. 133 * As described at #PGP_PTAG_NF_CONTENT_TAG_MASK the 134 * content tag needs to be shifted after being masked 135 * out from the Packet Tag. 136 * 137 * \see RFC4880 4.2 138 */ 139 #define PGP_PTAG_NF_CONTENT_TAG_SHIFT 0 140 141 #define MDC_PKT_TAG 0xd3 142 #define MDC_V1_SIZE 22 143 144 typedef enum : uint8_t { 145 PGP_REVOCATION_NO_REASON = 0, 146 PGP_REVOCATION_SUPERSEDED = 1, 147 PGP_REVOCATION_COMPROMISED = 2, 148 PGP_REVOCATION_RETIRED = 3, 149 PGP_REVOCATION_NO_LONGER_VALID = 0x20 150 } pgp_revocation_type_t; 151 152 /** 153 * @brief OpenPGP packet tags. See section 4.3 of RFC4880 for the detailed description. 154 * 155 */ 156 typedef enum : uint8_t { 157 PGP_PKT_RESERVED = 0, /* Reserved - a packet tag must not have this value */ 158 PGP_PKT_PK_SESSION_KEY = 1, /* Public-Key Encrypted Session Key Packet */ 159 PGP_PKT_SIGNATURE = 2, /* Signature Packet */ 160 PGP_PKT_SK_SESSION_KEY = 3, /* Symmetric-Key Encrypted Session Key Packet */ 161 PGP_PKT_ONE_PASS_SIG = 4, /* One-Pass Signature Packet */ 162 PGP_PKT_SECRET_KEY = 5, /* Secret Key Packet */ 163 PGP_PKT_PUBLIC_KEY = 6, /* Public Key Packet */ 164 PGP_PKT_SECRET_SUBKEY = 7, /* Secret Subkey Packet */ 165 PGP_PKT_COMPRESSED = 8, /* Compressed Data Packet */ 166 PGP_PKT_SE_DATA = 9, /* Symmetrically Encrypted Data Packet */ 167 PGP_PKT_MARKER = 10, /* Marker Packet */ 168 PGP_PKT_LITDATA = 11, /* Literal Data Packet */ 169 PGP_PKT_TRUST = 12, /* Trust Packet */ 170 PGP_PKT_USER_ID = 13, /* User ID Packet */ 171 PGP_PKT_PUBLIC_SUBKEY = 14, /* Public Subkey Packet */ 172 PGP_PKT_RESERVED2 = 15, /* Reserved */ 173 PGP_PKT_RESERVED3 = 16, /* Reserved */ 174 PGP_PKT_USER_ATTR = 17, /* User Attribute Packet */ 175 PGP_PKT_SE_IP_DATA = 18, /* Sym. Encrypted and Integrity Protected Data Packet */ 176 PGP_PKT_MDC = 19, /* Modification Detection Code Packet */ 177 PGP_PKT_AEAD_ENCRYPTED = 20 /* AEAD Encrypted Data Packet, RFC 4880bis */ 178 } pgp_pkt_type_t; 179 180 /** Public Key Algorithm Numbers. 181 * OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP. 182 * 183 * This lists algorithm numbers for public key algorithms. 184 * 185 * \see RFC4880 9.1 186 */ 187 typedef enum : uint8_t { 188 PGP_PKA_NOTHING = 0, /* No PKA */ 189 PGP_PKA_RSA = 1, /* RSA (Encrypt or Sign) */ 190 PGP_PKA_RSA_ENCRYPT_ONLY = 2, /* RSA Encrypt-Only (deprecated - 191 * \see RFC4880 13.5) */ 192 PGP_PKA_RSA_SIGN_ONLY = 3, /* RSA Sign-Only (deprecated - 193 * \see RFC4880 13.5) */ 194 PGP_PKA_ELGAMAL = 16, /* Elgamal (Encrypt-Only) */ 195 PGP_PKA_DSA = 17, /* DSA (Digital Signature Algorithm) */ 196 PGP_PKA_ECDH = 18, /* ECDH public key algorithm */ 197 PGP_PKA_ECDSA = 19, /* ECDSA public key algorithm [FIPS186-3] */ 198 PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN = 20, /* Elgamal Encrypt or Sign. Implementation MUST not 199 generate such keys and elgamal signatures. */ 200 PGP_PKA_RESERVED_DH = 21, /* Reserved for Diffie-Hellman 201 * (X9.42, as defined for 202 * IETF-S/MIME) */ 203 PGP_PKA_EDDSA = 22, /* EdDSA from draft-ietf-openpgp-rfc4880bis */ 204 PGP_PKA_SM2 = 99, /* SM2 encryption/signature schemes */ 205 206 PGP_PKA_PRIVATE00 = 100, /* Private/Experimental Algorithm */ 207 PGP_PKA_PRIVATE01 = 101, /* Private/Experimental Algorithm */ 208 PGP_PKA_PRIVATE02 = 102, /* Private/Experimental Algorithm */ 209 PGP_PKA_PRIVATE03 = 103, /* Private/Experimental Algorithm */ 210 PGP_PKA_PRIVATE04 = 104, /* Private/Experimental Algorithm */ 211 PGP_PKA_PRIVATE05 = 105, /* Private/Experimental Algorithm */ 212 PGP_PKA_PRIVATE06 = 106, /* Private/Experimental Algorithm */ 213 PGP_PKA_PRIVATE07 = 107, /* Private/Experimental Algorithm */ 214 PGP_PKA_PRIVATE08 = 108, /* Private/Experimental Algorithm */ 215 PGP_PKA_PRIVATE09 = 109, /* Private/Experimental Algorithm */ 216 PGP_PKA_PRIVATE10 = 110 /* Private/Experimental Algorithm */ 217 } pgp_pubkey_alg_t; 218 219 /** 220 * Enumeration of elliptic curves used by PGP. 221 * 222 * \see RFC4880-bis01 9.2. ECC Curve OID 223 * 224 * Values in this enum correspond to order in ec_curve array (in ec.c) 225 */ 226 typedef enum { 227 PGP_CURVE_UNKNOWN = 0, 228 PGP_CURVE_NIST_P_256, 229 PGP_CURVE_NIST_P_384, 230 PGP_CURVE_NIST_P_521, 231 PGP_CURVE_ED25519, 232 PGP_CURVE_25519, 233 PGP_CURVE_BP256, 234 PGP_CURVE_BP384, 235 PGP_CURVE_BP512, 236 PGP_CURVE_P256K1, 237 238 PGP_CURVE_SM2_P_256, 239 240 // Keep always last one 241 PGP_CURVE_MAX 242 } pgp_curve_t; 243 244 /** Symmetric Key Algorithm Numbers. 245 * OpenPGP assigns a unique Algorithm Number to each algorithm that is 246 * part of OpenPGP. 247 * 248 * This lists algorithm numbers for symmetric key algorithms. 249 * 250 * \see RFC4880 9.2 251 */ 252 typedef enum { 253 PGP_SA_PLAINTEXT = 0, /* Plaintext or unencrypted data */ 254 PGP_SA_IDEA = 1, /* IDEA */ 255 PGP_SA_TRIPLEDES = 2, /* TripleDES */ 256 PGP_SA_CAST5 = 3, /* CAST5 */ 257 PGP_SA_BLOWFISH = 4, /* Blowfish */ 258 PGP_SA_AES_128 = 7, /* AES with 128-bit key (AES) */ 259 PGP_SA_AES_192 = 8, /* AES with 192-bit key */ 260 PGP_SA_AES_256 = 9, /* AES with 256-bit key */ 261 PGP_SA_TWOFISH = 10, /* Twofish with 256-bit key (TWOFISH) */ 262 PGP_SA_CAMELLIA_128 = 11, /* Camellia with 128-bit key (CAMELLIA) */ 263 PGP_SA_CAMELLIA_192 = 12, /* Camellia with 192-bit key */ 264 PGP_SA_CAMELLIA_256 = 13, /* Camellia with 256-bit key */ 265 266 PGP_SA_SM4 = 105, /* RNP extension - SM4 */ 267 PGP_SA_UNKNOWN = 255 268 } pgp_symm_alg_t; 269 270 typedef enum { 271 PGP_CIPHER_MODE_NONE = 0, 272 PGP_CIPHER_MODE_CFB = 1, 273 PGP_CIPHER_MODE_CBC = 2, 274 PGP_CIPHER_MODE_OCB = 3, 275 } pgp_cipher_mode_t; 276 277 typedef enum { 278 PGP_AEAD_NONE = 0, 279 PGP_AEAD_EAX = 1, 280 PGP_AEAD_OCB = 2, 281 PGP_AEAD_UNKNOWN = 255 282 } pgp_aead_alg_t; 283 284 /** s2k_usage_t 285 */ 286 typedef enum { 287 PGP_S2KU_NONE = 0, 288 PGP_S2KU_ENCRYPTED_AND_HASHED = 254, 289 PGP_S2KU_ENCRYPTED = 255 290 } pgp_s2k_usage_t; 291 292 /** s2k_specifier_t 293 */ 294 typedef enum : uint8_t { 295 PGP_S2KS_SIMPLE = 0, 296 PGP_S2KS_SALTED = 1, 297 PGP_S2KS_ITERATED_AND_SALTED = 3, 298 PGP_S2KS_EXPERIMENTAL = 101 299 } pgp_s2k_specifier_t; 300 301 typedef enum { 302 PGP_S2K_GPG_NONE = 0, 303 PGP_S2K_GPG_NO_SECRET = 1, 304 PGP_S2K_GPG_SMARTCARD = 2 305 } pgp_s2k_gpg_extension_t; 306 307 /** Signature Type. 308 * OpenPGP defines different signature types that allow giving 309 * different meanings to signatures. Signature types include 0x10 for 310 * generitc User ID certifications (used when Ben signs Weasel's key), 311 * Subkey binding signatures, document signatures, key revocations, 312 * etc. 313 * 314 * Different types are used in different places, and most make only 315 * sense in their intended location (for instance a subkey binding has 316 * no place on a UserID). 317 * 318 * \see RFC4880 5.2.1 319 */ 320 typedef enum : uint8_t { 321 PGP_SIG_BINARY = 0x00, /* Signature of a binary document */ 322 PGP_SIG_TEXT = 0x01, /* Signature of a canonical text document */ 323 PGP_SIG_STANDALONE = 0x02, /* Standalone signature */ 324 325 PGP_CERT_GENERIC = 0x10, /* Generic certification of a User ID and 326 * Public Key packet */ 327 PGP_CERT_PERSONA = 0x11, /* Persona certification of a User ID and 328 * Public Key packet */ 329 PGP_CERT_CASUAL = 0x12, /* Casual certification of a User ID and 330 * Public Key packet */ 331 PGP_CERT_POSITIVE = 0x13, /* Positive certification of a 332 * User ID and Public Key packet */ 333 334 PGP_SIG_SUBKEY = 0x18, /* Subkey Binding Signature */ 335 PGP_SIG_PRIMARY = 0x19, /* Primary Key Binding Signature */ 336 PGP_SIG_DIRECT = 0x1f, /* Signature directly on a key */ 337 338 PGP_SIG_REV_KEY = 0x20, /* Key revocation signature */ 339 PGP_SIG_REV_SUBKEY = 0x28, /* Subkey revocation signature */ 340 PGP_SIG_REV_CERT = 0x30, /* Certification revocation signature */ 341 342 PGP_SIG_TIMESTAMP = 0x40, /* Timestamp signature */ 343 344 PGP_SIG_3RD_PARTY = 0x50 /* Third-Party Confirmation signature */ 345 } pgp_sig_type_t; 346 347 /** Signature Subpacket Type 348 * Signature subpackets contains additional information about the signature 349 * 350 * \see RFC4880 5.2.3.1-5.2.3.26 351 */ 352 353 typedef enum { 354 PGP_SIG_SUBPKT_UNKNOWN = 0, 355 PGP_SIG_SUBPKT_RESERVED_1 = 1, 356 PGP_SIG_SUBPKT_CREATION_TIME = 2, /* signature creation time */ 357 PGP_SIG_SUBPKT_EXPIRATION_TIME = 3, /* signature expiration time */ 358 PGP_SIG_SUBPKT_EXPORT_CERT = 4, /* exportable certification */ 359 PGP_SIG_SUBPKT_TRUST = 5, /* trust signature */ 360 PGP_SIG_SUBPKT_REGEXP = 6, /* regular expression */ 361 PGP_SIG_SUBPKT_REVOCABLE = 7, /* revocable */ 362 PGP_SIG_SUBPKT_RESERVED_8 = 8, 363 PGP_SIG_SUBPKT_KEY_EXPIRY = 9, /* key expiration time */ 364 PGP_SIG_SUBPKT_PLACEHOLDER = 10, /* placeholder for backward compatibility */ 365 PGP_SIG_SUBPKT_PREFERRED_SKA = 11, /* preferred symmetric algs */ 366 PGP_SIG_SUBPKT_REVOCATION_KEY = 12, /* revocation key */ 367 PGP_SIG_SUBPKT_RESERVED_13 = 13, 368 PGP_SIG_SUBPKT_RESERVED_14 = 14, 369 PGP_SIG_SUBPKT_RESERVED_15 = 15, 370 PGP_SIG_SUBPKT_ISSUER_KEY_ID = 16, /* issuer key ID */ 371 PGP_SIG_SUBPKT_RESERVED_17 = 17, 372 PGP_SIG_SUBPKT_RESERVED_18 = 18, 373 PGP_SIG_SUBPKT_RESERVED_19 = 19, 374 PGP_SIG_SUBPKT_NOTATION_DATA = 20, /* notation data */ 375 PGP_SIG_SUBPKT_PREFERRED_HASH = 21, /* preferred hash algs */ 376 PGP_SIG_SUBPKT_PREF_COMPRESS = 22, /* preferred compression algorithms */ 377 PGP_SIG_SUBPKT_KEYSERV_PREFS = 23, /* key server preferences */ 378 PGP_SIG_SUBPKT_PREF_KEYSERV = 24, /* preferred key Server */ 379 PGP_SIG_SUBPKT_PRIMARY_USER_ID = 25, /* primary user ID */ 380 PGP_SIG_SUBPKT_POLICY_URI = 26, /* policy URI */ 381 PGP_SIG_SUBPKT_KEY_FLAGS = 27, /* key flags */ 382 PGP_SIG_SUBPKT_SIGNERS_USER_ID = 28, /* signer's user ID */ 383 PGP_SIG_SUBPKT_REVOCATION_REASON = 29, /* reason for revocation */ 384 PGP_SIG_SUBPKT_FEATURES = 30, /* features */ 385 PGP_SIG_SUBPKT_SIGNATURE_TARGET = 31, /* signature target */ 386 PGP_SIG_SUBPKT_EMBEDDED_SIGNATURE = 32, /* embedded signature */ 387 PGP_SIG_SUBPKT_ISSUER_FPR = 33, /* issuer fingerprint */ 388 PGP_SIG_SUBPKT_PREFERRED_AEAD = 34, /* preferred AEAD algorithms */ 389 PGP_SIG_SUBPKT_PRIVATE_100 = 100, /* private/experimental subpackets */ 390 PGP_SIG_SUBPKT_PRIVATE_101 = 101, 391 PGP_SIG_SUBPKT_PRIVATE_102 = 102, 392 PGP_SIG_SUBPKT_PRIVATE_103 = 103, 393 PGP_SIG_SUBPKT_PRIVATE_104 = 104, 394 PGP_SIG_SUBPKT_PRIVATE_105 = 105, 395 PGP_SIG_SUBPKT_PRIVATE_106 = 106, 396 PGP_SIG_SUBPKT_PRIVATE_107 = 107, 397 PGP_SIG_SUBPKT_PRIVATE_108 = 108, 398 PGP_SIG_SUBPKT_PRIVATE_109 = 109, 399 PGP_SIG_SUBPKT_PRIVATE_110 = 110 400 } pgp_sig_subpacket_type_t; 401 402 /** Key Flags 403 * 404 * \see RFC4880 5.2.3.21 405 */ 406 typedef enum { 407 PGP_KF_CERTIFY = 0x01, /* This key may be used to certify other keys. */ 408 PGP_KF_SIGN = 0x02, /* This key may be used to sign data. */ 409 PGP_KF_ENCRYPT_COMMS = 0x04, /* This key may be used to encrypt communications. */ 410 PGP_KF_ENCRYPT_STORAGE = 0x08, /* This key may be used to encrypt storage. */ 411 PGP_KF_SPLIT = 0x10, /* The private component of this key may have been split 412 by a secret-sharing mechanism. */ 413 PGP_KF_AUTH = 0x20, /* This key may be used for authentication. */ 414 PGP_KF_SHARED = 0x80, /* The private component of this key may be in the 415 possession of more than one person. */ 416 /* pseudo flags */ 417 PGP_KF_NONE = 0x00, 418 PGP_KF_ENCRYPT = PGP_KF_ENCRYPT_COMMS | PGP_KF_ENCRYPT_STORAGE, 419 } pgp_key_flags_t; 420 421 typedef enum { 422 PGP_KEY_FEATURE_MDC = 0x01, 423 PGP_KEY_FEATURE_AEAD = 0x02, 424 PGP_KEY_FEATURE_V5 = 0x04 425 } pgp_key_feature_t; 426 427 /** Types of Compression */ 428 typedef enum { 429 PGP_C_NONE = 0, 430 PGP_C_ZIP = 1, 431 PGP_C_ZLIB = 2, 432 PGP_C_BZIP2 = 3, 433 PGP_C_UNKNOWN = 255 434 } pgp_compression_type_t; 435 436 enum { PGP_SE_IP_DATA_VERSION = 1, PGP_PKSK_V3 = 3, PGP_SKSK_V4 = 4, PGP_SKSK_V5 = 5 }; 437 438 /** Version. 439 * OpenPGP has two different protocol versions: version 3 and version 4. 440 * 441 * \see RFC4880 5.2 442 */ 443 typedef enum { 444 PGP_VUNKNOWN = 0, 445 PGP_V2 = 2, /* Version 2 (essentially the same as v3) */ 446 PGP_V3 = 3, /* Version 3 */ 447 PGP_V4 = 4 /* Version 4 */ 448 } pgp_version_t; 449 450 typedef enum pgp_op_t { 451 PGP_OP_UNKNOWN = 0, 452 PGP_OP_ADD_SUBKEY = 1, /* adding a subkey, primary key password required */ 453 PGP_OP_SIGN = 2, /* signing file or data */ 454 PGP_OP_DECRYPT = 3, /* decrypting file or data */ 455 PGP_OP_UNLOCK = 4, /* unlocking a key with key->unlock() */ 456 PGP_OP_PROTECT = 5, /* adding protection to a key */ 457 PGP_OP_UNPROTECT = 6, /* removing protection from a (locked) key */ 458 PGP_OP_DECRYPT_SYM = 7, /* symmetric decryption */ 459 PGP_OP_ENCRYPT_SYM = 8, /* symmetric encryption */ 460 PGP_OP_VERIFY = 9, /* signature verification */ 461 PGP_OP_ADD_USERID = 10, /* adding a userid */ 462 PGP_OP_MERGE_INFO = 11, /* merging information from one key to another */ 463 PGP_OP_ENCRYPT = 12 /* public-key encryption */ 464 } pgp_op_t; 465 466 /** Hashing Algorithm Numbers. 467 * OpenPGP assigns a unique Algorithm Number to each algorithm that is 468 * part of OpenPGP. 469 * 470 * This lists algorithm numbers for hash algorithms. 471 * 472 * \see RFC4880 9.4 473 */ 474 typedef enum : uint8_t { 475 PGP_HASH_UNKNOWN = 0, /* used to indicate errors */ 476 PGP_HASH_MD5 = 1, 477 PGP_HASH_SHA1 = 2, 478 PGP_HASH_RIPEMD = 3, 479 480 PGP_HASH_SHA256 = 8, 481 PGP_HASH_SHA384 = 9, 482 PGP_HASH_SHA512 = 10, 483 PGP_HASH_SHA224 = 11, 484 PGP_HASH_SHA3_256 = 12, 485 PGP_HASH_SHA3_512 = 14, 486 487 /* Private range */ 488 PGP_HASH_SM3 = 105, 489 } pgp_hash_alg_t; 490 491 typedef enum pgp_key_store_format_t { 492 PGP_KEY_STORE_UNKNOWN = 0, 493 PGP_KEY_STORE_GPG, 494 PGP_KEY_STORE_KBX, 495 PGP_KEY_STORE_G10, 496 } pgp_key_store_format_t; 497 498 #endif 499