| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
#ifndef OPS_PACKET_H |
|---|
| 6 |
#define OPS_PACKET_H |
|---|
| 7 |
|
|---|
| 8 |
#include "configure.h" |
|---|
| 9 |
|
|---|
| 10 |
#include <time.h> |
|---|
| 11 |
#include <openssl/bn.h> |
|---|
| 12 |
#include "types.h" |
|---|
| 13 |
#include "errors.h" |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
typedef struct |
|---|
| 19 |
{ |
|---|
| 20 |
size_t len; |
|---|
| 21 |
unsigned char *contents; |
|---|
| 22 |
} ops_data_t; |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
#define OPS_PTAG_ALWAYS_SET 0x80 |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
#define OPS_PTAG_NEW_FORMAT 0x40 |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
#define OPS_PTAG_OF_CONTENT_TAG_MASK 0x3c |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
#define OPS_PTAG_OF_CONTENT_TAG_SHIFT 2 |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
#define OPS_PTAG_OF_LENGTH_TYPE_MASK 0x03 |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
typedef enum |
|---|
| 81 |
{ |
|---|
| 82 |
OPS_PTAG_OF_LT_ONE_BYTE =0x00, |
|---|
| 83 |
OPS_PTAG_OF_LT_TWO_BYTE =0x01, |
|---|
| 84 |
OPS_PTAG_OF_LT_FOUR_BYTE =0x02, |
|---|
| 85 |
OPS_PTAG_OF_LT_INDETERMINATE =0x03 |
|---|
| 86 |
} ops_ptag_of_lt_t; |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
#define OPS_PTAG_NF_CONTENT_TAG_MASK 0x3f |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
#define OPS_PTAG_NF_CONTENT_TAG_SHIFT 0 |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
enum ops_content_tag_t |
|---|
| 120 |
{ |
|---|
| 121 |
OPS_PTAG_CT_RESERVED = 0, |
|---|
| 122 |
OPS_PTAG_CT_PK_SESSION_KEY = 1, |
|---|
| 123 |
OPS_PTAG_CT_SIGNATURE = 2, |
|---|
| 124 |
OPS_PTAG_CT_SK_SESSION_KEY = 3, |
|---|
| 125 |
OPS_PTAG_CT_ONE_PASS_SIGNATURE = 4, |
|---|
| 126 |
OPS_PTAG_CT_SECRET_KEY = 5, |
|---|
| 127 |
OPS_PTAG_CT_PUBLIC_KEY = 6, |
|---|
| 128 |
OPS_PTAG_CT_SECRET_SUBKEY = 7, |
|---|
| 129 |
OPS_PTAG_CT_COMPRESSED = 8, |
|---|
| 130 |
OPS_PTAG_CT_SK_DATA = 9, |
|---|
| 131 |
OPS_PTAG_CT_MARKER =10, |
|---|
| 132 |
OPS_PTAG_CT_LITERAL_DATA =11, |
|---|
| 133 |
OPS_PTAG_CT_TRUST =12, |
|---|
| 134 |
OPS_PTAG_CT_USER_ID =13, |
|---|
| 135 |
OPS_PTAG_CT_PUBLIC_SUBKEY =14, |
|---|
| 136 |
OPS_PTAG_CT_RESERVED2 =15, |
|---|
| 137 |
OPS_PTAG_CT_RESERVED3 =16, |
|---|
| 138 |
OPS_PTAG_CT_USER_ATTRIBUTE =17, |
|---|
| 139 |
OPS_PTAG_CT_SK_IP_DATA =18, |
|---|
| 140 |
OPS_PTAG_CT_MDC =19, |
|---|
| 141 |
|
|---|
| 142 |
OPS_PARSER_ERROR =0x100, |
|---|
| 143 |
OPS_PARSER_PTAG =0x101, |
|---|
| 144 |
|
|---|
| 145 |
OPS_PTAG_RAW_SS =0x102, |
|---|
| 146 |
OPS_PTAG_SS_ALL =0x103, |
|---|
| 147 |
OPS_PARSER_PACKET_END =0x104, |
|---|
| 148 |
OPS_PARSER_ERRCODE =0x105, |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
OPS_PTAG_SIGNATURE_SUBPACKET_BASE =0x200, |
|---|
| 153 |
|
|---|
| 154 |
OPS_PTAG_SS_CREATION_TIME =0x200+2, |
|---|
| 155 |
OPS_PTAG_SS_EXPIRATION_TIME =0x200+3, |
|---|
| 156 |
|
|---|
| 157 |
OPS_PTAG_SS_TRUST =0x200+5, |
|---|
| 158 |
OPS_PTAG_SS_REGEXP =0x200+6, |
|---|
| 159 |
OPS_PTAG_SS_REVOCABLE =0x200+7, |
|---|
| 160 |
OPS_PTAG_SS_KEY_EXPIRATION_TIME =0x200+9, |
|---|
| 161 |
OPS_PTAG_SS_RESERVED =0x200+10, |
|---|
| 162 |
OPS_PTAG_SS_PREFERRED_SKA =0x200+11, |
|---|
| 163 |
OPS_PTAG_SS_REVOCATION_KEY =0x200+12, |
|---|
| 164 |
OPS_PTAG_SS_ISSUER_KEY_ID =0x200+16, |
|---|
| 165 |
OPS_PTAG_SS_NOTATION_DATA =0x200+20, |
|---|
| 166 |
OPS_PTAG_SS_PREFERRED_HASH =0x200+21, |
|---|
| 167 |
OPS_PTAG_SS_PREFERRED_COMPRESSION =0x200+22, |
|---|
| 168 |
OPS_PTAG_SS_KEY_SERVER_PREFS =0x200+23, |
|---|
| 169 |
OPS_PTAG_SS_PREFERRED_KEY_SERVER =0x200+24, |
|---|
| 170 |
OPS_PTAG_SS_PRIMARY_USER_ID =0x200+25, |
|---|
| 171 |
OPS_PTAG_SS_POLICY_URL =0x200+26, |
|---|
| 172 |
OPS_PTAG_SS_KEY_FLAGS =0x200+27, |
|---|
| 173 |
OPS_PTAG_SS_SIGNERS_USER_ID =0x200+28, |
|---|
| 174 |
OPS_PTAG_SS_REVOCATION_REASON =0x200+29, |
|---|
| 175 |
OPS_PTAG_SS_FEATURES =0x200+30, |
|---|
| 176 |
|
|---|
| 177 |
OPS_PTAG_SS_USERDEFINED00 =0x200+100, |
|---|
| 178 |
OPS_PTAG_SS_USERDEFINED01 =0x200+101, |
|---|
| 179 |
OPS_PTAG_SS_USERDEFINED02 =0x200+102, |
|---|
| 180 |
OPS_PTAG_SS_USERDEFINED03 =0x200+103, |
|---|
| 181 |
OPS_PTAG_SS_USERDEFINED04 =0x200+104, |
|---|
| 182 |
OPS_PTAG_SS_USERDEFINED05 =0x200+105, |
|---|
| 183 |
OPS_PTAG_SS_USERDEFINED06 =0x200+106, |
|---|
| 184 |
OPS_PTAG_SS_USERDEFINED07 =0x200+107, |
|---|
| 185 |
OPS_PTAG_SS_USERDEFINED08 =0x200+108, |
|---|
| 186 |
OPS_PTAG_SS_USERDEFINED09 =0x200+109, |
|---|
| 187 |
OPS_PTAG_SS_USERDEFINED10 =0x200+110, |
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
OPS_PTAG_CT_LITERAL_DATA_HEADER =0x300, |
|---|
| 192 |
OPS_PTAG_CT_LITERAL_DATA_BODY =0x300+1, |
|---|
| 193 |
OPS_PTAG_CT_SIGNATURE_HEADER =0x300+2, |
|---|
| 194 |
OPS_PTAG_CT_SIGNATURE_FOOTER =0x300+3, |
|---|
| 195 |
OPS_PTAG_CT_ARMOUR_HEADER =0x300+4, |
|---|
| 196 |
OPS_PTAG_CT_ARMOUR_TRAILER =0x300+5, |
|---|
| 197 |
OPS_PTAG_CT_SIGNED_CLEARTEXT_HEADER =0x300+6, |
|---|
| 198 |
OPS_PTAG_CT_SIGNED_CLEARTEXT_BODY =0x300+7, |
|---|
| 199 |
OPS_PTAG_CT_SIGNED_CLEARTEXT_TRAILER=0x300+8, |
|---|
| 200 |
OPS_PTAG_CT_UNARMOURED_TEXT =0x300+9, |
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
OPS_PTAG_CMD_GET_PASSPHRASE =0x400, |
|---|
| 204 |
}; |
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
typedef struct |
|---|
| 208 |
{ |
|---|
| 209 |
const char *error; |
|---|
| 210 |
} ops_parser_error_t; |
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
typedef struct |
|---|
| 214 |
{ |
|---|
| 215 |
ops_errcode_t errcode; |
|---|
| 216 |
} ops_parser_errcode_t; |
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
typedef struct |
|---|
| 222 |
{ |
|---|
| 223 |
unsigned new_format; |
|---|
| 224 |
unsigned content_tag; |
|---|
| 225 |
ops_ptag_of_lt_t length_type; |
|---|
| 226 |
unsigned length; |
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
unsigned position; |
|---|
| 230 |
} ops_ptag_t; |
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
typedef enum |
|---|
| 240 |
{ |
|---|
| 241 |
OPS_PKA_RSA =1, |
|---|
| 242 |
OPS_PKA_RSA_ENCRYPT_ONLY =2, |
|---|
| 243 |
OPS_PKA_RSA_SIGN_ONLY =3, |
|---|
| 244 |
OPS_PKA_ELGAMAL =16, |
|---|
| 245 |
OPS_PKA_DSA =17, |
|---|
| 246 |
OPS_PKA_RESERVED_ELLIPTIC_CURVE =18, |
|---|
| 247 |
OPS_PKA_RESERVED_ECDSA =19, |
|---|
| 248 |
OPS_PKA_ELGAMAL_ENCRYPT_OR_SIGN =20, |
|---|
| 249 |
OPS_PKA_RESERVED_DH =21, |
|---|
| 250 |
OPS_PKA_PRIVATE00 =100, |
|---|
| 251 |
OPS_PKA_PRIVATE01 =101, |
|---|
| 252 |
OPS_PKA_PRIVATE02 =102, |
|---|
| 253 |
OPS_PKA_PRIVATE03 =103, |
|---|
| 254 |
OPS_PKA_PRIVATE04 =104, |
|---|
| 255 |
OPS_PKA_PRIVATE05 =105, |
|---|
| 256 |
OPS_PKA_PRIVATE06 =106, |
|---|
| 257 |
OPS_PKA_PRIVATE07 =107, |
|---|
| 258 |
OPS_PKA_PRIVATE08 =108, |
|---|
| 259 |
OPS_PKA_PRIVATE09 =109, |
|---|
| 260 |
OPS_PKA_PRIVATE10 =110, |
|---|
| 261 |
} ops_public_key_algorithm_t; |
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
typedef struct |
|---|
| 268 |
{ |
|---|
| 269 |
BIGNUM *p; |
|---|
| 270 |
BIGNUM *q; |
|---|
| 271 |
BIGNUM *g; |
|---|
| 272 |
BIGNUM *y; |
|---|
| 273 |
} ops_dsa_public_key_t; |
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
typedef struct |
|---|
| 280 |
{ |
|---|
| 281 |
BIGNUM *n; |
|---|
| 282 |
BIGNUM *e; |
|---|
| 283 |
} ops_rsa_public_key_t; |
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
typedef struct |
|---|
| 290 |
{ |
|---|
| 291 |
BIGNUM *p; |
|---|
| 292 |
BIGNUM *g; |
|---|
| 293 |
BIGNUM *y; |
|---|
| 294 |
} ops_elgamal_public_key_t; |
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
typedef union |
|---|
| 298 |
{ |
|---|
| 299 |
ops_dsa_public_key_t dsa; |
|---|
| 300 |
ops_rsa_public_key_t rsa; |
|---|
| 301 |
ops_elgamal_public_key_t elgamal; |
|---|
| 302 |
} ops_public_key_union_t; |
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
typedef enum |
|---|
| 310 |
{ |
|---|
| 311 |
OPS_V3=3, |
|---|
| 312 |
OPS_V4=4, |
|---|
| 313 |
} ops_version_t; |
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
typedef struct |
|---|
| 317 |
{ |
|---|
| 318 |
ops_version_t version; |
|---|
| 319 |
time_t creation_time; |
|---|
| 320 |
|
|---|
| 321 |
unsigned days_valid; |
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
ops_public_key_algorithm_t algorithm; |
|---|
| 325 |
ops_public_key_union_t key; |
|---|
| 326 |
} ops_public_key_t; |
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
typedef struct |
|---|
| 331 |
{ |
|---|
| 332 |
BIGNUM *d; |
|---|
| 333 |
BIGNUM *p; |
|---|
| 334 |
BIGNUM *q; |
|---|
| 335 |
BIGNUM *u; |
|---|
| 336 |
} ops_rsa_secret_key_t; |
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
typedef struct |
|---|
| 341 |
{ |
|---|
| 342 |
ops_rsa_secret_key_t rsa; |
|---|
| 343 |
} ops_secret_key_union_t; |
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 |
typedef enum |
|---|
| 348 |
{ |
|---|
| 349 |
OPS_S2KU_NONE=0, |
|---|
| 350 |
OPS_S2KU_ENCRYPTED_AND_HASHED=254, |
|---|
| 351 |
OPS_S2KU_ENCRYPTED=255 |
|---|
| 352 |
} ops_s2k_usage_t; |
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
typedef enum |
|---|
| 357 |
{ |
|---|
| 358 |
OPS_S2KS_SIMPLE=0, |
|---|
| 359 |
OPS_S2KS_SALTED=1, |
|---|
| 360 |
OPS_S2KS_ITERATED_AND_SALTED=3 |
|---|
| 361 |
} ops_s2k_specifier_t; |
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
|
|---|
| 370 |
typedef enum |
|---|
| 371 |
{ |
|---|
| 372 |
OPS_SA_PLAINTEXT =0, |
|---|
| 373 |
OPS_SA_IDEA =1, |
|---|
| 374 |
OPS_SA_TRIPLEDES =2, |
|---|
| 375 |
OPS_SA_CAST5 =3, |
|---|
| 376 |
OPS_SA_BLOWFISH =4, |
|---|
| 377 |
OPS_SA_AES_128 =7, |
|---|
| 378 |
OPS_SA_AES_192 =8, |
|---|
| 379 |
OPS_SA_AES_256 =9, |
|---|
| 380 |
OPS_SA_TWOFISH =10, |
|---|
| 381 |
} ops_symmetric_algorithm_t; |
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
#define OPS_MAX_BLOCK_SIZE 16 |
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 |
typedef struct |
|---|
| 389 |
{ |
|---|
| 390 |
ops_public_key_t public_key; |
|---|
| 391 |
ops_s2k_usage_t s2k_usage; |
|---|
| 392 |
ops_s2k_specifier_t s2k_specifier; |
|---|
| 393 |
ops_symmetric_algorithm_t algorithm; |
|---|
| 394 |
unsigned char iv[OPS_MAX_BLOCK_SIZE]; |
|---|
| 395 |
unsigned checksum; |
|---|
| 396 |
ops_secret_key_union_t key; |
|---|
| 397 |
} ops_secret_key_t; |
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 |
typedef struct |
|---|
| 402 |
{ |
|---|
| 403 |
ops_data_t data; |
|---|
| 404 |
} ops_trust_t; |
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 |
typedef struct |
|---|
| 408 |
{ |
|---|
| 409 |
unsigned char *user_id; |
|---|
| 410 |
} ops_user_id_t; |
|---|
| 411 |
|
|---|
| 412 |
|
|---|
| 413 |
typedef struct |
|---|
| 414 |
{ |
|---|
| 415 |
ops_data_t data; |
|---|
| 416 |
} ops_user_attribute_t; |
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
|
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
|
|---|
| 428 |
typedef enum |
|---|
| 429 |
{ |
|---|
| 430 |
OPS_SIG_BINARY =0x00, |
|---|
| 431 |
OPS_SIG_TEXT =0x01, |
|---|
| 432 |
OPS_SIG_STANDALONE =0x02, |
|---|
| 433 |
|
|---|
| 434 |
OPS_CERT_GENERIC =0x10, |
|---|
| 435 |
OPS_CERT_PERSONA =0x11, |
|---|
| 436 |
OPS_CERT_CASUAL =0x12, |
|---|
| 437 |
OPS_CERT_POSITIVE =0x13, |
|---|
| 438 |
|
|---|
| 439 |
OPS_SIG_SUBKEY =0x18, |
|---|
| 440 |
OPS_SIG_PRIMARY =0x19, |
|---|
| 441 |
OPS_SIG_DIRECT =0x1f, |
|---|
| 442 |
|
|---|
| 443 |
OPS_SIG_REV_KEY =0x20, |
|---|
| 444 |
OPS_SIG_REV_SUBKEY =0x28, |
|---|
| 445 |
OPS_SIG_REV_CERT =0x30, |
|---|
| 446 |
|
|---|
| 447 |
OPS_SIG_TIMESTAMP =0x40, |
|---|
| 448 |
|
|---|
| 449 |
OPS_SIG_3RD_PARTY =0x50, |
|---|
| 450 |
} ops_sig_type_t; |
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 |
typedef enum |
|---|
| 460 |
{ |
|---|
| 461 |
OPS_HASH_UNKNOWN =-1, |
|---|
| 462 |
OPS_HASH_MD5 = 1, |
|---|
| 463 |
OPS_HASH_SHA1 = 2, |
|---|
| 464 |
OPS_HASH_RIPEMD = 3, |
|---|
| 465 |
|
|---|
| 466 |
OPS_HASH_SHA256 = 8, |
|---|
| 467 |
OPS_HASH_SHA384 = 9, |
|---|
| 468 |
OPS_HASH_SHA512 =10, |
|---|
| 469 |
} ops_hash_algorithm_t; |
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
typedef struct |
|---|
| 473 |
{ |
|---|
| 474 |
BIGNUM *sig; |
|---|
| 475 |
} ops_rsa_signature_t; |
|---|
| 476 |
|
|---|
| 477 |
|
|---|
| 478 |
typedef struct |
|---|
| 479 |
{ |
|---|
| 480 |
BIGNUM *r; |
|---|
| 481 |
BIGNUM *s; |
|---|
| 482 |
} ops_dsa_signature_t; |
|---|
| 483 |
|
|---|
| 484 |
|
|---|
| 485 |
typedef struct |
|---|
| 486 |
{ |
|---|
| 487 |
BIGNUM *r; |
|---|
| 488 |
BIGNUM *s; |
|---|
| 489 |
} ops_elgamal_signature_t; |
|---|
| 490 |
|
|---|
| 491 |
|
|---|
| 492 |
typedef struct |
|---|
| 493 |
{ |
|---|
| 494 |
ops_data_t data; |
|---|
| 495 |
} ops_unknown_signature_t; |
|---|
| 496 |
|
|---|
| 497 |
|
|---|
| 498 |
typedef union |
|---|
| 499 |
{ |
|---|
| 500 |
ops_rsa_signature_t rsa; |
|---|
| 501 |
ops_dsa_signature_t dsa; |
|---|
| 502 |
ops_elgamal_signature_t elgamal; |
|---|
| 503 |
ops_unknown_signature_t unknown; |
|---|
| 504 |
} ops_signature_union_t; |
|---|
| 505 |
|
|---|
| 506 |
#define OPS_KEY_ID_SIZE 8 |
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 |
|
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 |
typedef struct |
|---|
| 514 |
{ |
|---|
| 515 |
ops_version_t version; |
|---|
| 516 |
ops_sig_type_t type; |
|---|
| 517 |
time_t creation_time; |
|---|
| 518 |
unsigned char signer_id[OPS_KEY_ID_SIZE]; |
|---|
| 519 |
ops_public_key_algorithm_t key_algorithm; |
|---|
| 520 |
ops_hash_algorithm_t hash_algorithm; |
|---|
| 521 |
unsigned char hash2[2]; |
|---|
| 522 |
ops_signature_union_t signature; |
|---|
| 523 |
size_t v4_hashed_data_start; |
|---|
| 524 |
size_t v4_hashed_data_length; |
|---|
| 525 |
ops_boolean_t creation_time_set:1; |
|---|
| 526 |
ops_boolean_t signer_id_set:1; |
|---|
| 527 |
} ops_signature_t; |
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
typedef struct |
|---|
| 532 |
{ |
|---|
| 533 |
ops_content_tag_t tag; |
|---|
| 534 |
size_t length; |
|---|
| 535 |
unsigned char *raw; |
|---|
| 536 |
} ops_ss_raw_t; |
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
typedef struct |
|---|
| 541 |
{ |
|---|
| 542 |
unsigned char level; |
|---|
| 543 |
unsigned char amount; |
|---|
| 544 |
} ops_ss_trust_t; |
|---|
| 545 |
|
|---|
| 546 |
|
|---|
| 547 |
typedef struct |
|---|
| 548 |
{ |
|---|
| 549 |
ops_boolean_t revocable; |
|---|
| 550 |
} ops_ss_revocable_t; |
|---|
| 551 |
|
|---|
| 552 |
|
|---|
| 553 |
typedef struct |
|---|
| 554 |
{ |
|---|
| 555 |
time_t time; |
|---|
| 556 |
} ops_ss_time_t; |
|---|
| 557 |
|
|---|
| 558 |
|
|---|
| 559 |
typedef struct |
|---|
| 560 |
{ |
|---|
| 561 |
unsigned char key_id[OPS_KEY_ID_SIZE]; |
|---|
| 562 |
} ops_ss_key_id_t; |
|---|
| 563 |
|
|---|
| 564 |
|
|---|
| 565 |
typedef struct |
|---|
| 566 |
{ |
|---|
| 567 |
ops_data_t flags; |
|---|
| 568 |
ops_data_t name; |
|---|
| 569 |
ops_data_t value; |
|---|
| 570 |
} ops_ss_notation_data_t; |
|---|
| 571 |
|
|---|
| 572 |
|
|---|
| 573 |
typedef struct |
|---|
| 574 |
{ |
|---|
| 575 |
ops_data_t data; |
|---|
| 576 |
} ops_ss_userdefined_t; |
|---|
| 577 |
|
|---|
| 578 |
|
|---|
| 579 |
typedef struct |
|---|
| 580 |
{ |
|---|
| 581 |
ops_data_t data; |
|---|
| 582 |
} ops_ss_unknown_t; |
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 |
typedef struct |
|---|
| 586 |
{ |
|---|
| 587 |
ops_data_t data; |
|---|
| 588 |
|
|---|
| 589 |
|
|---|
| 590 |
} ops_ss_preferred_ska_t; |
|---|
| 591 |
|
|---|
| 592 |
|
|---|
| 593 |
typedef struct |
|---|
| 594 |
{ |
|---|
| 595 |
ops_data_t data; |
|---|
| 596 |
} ops_ss_preferred_hash_t; |
|---|
| 597 |
|
|---|
| 598 |
|
|---|
| 599 |
typedef struct |
|---|
| 600 |
{ |
|---|
| 601 |
ops_data_t data; |
|---|
| 602 |
} ops_ss_preferred_compression_t; |
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 |
typedef struct |
|---|
| 606 |
{ |
|---|
| 607 |
ops_data_t data; |
|---|
| 608 |
} ops_ss_key_flags_t; |
|---|
| 609 |
|
|---|
| 610 |
|
|---|
| 611 |
typedef struct |
|---|
| 612 |
{ |
|---|
| 613 |
ops_data_t data; |
|---|
| 614 |
} ops_ss_key_server_prefs_t; |
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 |
typedef struct |
|---|
| 618 |
{ |
|---|
| 619 |
ops_data_t data; |
|---|
| 620 |
} ops_ss_features_t; |
|---|
| 621 |
|
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 |
typedef struct |
|---|
| 625 |
{ |
|---|
| 626 |
size_t length; |
|---|
| 627 |
unsigned char *raw; |
|---|
| 628 |
} ops_packet_t; |
|---|
| 629 |
|
|---|
| 630 |
|
|---|
| 631 |
typedef enum |
|---|
| 632 |
{ |
|---|
| 633 |
OPS_C_NONE=0, |
|---|
| 634 |
OPS_C_ZIP=1, |
|---|
| 635 |
OPS_C_ZLIB=2, |
|---|
| 636 |
OPS_C_BZIP2=3, |
|---|
| 637 |
} ops_compression_type_t; |
|---|
| 638 |
|
|---|
| 639 |
|
|---|
| 640 |
|
|---|
| 641 |
|
|---|
| 642 |
typedef struct |
|---|
| 643 |
{ |
|---|
| 644 |
ops_compression_type_t type; |
|---|
| 645 |
} ops_compressed_t; |
|---|
| 646 |
|
|---|
| 647 |
|
|---|
| 648 |
typedef struct |
|---|
| 649 |
{ |
|---|
| 650 |
unsigned char version; |
|---|
| 651 |
ops_sig_type_t sig_type; |
|---|
| 652 |
ops_hash_algorithm_t hash_algorithm; |
|---|
| 653 |
ops_public_key_algorithm_t key_algorithm; |
|---|
| 654 |
unsigned char keyid[OPS_KEY_ID_SIZE]; |
|---|
| 655 |
ops_boolean_t nested; |
|---|
| 656 |
} ops_one_pass_signature_t; |
|---|
| 657 |
|
|---|
| 658 |
|
|---|
| 659 |
typedef struct |
|---|
| 660 |
{ |
|---|
| 661 |
ops_boolean_t primary_user_id; |
|---|
| 662 |
} ops_ss_primary_user_id_t; |
|---|
| 663 |
|
|---|
| 664 |
|
|---|
| 665 |
typedef struct |
|---|
| 666 |
{ |
|---|
| 667 |
char *text; |
|---|
| 668 |
} ops_ss_regexp_t; |
|---|
| 669 |
|
|---|
| 670 |
|
|---|
| 671 |
typedef struct |
|---|
| 672 |
{ |
|---|
| 673 |
char *text; |
|---|
| 674 |
} ops_ss_policy_url_t; |
|---|
| 675 |
|
|---|
| 676 |
|
|---|
| 677 |
typedef struct |
|---|
| 678 |
{ |
|---|
| 679 |
char *text; |
|---|
| 680 |
} ops_ss_preferred_key_server_t; |
|---|
| 681 |
|
|---|
| 682 |
|
|---|
| 683 |
typedef struct |
|---|
| 684 |
{ |
|---|
| 685 |
unsigned char class; |
|---|
| 686 |
unsigned char algid; |
|---|
| 687 |
unsigned char fingerprint[20]; |
|---|
| 688 |
} ops_ss_revocation_key_t; |
|---|
| 689 |
|
|---|
| 690 |
|
|---|
| 691 |
typedef struct |
|---|
| 692 |
{ |
|---|
| 693 |
unsigned char code; |
|---|
| 694 |
char *text; |
|---|
| 695 |
} ops_ss_revocation_reason_t; |
|---|
| 696 |
|
|---|
| 697 |
|
|---|
| 698 |
typedef enum |
|---|
| 699 |
{ |
|---|
| 700 |
OPS_LDT_BINARY='b', |
|---|
| 701 |
OPS_LDT_TEXT='t', |
|---|
| 702 |
OPS_LDT_UTF8='u', |
|---|
| 703 |
OPS_LDT_LOCAL='l', |
|---|
| 704 |
OPS_LDT_LOCAL2='1' |
|---|
| 705 |
} literal_data_type_t; |
|---|
| 706 |
|
|---|
| 707 |
|
|---|
| 708 |
typedef struct |
|---|
| 709 |
{ |
|---|
| 710 |
literal_data_type_t format; |
|---|
| 711 |
char filename[256]; |
|---|
| 712 |
time_t modification_time; |
|---|
| 713 |
} ops_literal_data_header_t; |
|---|
| 714 |
|
|---|
| 715 |
|
|---|
| 716 |
typedef struct |
|---|
| 717 |
{ |
|---|
| 718 |
unsigned length; |
|---|
| 719 |
unsigned char data[8192]; |
|---|
| 720 |
} ops_literal_data_body_t; |
|---|
| 721 |
|
|---|
| 722 |
|
|---|
| 723 |
typedef struct |
|---|
| 724 |
{ |
|---|
| 725 |
char *key; |
|---|
| 726 |
char *value; |
|---|
| 727 |
} ops_armoured_header_value_t; |
|---|
| 728 |
|
|---|
| 729 |
|
|---|
| 730 |
typedef struct |
|---|
| 731 |
{ |
|---|
| 732 |
ops_armoured_header_value_t *headers; |
|---|
| 733 |
unsigned nheaders; |
|---|
| 734 |
} ops_headers_t; |
|---|
| 735 |
|
|---|
| 736 |
|
|---|
| 737 |
typedef struct |
|---|
| 738 |
{ |
|---|
| 739 |
const char *type; |
|---|
| 740 |
ops_headers_t headers; |
|---|
| 741 |
} ops_armour_header_t; |
|---|
| 742 |
|
|---|
| 743 |
|
|---|
| 744 |
typedef struct |
|---|
| 745 |
{ |
|---|
| 746 |
const char *type; |
|---|
| 747 |
} ops_armour_trailer_t; |
|---|
| 748 |
|
|---|
| 749 |
|
|---|
| 750 |
typedef struct |
|---|
| 751 |
{ |
|---|
| 752 |
ops_headers_t headers; |
|---|
| 753 |
} ops_signed_cleartext_header_t; |
|---|
| 754 |
|
|---|
| 755 |
|
|---|
| 756 |
typedef struct |
|---|
| 757 |
{ |
|---|
| 758 |
unsigned length; |
|---|
| 759 |
unsigned char data[8192]; |
|---|
| 760 |
} ops_signed_cleartext_body_t; |
|---|
| 761 |
|
|---|
| 762 |
|
|---|
| 763 |
typedef struct |
|---|
| 764 |
{ |
|---|
| 765 |
struct _ops_hash_t *hash; |
|---|
| 766 |
} ops_signed_cleartext_trailer_t; |
|---|
| 767 |
|
|---|
| 768 |
|
|---|
| 769 |
typedef struct |
|---|
| 770 |
{ |
|---|
| 771 |
unsigned length; |
|---|
| 772 |
unsigned char *data; |
|---|
| 773 |
} ops_unarmoured_text_t; |
|---|
| 774 |
|
|---|
| 775 |
typedef enum |
|---|
| 776 |
{ |
|---|
| 777 |
OPS_PKSK_V3=3 |
|---|
| 778 |
} ops_pk_session_key_version_t; |
|---|
| 779 |
|
|---|
| 780 |
typedef struct |
|---|
| 781 |
{ |
|---|
| 782 |
BIGNUM *encrypted_m; |
|---|
| 783 |
} ops_pk_session_key_parameters_rsa_t; |
|---|
| 784 |
|
|---|
| 785 |
typedef struct |
|---|
| 786 |
{ |
|---|
| 787 |
BIGNUM *g_to_k; |
|---|
| 788 |
BIGNUM *encrypted_m; |
|---|
| 789 |
} ops_pk_session_key_parameters_elgamal_t; |
|---|
| 790 |
|
|---|
| 791 |
typedef union |
|---|
| 792 |
{ |
|---|
| 793 |
ops_pk_session_key_parameters_rsa_t rsa; |
|---|
| 794 |
ops_pk_session_key_parameters_elgamal_t elgamal; |
|---|
| 795 |
} ops_pk_session_key_parameters_t; |
|---|
| 796 |
|
|---|
| 797 |
typedef struct |
|---|
| 798 |
{ |
|---|
| 799 |
ops_pk_session_key_version_t version; |
|---|
| 800 |
unsigned char key_id[OPS_KEY_ID_SIZE]; |
|---|
| 801 |
ops_public_key_algorithm_t algorithm; |
|---|
| 802 |
ops_pk_session_key_parameters_t parameters; |
|---|
| 803 |
} ops_pk_session_key_t; |
|---|
| 804 |
|
|---|
| 805 |
|
|---|
| 806 |
typedef union |
|---|
| 807 |
{ |
|---|
| 808 |
ops_parser_error_t error; |
|---|
| 809 |
ops_parser_errcode_t errcode; |
|---|
| 810 |
ops_ptag_t ptag; |
|---|
| 811 |
ops_public_key_t public_key; |
|---|
| 812 |
ops_trust_t trust; |
|---|
| 813 |
ops_user_id_t user_id; |
|---|
| 814 |
ops_user_attribute_t user_attribute; |
|---|
| 815 |
ops_signature_t signature; |
|---|
| 816 |
ops_ss_raw_t ss_raw; |
|---|
| 817 |
ops_ss_trust_t ss_trust; |
|---|
| 818 |
ops_ss_revocable_t ss_revocable; |
|---|
| 819 |
ops_ss_time_t ss_time; |
|---|
| 820 |
ops_ss_key_id_t ss_issuer_key_id; |
|---|
| 821 |
ops_ss_notation_data_t ss_notation_data; |
|---|
| 822 |
ops_packet_t packet; |
|---|
| 823 |
ops_compressed_t compressed; |
|---|
| 824 |
ops_one_pass_signature_t one_pass_signature; |
|---|
| 825 |
ops_ss_preferred_ska_t ss_preferred_ska; |
|---|
| 826 |
ops_ss_preferred_hash_t ss_preferred_hash; |
|---|
| 827 |
ops_ss_preferred_compression_t ss_preferred_compression; |
|---|
| 828 |
ops_ss_key_flags_t ss_key_flags; |
|---|
| 829 |
ops_ss_key_server_prefs_t ss_key_server_prefs; |
|---|
| 830 |
ops_ss_primary_user_id_t ss_primary_user_id; |
|---|
| 831 |
ops_ss_regexp_t ss_regexp; |
|---|
| 832 |
ops_ss_policy_url_t ss_policy_url; |
|---|
| 833 |
ops_ss_preferred_key_server_t ss_preferred_key_server; |
|---|
| 834 |
ops_ss_revocation_key_t ss_revocation_key; |
|---|
| 835 |
ops_ss_userdefined_t ss_userdefined; |
|---|
| 836 |
ops_ss_unknown_t ss_unknown; |
|---|
| 837 |
ops_literal_data_header_t literal_data_header; |
|---|
| 838 |
ops_literal_data_body_t literal_data_body; |
|---|
| 839 |
ops_ss_features_t ss_features; |
|---|
| 840 |
ops_ss_revocation_reason_t ss_revocation_reason; |
|---|
| 841 |
ops_secret_key_t secret_key; |
|---|
| 842 |
ops_user_id_t ss_signers_user_id; |
|---|
| 843 |
ops_armour_header_t armour_header; |
|---|
| 844 |
ops_armour_trailer_t armour_trailer; |
|---|
| 845 |
ops_signed_cleartext_header_t signed_cleartext_header; |
|---|
| 846 |
ops_signed_cleartext_body_t signed_cleartext_body; |
|---|
| 847 |
ops_signed_cleartext_trailer_t signed_cleartext_trailer; |
|---|
| 848 |
ops_unarmoured_text_t unarmoured_text; |
|---|
| 849 |
ops_pk_session_key_t pk_session_key; |
|---|
| 850 |
char **passphrase; |
|---|
| 851 |
} ops_parser_content_union_t; |
|---|
| 852 |
|
|---|
| 853 |
|
|---|
| 854 |
struct ops_parser_content_t |
|---|
| 855 |
{ |
|---|
| 856 |
ops_content_tag_t tag; |
|---|
| 857 |
unsigned char critical; |
|---|
| 858 |
ops_parser_content_union_t content; |
|---|
| 859 |
}; |
|---|
| 860 |
|
|---|
| 861 |
|
|---|
| 862 |
typedef struct |
|---|
| 863 |
{ |
|---|
| 864 |
unsigned char fingerprint[20]; |
|---|
| 865 |
unsigned length; |
|---|
| 866 |
} ops_fingerprint_t; |
|---|
| 867 |
|
|---|
| 868 |
void ops_init(void); |
|---|
| 869 |
void ops_finish(void); |
|---|
| 870 |
void ops_keyid(unsigned char keyid[OPS_KEY_ID_SIZE], |
|---|
| 871 |
const ops_public_key_t *key); |
|---|
| 872 |
void ops_fingerprint(ops_fingerprint_t *fp,const ops_public_key_t *key); |
|---|
| 873 |
void ops_public_key_free(ops_public_key_t *key); |
|---|
| 874 |
void ops_user_id_free(ops_user_id_t *id); |
|---|
| 875 |
void ops_user_attribute_free(ops_user_attribute_t *att); |
|---|
| 876 |
void ops_signature_free(ops_signature_t *sig); |
|---|
| 877 |
void ops_trust_free(ops_trust_t *trust); |
|---|
| 878 |
void ops_ss_preferred_ska_free(ops_ss_preferred_ska_t *ss_preferred_ska); |
|---|
| 879 |
void ops_ss_preferred_hash_free(ops_ss_preferred_hash_t *ss_preferred_hash); |
|---|
| 880 |
void ops_ss_preferred_compression_free(ops_ss_preferred_compression_t *ss_preferred_compression); |
|---|
| 881 |
void ops_ss_key_flags_free(ops_ss_key_flags_t *ss_key_flags); |
|---|
| 882 |
void ops_ss_key_server_prefs_free(ops_ss_key_server_prefs_t *ss_key_server_prefs); |
|---|
| 883 |
void ops_ss_features_free(ops_ss_features_t *ss_features); |
|---|
| 884 |
void ops_ss_notation_data_free(ops_ss_notation_data_t *ss_notation_data); |
|---|
| 885 |
void ops_ss_policy_url_free(ops_ss_policy_url_t *ss_policy_url); |
|---|
| 886 |
void ops_ss_preferred_key_server_free(ops_ss_preferred_key_server_t *ss_preferred_key_server); |
|---|
| 887 |
void ops_ss_regexp_free(ops_ss_regexp_t *ss_regexp); |
|---|
| 888 |
void ops_ss_userdefined_free(ops_ss_userdefined_t *ss_userdefined); |
|---|
| 889 |
void ops_ss_reserved_free(ops_ss_unknown_t *ss_unknown); |
|---|
| 890 |
void ops_ss_revocation_reason_free(ops_ss_revocation_reason_t *ss_revocation_reason); |
|---|
| 891 |
void ops_packet_free(ops_packet_t *packet); |
|---|
| 892 |
void ops_parser_content_free(ops_parser_content_t *c); |
|---|
| 893 |
void ops_secret_key_free(ops_secret_key_t *key); |
|---|
| 894 |
void ops_pk_session_key_free(ops_pk_session_key_t *sk); |
|---|
| 895 |
|
|---|
| 896 |
|
|---|
| 897 |
|
|---|
| 898 |
|
|---|
| 899 |
#endif |
|---|
| 900 |
|
|---|