cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
Macros | Enumerations | Functions | Variables
pgp.h File Reference
#include "io/stream.h"

Go to the source code of this file.

Macros

#define PGP_SUBPACKET_TIME   2 /* Signing time */
 
#define PGP_SUBPACKET_KEYID   16 /* Key ID */
 
#define PGP_SUBPACKET_TYPEANDVALUE   20 /* Type-and-value pairs */
 
#define PGP_SUBPACKET_LAST   29 /* Last valid subpacket type */
 
#define PGP_PACKET_SIGNATURE_SPECIAL   1000
 
#define PGP_CTB   0x80 /* PGP 2.x CTB template */
 
#define PGP_CTB_OPENPGP   0xC0 /* OpenPGP CTB template */
 
#define PGP_CTB_COMPRESSED   0xA3 /* Compressed indef-length data */
 
#define pgpIsCTB(ctb)   ( ( ctb ) & PGP_CTB )
 
#define pgpGetPacketVersion(ctb)
 
#define pgpGetPacketType(ctb)
 
#define pgpIsReservedPacket(type)   ( ( type ) >= 60 && ( type ) <= 63 )
 
#define PGP_VERSION_2   2 /* Version number byte for PGP 2.0 */
 
#define PGP_VERSION_3   3 /* Version number byte for legal-kludged PGP 2.0 */
 
#define PGP_VERSION_OPENPGP   4 /* Version number for OpenPGP */
 
#define PGP_ALGO_RSA   1 /* RSA */
 
#define PGP_ALGO_RSA_ENCRYPT   2 /* RSA encrypt-only */
 
#define PGP_ALGO_RSA_SIGN   3 /* RSA sign-only */
 
#define PGP_ALGO_ELGAMAL   16 /* ElGamal */
 
#define PGP_ALGO_DSA   17 /* DSA */
 
#define PGP_ALGO_ECC_RES   18 /* Reserved for "ECC" */
 
#define PGP_ALGO_ECDSA_RES   19 /* Reserved for ECDSA */
 
#define PGP_ALGO_PKC_RES1   20 /* Reserved, formerly Elgamal sign */
 
#define PGP_ALGO_PKC_RES2   21 /* Reserved for "X9.42" */
 
#define PGP_ALGO_NONE   0 /* No CKE algorithm */
 
#define PGP_ALGO_IDEA   1 /* IDEA */
 
#define PGP_ALGO_3DES   2 /* Triple DES */
 
#define PGP_ALGO_CAST5   3 /* CAST-128 */
 
#define PGP_ALGO_BLOWFISH   4 /* Blowfish */
 
#define PGP_ALGO_ENC_RES1   5 /* Reserved, formerly Safer-SK */
 
#define PGP_ALGO_ENC_RES2   6 /* Reserved */
 
#define PGP_ALGO_AES_128   7 /* AES with 128-bit key */
 
#define PGP_ALGO_AES_192   8 /* AES with 192-bit key */
 
#define PGP_ALGO_AES_256   9 /* AES with 256-bit key */
 
#define PGP_ALGO_TWOFISH   10 /* Twofish */
 
#define PGP_ALGO_MD5   1 /* MD5 */
 
#define PGP_ALGO_SHA   2 /* SHA-1 */
 
#define PGP_ALGO_RIPEMD160   3 /* RIPEMD-160 */
 
#define PGP_ALGO_HASH_RES1   4 /* Reserved */
 
#define PGP_ALGO_HASH_RES2   5 /* Reserved, formerly MD2 */
 
#define PGP_ALGO_HASH_RES3   6 /* Reserved, formerly Tiger/192 */
 
#define PGP_ALGO_HASH_RES4   7 /* Reserved, formerly Haval */
 
#define PGP_ALGO_SHA2_256   8 /* SHA-2 256bit */
 
#define PGP_ALGO_SHA2_384   9 /* SHA-2 384bit */
 
#define PGP_ALGO_SHA2_512   10 /* SHA-2 512bit */
 
#define PGP_ALGO_SHA2_224   11 /* SHA-2 224bit */
 
#define PGP_ALGO_ZIP   1 /* ZIP compression */
 
#define PGP_ALGO_ZLIB   2 /* zlib compression */
 
#define PGP_ALGO_BZIP2   3 /* Bzip2 compression */
 
#define PGP_ALGO_LAST   PGP_ALGO_DSA
 
#define PGP_S2K   0xFF /* Standard S2K */
 
#define PGP_S2K_HASHED   0xFE /* S2K with hashed key */
 
#define PGP_SIG_NONE   0x00 /* Same as PGP_SIG_DATA, for range chk.*/
 
#define PGP_SIG_DATA   0x00 /* Binary data */
 
#define PGP_SIG_TEXT   0x01 /* Canonicalised text data */
 
#define PGP_SIG_STANDALONE   0x02 /* Unknown purpose, from RFC 4880 */
 
#define PGP_SIG_CERT0   0x10 /* Key certificate, unknown assurance */
 
#define PGP_SIG_CERT1   0x11 /* Key certificate, no assurance */
 
#define PGP_SIG_CERT2   0x12 /* Key certificate, casual assurance */
 
#define PGP_SIG_CERT3   0x13 /* Key certificate, strong assurance */
 
#define PGP_SIG_SUBKEY   0x18 /* Subkey binding signature */
 
#define PGP_SIG_PRIMKEY   0x19 /* Primary key binding signature */
 
#define PGP_SIG_DIRECTKEY   0x1F /* Key self-signature */
 
#define PGP_SIG_KEYREV   0x20 /* Key revocation */
 
#define PGP_SIG_SUBKEYREV   0x28 /* Subkey revocation */
 
#define PGP_SIG_CRL   0x30 /* Certificate revocation */
 
#define PGP_SIG_TS   0x40 /* Timestamp signature */
 
#define PGP_SIG_COUNTERSIG   0x50 /* Third-party countersignature */
 
#define PGP_SIG_LAST   0x51 /* Last possible signature type */
 
#define PGP_VERSION_SIZE   1
 
#define PGP_ALGOID_SIZE   1
 
#define PGP_MAX_USERIDSIZE   256
 
#define PGP_SALTSIZE   8
 
#define PGP_ITERATIONS   1024
 
#define PGP_MIN_HEADER_SIZE   2 /* CTB + length */
 
#define PGP_MAX_HEADER_SIZE   6 /* CTB + 0xFF + 4-byte length */
 
#define PGP_DATA_HEADER   "b\x00\x00\x00\x00\x00"
 
#define PGP_DATA_HEADER_SIZE   ( 1 + 1 + 4 )
 
#define PGP_MDC_PACKET_SIZE   ( 1 + 1 + 20 ) /* Size of MDC packet */
 

Enumerations

enum  PGP_PACKET_TYPE {
  PGP_PACKET_NONE, PGP_PACKET_PKE, PGP_PACKET_SIGNATURE, PGP_PACKET_SKE,
  PGP_PACKET_SIGNATURE_ONEPASS, PGP_PACKET_SECKEY, PGP_PACKET_PUBKEY, PGP_PACKET_SECKEY_SUB,
  PGP_PACKET_COPR, PGP_PACKET_ENCR, PGP_PACKET_MARKER, PGP_PACKET_DATA,
  PGP_PACKET_TRUST, PGP_PACKET_USERID, PGP_PACKET_PUBKEY_SUB, PGP_PACKET_DUMMY1,
  PGP_PACKET_DUMMY2, PGP_PACKET_USERATTR, PGP_PACKET_ENCR_MDC, PGP_PACKET_MDC,
  PGP_PACKET_LAST
}
 
enum  PGP_ALGOCLASS_TYPE {
  PGP_ALGOCLASS_NONE, PGP_ALGOCLASS_CRYPT, PGP_ALGOCLASS_PWCRYPT, PGP_ALGOCLASS_PKCCRYPT,
  PGP_ALGOCLASS_SIGN, PGP_ALGOCLASS_HASH, PGP_ALGOCLASS_LAST
}
 

Functions

CHECK_RETVAL STDC_NONNULL_ARG ((3)) int pgpToCryptlibAlgo(IN_RANGE(PGP_ALGO_NONE
 
CHECK_RETVAL const int IN_ENUM (PGP_ALGOCLASS) const PGP_ALGOCLASS_TYPE pgpAlgoClass
 
CHECK_RETVAL STDC_NONNULL_ARG ((2)) int cryptlibToPgpAlgo(IN_ALGO const CRYPT_ALGO_TYPE cryptlibAlgo
 
CHECK_RETVAL OUT_RANGE (PGP_ALGO_NONE, PGP_ALGO_LAST) int *pgpAlgo)
 
CHECK_RETVAL STDC_NONNULL_ARG ((1, 2)) int readPgpAlgo(INOUT STREAM *stream
 
CHECK_RETVAL
IN_LENGTH_SHORT_OPT const int 
IN_BUFFER (passwordLength) const char *password
 
CHECK_RETVAL
IN_LENGTH_SHORT_OPT const int
IN_LENGTH_SHORT const int
IN_ALGO const CRYPT_ALGO_TYPE
const BYTE 
IN_RANGE (0, CRYPT_MAX_HASHSIZE) const int saltSize
 
CHECK_RETVAL INOUT_BUFFER_FIXED (ivInfoSize) BYTE *ivInfo
 
CHECK_RETVAL IN_RANGE (8+2, CRYPT_MAX_IVSIZE+2) const int ivInfoSize
 

Variables

CHECK_RETVAL const int pgpAlgo
 
CHECK_RETVAL const int
OUT_ALGO_Z CRYPT_ALGO_TYPE
cryptAlgo
 
CHECK_RETVAL
IN_LENGTH_SHORT_OPT const int 
optKeyLength
 
CHECK_RETVAL
IN_LENGTH_SHORT_OPT const int
IN_LENGTH_SHORT const int 
passwordLength
 
CHECK_RETVAL
IN_LENGTH_SHORT_OPT const int
IN_LENGTH_SHORT const int
IN_ALGO const CRYPT_ALGO_TYPE 
hashAlgo
 
CHECK_RETVAL
IN_LENGTH_SHORT_OPT const int
IN_LENGTH_SHORT const int
IN_ALGO const CRYPT_ALGO_TYPE
const BYTE
salt
 
CHECK_RETVAL
IN_LENGTH_SHORT_OPT const int
IN_LENGTH_SHORT const int
IN_ALGO const CRYPT_ALGO_TYPE
const BYTE IN_INT const int 
iterations
 
CHECK_RETVAL IN_LENGTH_IV const int ivDataSize
 
CHECK_RETVAL IN_LENGTH_IV
const int const BOOLEAN 
isEncrypt
 
CHECK_RETVAL IN_LENGTH_IV
const int const BOOLEAN const
BOOLEAN 
resyncIV
 

Macro Definition Documentation

#define PGP_ALGO_3DES   2 /* Triple DES */

Definition at line 115 of file pgp.h.

#define PGP_ALGO_AES_128   7 /* AES with 128-bit key */

Definition at line 120 of file pgp.h.

#define PGP_ALGO_AES_192   8 /* AES with 192-bit key */

Definition at line 121 of file pgp.h.

#define PGP_ALGO_AES_256   9 /* AES with 256-bit key */

Definition at line 122 of file pgp.h.

#define PGP_ALGO_BLOWFISH   4 /* Blowfish */

Definition at line 117 of file pgp.h.

#define PGP_ALGO_BZIP2   3 /* Bzip2 compression */

Definition at line 143 of file pgp.h.

#define PGP_ALGO_CAST5   3 /* CAST-128 */

Definition at line 116 of file pgp.h.

#define PGP_ALGO_DSA   17 /* DSA */

Definition at line 105 of file pgp.h.

#define PGP_ALGO_ECC_RES   18 /* Reserved for "ECC" */

Definition at line 106 of file pgp.h.

#define PGP_ALGO_ECDSA_RES   19 /* Reserved for ECDSA */

Definition at line 107 of file pgp.h.

#define PGP_ALGO_ELGAMAL   16 /* ElGamal */

Definition at line 104 of file pgp.h.

#define PGP_ALGO_ENC_RES1   5 /* Reserved, formerly Safer-SK */

Definition at line 118 of file pgp.h.

#define PGP_ALGO_ENC_RES2   6 /* Reserved */

Definition at line 119 of file pgp.h.

#define PGP_ALGO_HASH_RES1   4 /* Reserved */

Definition at line 130 of file pgp.h.

#define PGP_ALGO_HASH_RES2   5 /* Reserved, formerly MD2 */

Definition at line 131 of file pgp.h.

#define PGP_ALGO_HASH_RES3   6 /* Reserved, formerly Tiger/192 */

Definition at line 132 of file pgp.h.

#define PGP_ALGO_HASH_RES4   7 /* Reserved, formerly Haval */

Definition at line 133 of file pgp.h.

#define PGP_ALGO_IDEA   1 /* IDEA */

Definition at line 114 of file pgp.h.

#define PGP_ALGO_LAST   PGP_ALGO_DSA

Definition at line 147 of file pgp.h.

#define PGP_ALGO_MD5   1 /* MD5 */

Definition at line 127 of file pgp.h.

#define PGP_ALGO_NONE   0 /* No CKE algorithm */

Definition at line 113 of file pgp.h.

#define PGP_ALGO_PKC_RES1   20 /* Reserved, formerly Elgamal sign */

Definition at line 108 of file pgp.h.

#define PGP_ALGO_PKC_RES2   21 /* Reserved for "X9.42" */

Definition at line 109 of file pgp.h.

#define PGP_ALGO_RIPEMD160   3 /* RIPEMD-160 */

Definition at line 129 of file pgp.h.

#define PGP_ALGO_RSA   1 /* RSA */

Definition at line 101 of file pgp.h.

#define PGP_ALGO_RSA_ENCRYPT   2 /* RSA encrypt-only */

Definition at line 102 of file pgp.h.

#define PGP_ALGO_RSA_SIGN   3 /* RSA sign-only */

Definition at line 103 of file pgp.h.

#define PGP_ALGO_SHA   2 /* SHA-1 */

Definition at line 128 of file pgp.h.

#define PGP_ALGO_SHA2_224   11 /* SHA-2 224bit */

Definition at line 137 of file pgp.h.

#define PGP_ALGO_SHA2_256   8 /* SHA-2 256bit */

Definition at line 134 of file pgp.h.

#define PGP_ALGO_SHA2_384   9 /* SHA-2 384bit */

Definition at line 135 of file pgp.h.

#define PGP_ALGO_SHA2_512   10 /* SHA-2 512bit */

Definition at line 136 of file pgp.h.

#define PGP_ALGO_TWOFISH   10 /* Twofish */

Definition at line 123 of file pgp.h.

#define PGP_ALGO_ZIP   1 /* ZIP compression */

Definition at line 141 of file pgp.h.

#define PGP_ALGO_ZLIB   2 /* zlib compression */

Definition at line 142 of file pgp.h.

#define PGP_ALGOID_SIZE   1

Definition at line 177 of file pgp.h.

#define PGP_CTB   0x80 /* PGP 2.x CTB template */

Definition at line 78 of file pgp.h.

#define PGP_CTB_COMPRESSED   0xA3 /* Compressed indef-length data */

Definition at line 80 of file pgp.h.

#define PGP_CTB_OPENPGP   0xC0 /* OpenPGP CTB template */

Definition at line 79 of file pgp.h.

#define PGP_DATA_HEADER   "b\x00\x00\x00\x00\x00"

Definition at line 198 of file pgp.h.

#define PGP_DATA_HEADER_SIZE   ( 1 + 1 + 4 )

Definition at line 199 of file pgp.h.

#define PGP_ITERATIONS   1024

Definition at line 191 of file pgp.h.

#define PGP_MAX_HEADER_SIZE   6 /* CTB + 0xFF + 4-byte length */

Definition at line 197 of file pgp.h.

#define PGP_MAX_USERIDSIZE   256

Definition at line 182 of file pgp.h.

#define PGP_MDC_PACKET_SIZE   ( 1 + 1 + 20 ) /* Size of MDC packet */

Definition at line 200 of file pgp.h.

#define PGP_MIN_HEADER_SIZE   2 /* CTB + length */

Definition at line 196 of file pgp.h.

#define PGP_PACKET_SIGNATURE_SPECIAL   1000

Definition at line 59 of file pgp.h.

#define PGP_S2K   0xFF /* Standard S2K */

Definition at line 151 of file pgp.h.

#define PGP_S2K_HASHED   0xFE /* S2K with hashed key */

Definition at line 152 of file pgp.h.

#define PGP_SALTSIZE   8

Definition at line 190 of file pgp.h.

#define PGP_SIG_CERT0   0x10 /* Key certificate, unknown assurance */

Definition at line 160 of file pgp.h.

#define PGP_SIG_CERT1   0x11 /* Key certificate, no assurance */

Definition at line 161 of file pgp.h.

#define PGP_SIG_CERT2   0x12 /* Key certificate, casual assurance */

Definition at line 162 of file pgp.h.

#define PGP_SIG_CERT3   0x13 /* Key certificate, strong assurance */

Definition at line 163 of file pgp.h.

#define PGP_SIG_COUNTERSIG   0x50 /* Third-party countersignature */

Definition at line 171 of file pgp.h.

#define PGP_SIG_CRL   0x30 /* Certificate revocation */

Definition at line 169 of file pgp.h.

#define PGP_SIG_DATA   0x00 /* Binary data */

Definition at line 157 of file pgp.h.

#define PGP_SIG_DIRECTKEY   0x1F /* Key self-signature */

Definition at line 166 of file pgp.h.

#define PGP_SIG_KEYREV   0x20 /* Key revocation */

Definition at line 167 of file pgp.h.

#define PGP_SIG_LAST   0x51 /* Last possible signature type */

Definition at line 172 of file pgp.h.

#define PGP_SIG_NONE   0x00 /* Same as PGP_SIG_DATA, for range chk.*/

Definition at line 156 of file pgp.h.

#define PGP_SIG_PRIMKEY   0x19 /* Primary key binding signature */

Definition at line 165 of file pgp.h.

#define PGP_SIG_STANDALONE   0x02 /* Unknown purpose, from RFC 4880 */

Definition at line 159 of file pgp.h.

#define PGP_SIG_SUBKEY   0x18 /* Subkey binding signature */

Definition at line 164 of file pgp.h.

#define PGP_SIG_SUBKEYREV   0x28 /* Subkey revocation */

Definition at line 168 of file pgp.h.

#define PGP_SIG_TEXT   0x01 /* Canonicalised text data */

Definition at line 158 of file pgp.h.

#define PGP_SIG_TS   0x40 /* Timestamp signature */

Definition at line 170 of file pgp.h.

#define PGP_SUBPACKET_KEYID   16 /* Key ID */

Definition at line 48 of file pgp.h.

#define PGP_SUBPACKET_LAST   29 /* Last valid subpacket type */

Definition at line 50 of file pgp.h.

#define PGP_SUBPACKET_TIME   2 /* Signing time */

Definition at line 47 of file pgp.h.

#define PGP_SUBPACKET_TYPEANDVALUE   20 /* Type-and-value pairs */

Definition at line 49 of file pgp.h.

#define PGP_VERSION_2   2 /* Version number byte for PGP 2.0 */

Definition at line 95 of file pgp.h.

#define PGP_VERSION_3   3 /* Version number byte for legal-kludged PGP 2.0 */

Definition at line 96 of file pgp.h.

#define PGP_VERSION_OPENPGP   4 /* Version number for OpenPGP */

Definition at line 97 of file pgp.h.

#define PGP_VERSION_SIZE   1

Definition at line 176 of file pgp.h.

#define pgpGetPacketType (   ctb)
Value:
( ( ( ( ctb ) & PGP_CTB_OPENPGP ) == PGP_CTB_OPENPGP ) ? \
( ( ctb ) & 0x3F ) : ( ( ( ctb ) >> 2 ) & 0x0F ) )

Definition at line 88 of file pgp.h.

#define pgpGetPacketVersion (   ctb)
Value:

Definition at line 85 of file pgp.h.

#define pgpIsCTB (   ctb)    ( ( ctb ) & PGP_CTB )

Definition at line 84 of file pgp.h.

#define pgpIsReservedPacket (   type)    ( ( type ) >= 60 && ( type ) <= 63 )

Definition at line 91 of file pgp.h.

Enumeration Type Documentation

Enumerator:
PGP_ALGOCLASS_NONE 
PGP_ALGOCLASS_CRYPT 
PGP_ALGOCLASS_PWCRYPT 
PGP_ALGOCLASS_PKCCRYPT 
PGP_ALGOCLASS_SIGN 
PGP_ALGOCLASS_HASH 
PGP_ALGOCLASS_LAST 

Definition at line 208 of file pgp.h.

Enumerator:
PGP_PACKET_NONE 
PGP_PACKET_PKE 
PGP_PACKET_SIGNATURE 
PGP_PACKET_SKE 
PGP_PACKET_SIGNATURE_ONEPASS 
PGP_PACKET_SECKEY 
PGP_PACKET_PUBKEY 
PGP_PACKET_SECKEY_SUB 
PGP_PACKET_COPR 
PGP_PACKET_ENCR 
PGP_PACKET_MARKER 
PGP_PACKET_DATA 
PGP_PACKET_TRUST 
PGP_PACKET_USERID 
PGP_PACKET_PUBKEY_SUB 
PGP_PACKET_DUMMY1 
PGP_PACKET_DUMMY2 
PGP_PACKET_USERATTR 
PGP_PACKET_ENCR_MDC 
PGP_PACKET_MDC 
PGP_PACKET_LAST 

Definition at line 22 of file pgp.h.

Function Documentation

CHECK_RETVAL const int IN_ENUM ( PGP_ALGOCLASS  ) const
CHECK_RETVAL IN_RANGE ( 8+  2,
CRYPT_MAX_IVSIZE 2 
) const
CHECK_RETVAL INOUT_BUFFER_FIXED ( ivInfoSize  )
CHECK_RETVAL OUT_RANGE ( PGP_ALGO_NONE  ,
PGP_ALGO_LAST   
)
CHECK_RETVAL STDC_NONNULL_ARG ( (3)  )
CHECK_RETVAL STDC_NONNULL_ARG ( (2)  ) const
CHECK_RETVAL STDC_NONNULL_ARG ( (1, 2)  )

Variable Documentation

Definition at line 223 of file pgp.h.

Definition at line 241 of file pgp.h.

Definition at line 254 of file pgp.h.

Definition at line 247 of file pgp.h.

Definition at line 254 of file pgp.h.

Definition at line 238 of file pgp.h.

Definition at line 241 of file pgp.h.

CHECK_RETVAL const int pgpAlgo

Definition at line 220 of file pgp.h.

Definition at line 254 of file pgp.h.

Definition at line 241 of file pgp.h.