packet.h File Reference

packet related headers. More...

#include "configure.h"
#include <time.h>
#include <openssl/bn.h>
#include <openssl/sha.h>
#include "types.h"
#include "errors.h"

Go to the source code of this file.

Data Structures

struct  ops_data_t
 General-use structure for variable-length data. More...
struct  ops_parser_error_t
 Structure to hold one parse error string. More...
struct  ops_parser_errcode_t
 Structure to hold one error code. More...
struct  ops_ptag_t
 Structure to hold one packet tag. More...
struct  ops_dsa_public_key_t
 Structure to hold one DSA public key parameters. More...
struct  ops_rsa_public_key_t
 Structure to hold on RSA public key. More...
struct  ops_elgamal_public_key_t
 Structure to hold on ElGamal public key parameters. More...
union  ops_public_key_union_t
 Union to hold public key parameters of any algorithm. More...
struct  ops_public_key_t
 Structure to hold one pgp public key. More...
struct  ops_rsa_secret_key_t
 Structure to hold data for one RSA secret key. More...
struct  ops_dsa_secret_key_t
 ops_dsa_secret_key_t More...
struct  ops_secret_key_union_t
 ops_secret_key_union_t More...
struct  ops_secret_key_t
 ops_secret_key_t More...
struct  ops_trust_t
 Structure to hold one trust packet's data. More...
struct  ops_user_id_t
 Structure to hold one user id. More...
struct  ops_user_attribute_t
 Structure to hold one user attribute. More...
struct  ops_rsa_signature_t
 Struct to hold parameters of an RSA signature. More...
struct  ops_dsa_signature_t
 Struct to hold parameters of a DSA signature. More...
struct  ops_elgamal_signature_t
 ops_elgamal_signature_t More...
struct  ops_unknown_signature_t
 Struct to hold data for a private/experimental signature. More...
union  ops_signature_union_t
 Union to hold signature parameters of any algorithm. More...
struct  ops_signature_info_t
 Struct to hold a signature packet. More...
struct  ops_signature_t
 Struct used when parsing a signature. More...
struct  ops_ss_raw_t
 The raw bytes of a signature subpacket. More...
struct  ops_ss_trust_t
 Signature Subpacket : Trust Level. More...
struct  ops_ss_revocable_t
 Signature Subpacket : Revocable. More...
struct  ops_ss_time_t
 Signature Subpacket : Time. More...
struct  ops_ss_key_id_t
 Signature Subpacket : Key ID. More...
struct  ops_ss_notation_data_t
 Signature Subpacket : Notation Data. More...
struct  ops_ss_userdefined_t
 Signature Subpacket : User Defined. More...
struct  ops_ss_unknown_t
 Signature Subpacket : Unknown. More...
struct  ops_ss_preferred_ska_t
 Signature Subpacket : Preferred Symmetric Key Algorithm. More...
struct  ops_ss_preferred_hash_t
 Signature Subpacket : Preferrred Hash Algorithm. More...
struct  ops_ss_preferred_compression_t
 Signature Subpacket : Preferred Compression. More...
struct  ops_ss_key_flags_t
 Signature Subpacket : Key Flags. More...
struct  ops_ss_key_server_prefs_t
 Signature Subpacket : Key Server Preferences. More...
struct  ops_ss_features_t
 Signature Subpacket : Features. More...
struct  ops_ss_signature_target_t
 Signature Subpacket : Signature Target. More...
struct  ops_ss_embedded_signature_t
 Signature Subpacket : Embedded Signature. More...
struct  ops_packet_t
 ops_packet_t More...
struct  ops_compressed_t
 ops_compressed_t More...
struct  ops_one_pass_signature_t
 ops_one_pass_signature_t More...
struct  ops_ss_primary_user_id_t
 Signature Subpacket : Primary User ID. More...
struct  ops_ss_regexp_t
 Signature Subpacket : Regexp. More...
struct  ops_ss_policy_url_t
 Signature Subpacket : Policy URL. More...
struct  ops_ss_preferred_key_server_t
 Signature Subpacket : Preferred Key Server. More...
struct  ops_ss_revocation_key_t
 Signature Subpacket : Revocation Key. More...
struct  ops_ss_revocation_reason_t
 Signature Subpacket : Revocation Reason. More...
struct  ops_literal_data_header_t
 ops_literal_data_header_t More...
struct  ops_literal_data_body_t
 ops_literal_data_body_t More...
struct  ops_mdc_t
 ops_mdc_t More...
struct  ops_armoured_header_value_t
 ops_armoured_header_value_t More...
struct  ops_headers_t
 ops_headers_t More...
struct  ops_armour_header_t
 ops_armour_header_t More...
struct  ops_armour_trailer_t
 ops_armour_trailer_t More...
struct  ops_signed_cleartext_header_t
 ops_signed_cleartext_header_t More...
struct  ops_signed_cleartext_body_t
 ops_signed_cleartext_body_t More...
struct  ops_signed_cleartext_trailer_t
 ops_signed_cleartext_trailer_t More...
struct  ops_unarmoured_text_t
 ops_unarmoured_text_t More...
struct  ops_pk_session_key_parameters_rsa_t
 ops_pk_session_key_parameters_rsa_t More...
struct  ops_pk_session_key_parameters_elgamal_t
 ops_pk_session_key_parameters_elgamal_t More...
union  ops_pk_session_key_parameters_t
 ops_pk_session_key_parameters_t More...
struct  ops_pk_session_key_t
 ops_pk_session_key_t More...
struct  ops_secret_key_passphrase_t
 ops_secret_key_passphrase_t More...
struct  ops_se_ip_data_header_t
 ops_se_ip_data_header_t More...
struct  ops_se_ip_data_body_t
 ops_se_ip_data_body_t More...
struct  ops_se_data_body_t
 ops_se_data_body_t More...
struct  ops_get_secret_key_t
 ops_get_secret_key_t More...
union  ops_parser_content_union_t
 ops_parser_union_content_t More...
struct  ops_parser_content_t
 ops_parser_content_t More...
struct  ops_fingerprint_t
 ops_fingerprint_t More...

Defines

#define OPS_PTAG_ALWAYS_SET   0x80
 Packet Tag - Bit 7 Mask (this bit is always set).
#define OPS_PTAG_NEW_FORMAT   0x40
 Packet Tag - New Format Flag.
#define OPS_PTAG_OF_CONTENT_TAG_MASK   0x3c
 Old Packet Format: Mask for content tag.
#define OPS_PTAG_OF_CONTENT_TAG_SHIFT   2
 Old Packet Format: Offset for the content tag.
#define OPS_PTAG_OF_LENGTH_TYPE_MASK   0x03
 Old Packet Format: Mask for length type.
#define OPS_PTAG_NF_CONTENT_TAG_MASK   0x3f
 New Packet Format: Mask for content tag.
#define OPS_PTAG_NF_CONTENT_TAG_SHIFT   0
 New Packet Format: Offset for the content tag.
#define OPS_MAX_BLOCK_SIZE   16
#define OPS_MAX_KEY_SIZE   32
#define OPS_SALT_SIZE   8
#define OPS_CHECKHASH_SIZE   20
#define OPS_SHA1_HASH_SIZE   SHA_DIGEST_LENGTH
#define OPS_SHA256_HASH_SIZE   SHA256_DIGEST_LENGTH
#define OPS_MAX_HASH_SIZE   64
#define OPS_KEY_ID_SIZE   8

Enumerations

enum  ops_ptag_of_lt_t { OPS_PTAG_OF_LT_ONE_BYTE = 0x00, OPS_PTAG_OF_LT_TWO_BYTE = 0x01, OPS_PTAG_OF_LT_FOUR_BYTE = 0x02, OPS_PTAG_OF_LT_INDETERMINATE = 0x03 }
 Old Packet Format Lengths. More...
enum  ops_public_key_algorithm_t {
  OPS_PKA_RSA = 1, OPS_PKA_RSA_ENCRYPT_ONLY = 2, OPS_PKA_RSA_SIGN_ONLY = 3, OPS_PKA_ELGAMAL = 16,
  OPS_PKA_DSA = 17, OPS_PKA_RESERVED_ELLIPTIC_CURVE = 18, OPS_PKA_RESERVED_ECDSA = 19, OPS_PKA_ELGAMAL_ENCRYPT_OR_SIGN = 20,
  OPS_PKA_RESERVED_DH = 21, OPS_PKA_PRIVATE00 = 100, OPS_PKA_PRIVATE01 = 101, OPS_PKA_PRIVATE02 = 102,
  OPS_PKA_PRIVATE03 = 103, OPS_PKA_PRIVATE04 = 104, OPS_PKA_PRIVATE05 = 105, OPS_PKA_PRIVATE06 = 106,
  OPS_PKA_PRIVATE07 = 107, OPS_PKA_PRIVATE08 = 108, OPS_PKA_PRIVATE09 = 109, OPS_PKA_PRIVATE10 = 110
}
 Public Key Algorithm Numbers. More...
enum  ops_version_t { OPS_V2 = 2, OPS_V3 = 3, OPS_V4 = 4 }
 Version. More...
enum  ops_s2k_usage_t { OPS_S2KU_NONE = 0, OPS_S2KU_ENCRYPTED_AND_HASHED = 254, OPS_S2KU_ENCRYPTED = 255 }
 s2k_usage_t
enum  ops_s2k_specifier_t { OPS_S2KS_SIMPLE = 0, OPS_S2KS_SALTED = 1, OPS_S2KS_ITERATED_AND_SALTED = 3 }
 s2k_specifier_t
enum  ops_symmetric_algorithm_t {
  OPS_SA_PLAINTEXT = 0, OPS_SA_IDEA = 1, OPS_SA_TRIPLEDES = 2, OPS_SA_CAST5 = 3,
  OPS_SA_BLOWFISH = 4, OPS_SA_AES_128 = 7, OPS_SA_AES_192 = 8, OPS_SA_AES_256 = 9,
  OPS_SA_TWOFISH = 10, OPS_SA_CAMELLIA_128 = 11, OPS_SA_CAMELLIA_192 = 12, OPS_SA_CAMELLIA_256 = 13
}
 Symmetric Key Algorithm Numbers. More...
enum  ops_hash_algorithm_t {
  OPS_HASH_UNKNOWN = -1, OPS_HASH_MD5 = 1, OPS_HASH_SHA1 = 2, OPS_HASH_RIPEMD = 3,
  OPS_HASH_SHA256 = 8, OPS_HASH_SHA384 = 9, OPS_HASH_SHA512 = 10, OPS_HASH_SHA224 = 11
}
 Hashing Algorithm Numbers. More...
enum  ops_sig_type_t {
  OPS_SIG_BINARY = 0x00, OPS_SIG_TEXT = 0x01, OPS_SIG_STANDALONE = 0x02, OPS_CERT_GENERIC = 0x10,
  OPS_CERT_PERSONA = 0x11, OPS_CERT_CASUAL = 0x12, OPS_CERT_POSITIVE = 0x13, OPS_SIG_SUBKEY = 0x18,
  OPS_SIG_PRIMARY = 0x19, OPS_SIG_DIRECT = 0x1f, OPS_SIG_REV_KEY = 0x20, OPS_SIG_REV_SUBKEY = 0x28,
  OPS_SIG_REV_CERT = 0x30, OPS_SIG_TIMESTAMP = 0x40, OPS_SIG_3RD_PARTY = 0x50
}
 Signature Type. More...
enum  ops_compression_type_t { OPS_C_NONE = 0, OPS_C_ZIP = 1, OPS_C_ZLIB = 2, OPS_C_BZIP2 = 3 }
 Types of Compression.
enum  ops_literal_data_type_t {
  OPS_LDT_BINARY = 'b', OPS_LDT_TEXT = 't', OPS_LDT_UTF8 = 'u', OPS_LDT_LOCAL = 'l',
  OPS_LDT_LOCAL2 = '1'
}
 literal_data_type_t
enum  ops_se_ip_data_version_t { SE_IP_DATA_VERSION = 1 }
enum  ops_pk_session_key_version_t { OPS_PKSK_V3 = 3 }
enum  ops_se_ip_version_t { OPS_SE_IP_V1 = 1 }

Functions

void ops_init (void)
 Initialises OpenPGP::SDK.
void ops_finish (void)
 Closes down OpenPGP::SDK.
void ops_keyid (unsigned char keyid[OPS_KEY_ID_SIZE], const ops_public_key_t *key)
void ops_fingerprint (ops_fingerprint_t *fp, const ops_public_key_t *key)
 Calculate a public key fingerprint.
void ops_public_key_free (ops_public_key_t *key)
 Free allocated memory.
void ops_public_key_copy (ops_public_key_t *dst, const ops_public_key_t *src)
void ops_user_id_free (ops_user_id_t *id)
 Free allocated memory.
void ops_user_attribute_free (ops_user_attribute_t *att)
 Free allocated memory.
void ops_signature_free (ops_signature_t *sig)
 Free the memory used when parsing a signature.
void ops_trust_free (ops_trust_t *trust)
 Free the memory used when parsing this packet type.
void ops_ss_preferred_ska_free (ops_ss_preferred_ska_t *ss_preferred_ska)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_preferred_hash_free (ops_ss_preferred_hash_t *ss_preferred_hash)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_preferred_compression_free (ops_ss_preferred_compression_t *ss_preferred_compression)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_key_flags_free (ops_ss_key_flags_t *ss_key_flags)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_key_server_prefs_free (ops_ss_key_server_prefs_t *ss_key_server_prefs)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_features_free (ops_ss_features_t *ss_features)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_notation_data_free (ops_ss_notation_data_t *ss_notation_data)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_policy_url_free (ops_ss_policy_url_t *ss_policy_url)
 Free allocated memory.
void ops_ss_preferred_key_server_free (ops_ss_preferred_key_server_t *ss_preferred_key_server)
 Free allocated memory.
void ops_ss_regexp_free (ops_ss_regexp_t *ss_regexp)
 Free allocated memory.
void ops_ss_userdefined_free (ops_ss_userdefined_t *ss_userdefined)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_reserved_free (ops_ss_unknown_t *ss_unknown)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_revocation_reason_free (ops_ss_revocation_reason_t *ss_revocation_reason)
 Free the memory used when parsing this signature sub-packet type.
void ops_ss_signature_target_free (ops_ss_signature_target_t *ss_signature_target)
void ops_ss_embedded_signature_free (ops_ss_embedded_signature_t *ss_embedded_signature)
void ops_packet_free (ops_packet_t *packet)
 Free allocated memory.
void ops_parser_content_free (ops_parser_content_t *c)
 Free allocated memory.
void ops_secret_key_free (ops_secret_key_t *key)
 ops_secret_key_free() frees the memory associated with "key".
void ops_secret_key_copy (ops_secret_key_t *dst, const ops_secret_key_t *src)
void ops_pk_session_key_free (ops_pk_session_key_t *sk)
 Free allocated memory.


Detailed Description

packet related headers.


Define Documentation

#define OPS_PTAG_ALWAYS_SET   0x80
 

Packet Tag - Bit 7 Mask (this bit is always set).

The first byte of a packet is the "Packet Tag". It always has bit 7 set. This is the mask for it.

See also:
RFC4880 4.2

#define OPS_PTAG_NEW_FORMAT   0x40
 

Packet Tag - New Format Flag.

Bit 6 of the Packet Tag is the packet format indicator. If it is set, the new format is used, if cleared the old format is used.

See also:
RFC4880 4.2

#define OPS_PTAG_NF_CONTENT_TAG_MASK   0x3f
 

New Packet Format: Mask for content tag.

In the new packet format the 6 rightmost bits are the content tag. This is the mask to apply to the packet tag. Note that you need to shift by OPS_PTAG_NF_CONTENT_TAG_SHIFT bits.

See also:
RFC4880 4.2

#define OPS_PTAG_NF_CONTENT_TAG_SHIFT   0
 

New Packet Format: Offset for the content tag.

As described at OPS_PTAG_NF_CONTENT_TAG_MASK the content tag needs to be shifted after being masked out from the Packet Tag.

See also:
RFC4880 4.2

#define OPS_PTAG_OF_CONTENT_TAG_MASK   0x3c
 

Old Packet Format: Mask for content tag.

In the old packet format bits 5 to 2 (including) are the content tag. This is the mask to apply to the packet tag. Note that you need to shift by OPS_PTAG_OF_CONTENT_TAG_SHIFT bits.

See also:
RFC4880 4.2

#define OPS_PTAG_OF_CONTENT_TAG_SHIFT   2
 

Old Packet Format: Offset for the content tag.

As described at OPS_PTAG_OF_CONTENT_TAG_MASK the content tag needs to be shifted after being masked out from the Packet Tag.

See also:
RFC4880 4.2

#define OPS_PTAG_OF_LENGTH_TYPE_MASK   0x03
 

Old Packet Format: Mask for length type.

Bits 1 and 0 of the packet tag are the length type in the old packet format.

See ops_ptag_of_lt_t for the meaning of the values.

See also:
RFC4880 4.2


Enumeration Type Documentation

enum ops_hash_algorithm_t
 

Hashing Algorithm Numbers.

OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP.

This lists algorithm numbers for hash algorithms.

See also:
RFC4880 9.4
Enumerator:
OPS_HASH_UNKNOWN  used to indicate errors
OPS_HASH_MD5  MD5
OPS_HASH_SHA1  SHA-1
OPS_HASH_RIPEMD  RIPEMD160
OPS_HASH_SHA256  SHA256
OPS_HASH_SHA384  SHA384
OPS_HASH_SHA512  SHA512
OPS_HASH_SHA224  SHA224

enum ops_ptag_of_lt_t
 

Old Packet Format Lengths.

Defines the meanings of the 2 bits for length type in the old packet format.

See also:
RFC4880 4.2.1
Enumerator:
OPS_PTAG_OF_LT_ONE_BYTE  Packet has a 1 byte length - header is 2 bytes long.
OPS_PTAG_OF_LT_TWO_BYTE  Packet has a 2 byte length - header is 3 bytes long.
OPS_PTAG_OF_LT_FOUR_BYTE  Packet has a 4 byte length - header is 5 bytes long.
OPS_PTAG_OF_LT_INDETERMINATE  Packet has a indeterminate length.

enum ops_public_key_algorithm_t
 

Public Key Algorithm Numbers.

OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP.

This lists algorithm numbers for public key algorithms.

See also:
RFC4880 9.1
Enumerator:
OPS_PKA_RSA  RSA (Encrypt or Sign)
OPS_PKA_RSA_ENCRYPT_ONLY  RSA Encrypt-Only (deprecated -
See also:
RFC4880 13.5)
OPS_PKA_RSA_SIGN_ONLY  RSA Sign-Only (deprecated -
See also:
RFC4880 13.5)
OPS_PKA_ELGAMAL  Elgamal (Encrypt-Only)
OPS_PKA_DSA  DSA (Digital Signature Algorithm)
OPS_PKA_RESERVED_ELLIPTIC_CURVE  Reserved for Elliptic Curve
OPS_PKA_RESERVED_ECDSA  Reserved for ECDSA
OPS_PKA_ELGAMAL_ENCRYPT_OR_SIGN  Deprecated.
OPS_PKA_RESERVED_DH  Reserved for Diffie-Hellman (X9.42, as defined for IETF-S/MIME)
OPS_PKA_PRIVATE00  Private/Experimental Algorithm
OPS_PKA_PRIVATE01  Private/Experimental Algorithm
OPS_PKA_PRIVATE02  Private/Experimental Algorithm
OPS_PKA_PRIVATE03  Private/Experimental Algorithm
OPS_PKA_PRIVATE04  Private/Experimental Algorithm
OPS_PKA_PRIVATE05  Private/Experimental Algorithm
OPS_PKA_PRIVATE06  Private/Experimental Algorithm
OPS_PKA_PRIVATE07  Private/Experimental Algorithm
OPS_PKA_PRIVATE08  Private/Experimental Algorithm
OPS_PKA_PRIVATE09  Private/Experimental Algorithm
OPS_PKA_PRIVATE10  Private/Experimental Algorithm

enum ops_sig_type_t
 

Signature Type.

OpenPGP defines different signature types that allow giving different meanings to signatures. Signature types include 0x10 for generitc User ID certifications (used when Ben signs Weasel's key), Subkey binding signatures, document signatures, key revocations, etc.

Different types are used in different places, and most make only sense in their intended location (for instance a subkey binding has no place on a UserID).

See also:
RFC4880 5.2.1

enum ops_symmetric_algorithm_t
 

Symmetric Key Algorithm Numbers.

OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP.

This lists algorithm numbers for symmetric key algorithms.

See also:
RFC4880 9.2
Enumerator:
OPS_SA_PLAINTEXT  Plaintext or unencrypted data
OPS_SA_IDEA  IDEA
OPS_SA_TRIPLEDES  TripleDES
OPS_SA_CAST5  CAST5
OPS_SA_BLOWFISH  Blowfish
OPS_SA_AES_128  AES with 128-bit key (AES)
OPS_SA_AES_192  AES with 192-bit key
OPS_SA_AES_256  AES with 256-bit key
OPS_SA_TWOFISH  Twofish with 256-bit key (TWOFISH)
OPS_SA_CAMELLIA_128  Camellia with 128-bit key
OPS_SA_CAMELLIA_192  Camellia with 192-bit key
OPS_SA_CAMELLIA_256  Camellia with 256-bit key

enum ops_version_t
 

Version.

OpenPGP has two different protocol versions: version 3 and version 4.

See also:
RFC4880 5.2


Function Documentation

void ops_finish void   ) 
 

Closes down OpenPGP::SDK.

Close down OpenPGP:SDK, release any resources under the control of the library. No OpenPGP:SDK function other than ops_init() should be called after this function.

void ops_init void   ) 
 

Initialises OpenPGP::SDK.

To be called before any other OPS function.

Initialises OpenPGP::SDK and the underlying openssl library.


Generated on Sat May 25 00:00:02 2013 for OpenPGP:SDK by  doxygen 1.4.6