Package conary :: Package lib :: Module openpgpfile
[hide private]
[frames] | no frames]

Module openpgpfile

source code

Classes [hide private]
  PGPError
  InvalidPacketError
  KeyringError
  MalformedKeyRing
  UnsupportedEncryptionAlgorithm
  UnsupportedHashAlgorithm
  IncompatibleKey
  InvalidKey
  KeyNotFound
  BadPassPhrase
  BadSelfSignature
  InvalidBodyError
  ShortReadError
  MergeError
  SignatureError
  CRC24
  PacketTypeDispatcher
  PGP_Message
  PGP_PacketFromStream
  PGP_BasePacket
  PGP_Packet
Anonymous PGP packet
  PGP_BaseKeySig
Base class for keys and signatures
  PGP_Signature
  PGP_UserID
  PGP_UserAttribute
  PGP_Key
  PGP_MainKey
  PGP_PublicAnyKey
  PGP_PublicKey
  PGP_SecretAnyKey
  PGP_SecretKey
  PGP_SubKey
  PGP_PublicSubKey
  PGP_SecretSubKey
  PGP_Trust
  TimestampPacketDispatcher
  TimestampPacketDatabase
  KeyTimestampPacket
This packet is associated with a particular (main) key in order to track its "freshness".
  PublicKeyring
A representation of a public keyring.
  klass
Functions [hide private]
 
getKeyId(keyRing) source code
 
getKeyFromString(keyId, data) source code
 
seekKeyById(keyId, keyRing) source code
stream
exportKey(keyId, keyRing, armored=False)
Export the key from the keyring, performing the necessary locking
source code
 
armorKeyData(keyData, stream)
Write the Radix-64 encoded version of the key data.
source code
 
verifySelfSignatures(keyId, stream) source code
 
fingerprintToInternalKeyId(fingerprint) source code
 
binSeqToString(sequence)
sequence is a sequence of unsigned chars.
source code
 
stringToAscii(sequence)
sequence is a sequence of characters.
source code
 
simpleS2K(passPhrase, hash, keySize) source code
 
saltedS2K(passPhrase, hash, keySize, salt) source code
 
iteratedS2K(passPhrase, hash, keySize, salt, count) source code
 
getUserIdsFromString(keyId, data) source code
 
getFingerprint(keyId, keyFile='') source code
 
addKeys(keys, fpath)
Add keys to the file
source code
 
addKeyTimestampPackets(pkts, fpath)
Add key timestamp packets to the file
source code
 
addPackets(pkts, fpath, pktIdFunc, messageFactory, streamIterFunc)
Add packets to the file.
source code
 
verifyRFC2440Checksum(data) source code
 
verifySHAChecksum(data) source code
 
xorStr(str1, str2) source code
 
countKeys(keyRing) source code
 
getFingerprints(keyRing) source code
PGP_Signature
readSignature(fileobj)
Read a signature packet from a stream.
source code
bool
parseAsciiArmor(asciiData, dest)
Parse an armored (Radix-64 encoded) PGP message.
source code
string or None
parseAsciiArmorKey(asciiData)
Parse an armored (Radix-64 encoded) PGP message.
source code
 
_crc24(stream) source code
 
crc24(stream) source code
 
crc24base64(stream) source code
 
newKeyFromString(data)
Create a new (main) key from the data Returns None if a key was not found
source code
 
newKeyFromStream(stream)
Create a new (main) key from the stream Returns None if a key was not found
source code
 
_mergeSignatures(*sources) source code
 
len2bytes(v1, v2)
Return the packet body length when represented on 2 bytes
source code
 
len4bytes(v1, v2, v3, v4)
Return the packet body length when represented on 4 bytes
source code
 
len2ToBytes(v) source code
 
len4ToBytes(v) source code
 
int2FromBytes(v1, v2) source code
 
int4FromBytes(v1, v2, v3, v4) source code
 
int2ToBytes(v) source code
 
int4ToBytes(v) source code
 
num_gcd(a, b) source code
 
num_bitLen(a) source code
 
num_getRelPrime(q) source code
Variables [hide private]
  PK_ALGO_RSA = 1
  PK_ALGO_RSA_ENCRYPT_ONLY = 2
  PK_ALGO_RSA_SIGN_ONLY = 3
  PK_ALGO_ELGAMAL_ENCRYPT_ONLY = 16
  PK_ALGO_DSA = 17
  PK_ALGO_ELLIPTIC_CURVE = 18
  PK_ALGO_ECDSA = 19
  PK_ALGO_ELGAMAL = 20
  PK_ALGO_ALL_RSA = (1, 2, 3)
  PK_ALGO_ALL_ELGAMAL = (16, 20)
  PKT_RESERVED = 0
  PKT_PUB_SESSION_KEY = 1
  PKT_SIG = 2
  PKT_SYM_SESSION_KEY = 3
  PKT_ONE_PASS_SIG = 4
  PKT_SECRET_KEY = 5
  PKT_PUBLIC_KEY = 6
  PKT_SECRET_SUBKEY = 7
  PKT_COMPRESSED_DATA = 8
  PKT_SYM_ENCRYPTED_DATA = 9
  PKT_MARKER = 10
  PKT_LITERAL_DATA = 11
  PKT_TRUST = 12
  PKT_USERID = 13
  PKT_PUBLIC_SUBKEY = 14
  PKT_USER_ATTRIBUTE = 17
  PKT_DATA_PACKET = 18
  PKT_MOD_DETECTION = 19
  PKT_PRIVATE1 = 60
  PKT_PRIVATE2 = 61
  PKT_PRIVATE3 = 62
  PKT_PRIVATE4 = 63
  PKT_ALL_SECRET = (5, 7)
  PKT_ALL_PUBLIC = (6, 14)
  PKT_ALL_KEYS = (5, 7, 6, 14)
  PKT_MAIN_KEYS = (5, 6)
  PKT_SUB_KEYS = (7, 14)
  PKT_ALL_USER = set([13, 17])
  SIG_TYPE_BINARY_DOC = 0
  SIG_TYPE_TEXT_DOC = 1
  SIG_TYPE_STANDALONE = 2
  SIG_TYPE_CERT_0 = 16
  SIG_TYPE_CERT_1 = 17
  SIG_TYPE_CERT_2 = 18
  SIG_TYPE_CERT_3 = 19
  SIG_TYPE_SUBKEY_BIND = 24
  SIG_TYPE_PRKEY_BIND = 25
  SIG_TYPE_DIRECT_KEY = 31
  SIG_TYPE_KEY_REVOC = 32
  SIG_TYPE_SUBKEY_REVOC = 40
  SIG_TYPE_CERT_REVOC = 48
  SIG_TYPE_TIMESTAMP = 64
  SIG_TYPE_THIRD_PARTY_CONFIRM = 80
  SIG_CERTS = (16, 17, 18, 19)
  SIG_KEY_REVOCS = (32, 40)
  SIG_SUBPKT_CREATION = 2
  SIG_SUBPKT_SIG_EXPIRE = 3
  SIG_SUBPKT_EXPORTABLE = 4
  SIG_SUBPKT_TRUST = 5
  SIG_SUBPKT_REGEX = 6
  SIG_SUBPKT_REVOCABLE = 7
  SIG_SUBPKT_KEY_EXPIRE = 9
  SIG_SUBPKT_PLACEHOLDER = 10
  SIG_SUBPKT_PREF_SYM_ALGS = 11
  SIG_SUBPKT_REVOC_KEY = 12
  SIG_SUBPKT_ISSUER_KEYID = 16
  SIG_SUBPKT_NOTATION_DATA = 20
  SIG_SUBPKT_PREF_HASH_ALGS = 21
  SIG_SUBPKT_PREF_COMP_ALGS = 22
  SIG_SUBPKT_KEYSRVR_PREFS = 23
  SIG_SUBPKT_PREF_KEYSRVR = 24
  SIG_SUBPKT_PRIM_UID = 25
  SIG_SUBPKT_POLICY_URL = 26
  SIG_SUBPKT_KEY_FLAGS = 27
  SIG_SUBPKT_SIGNERS_UID = 28
  SIG_SUBPKT_REVOC_REASON = 29
  SIG_SUBPKT_FEATURES = 30
  SIG_SUBPKT_SIG_TARGET = 31
  SIG_SUBPKT_EMBEDDED_SIG = 32
  SIG_SUBPKT_INTERNAL_0 = 100
  SIG_SUBPKT_INTERNAL_1 = 101
  SIG_SUBPKT_INTERNAL_2 = 102
  SIG_SUBPKT_INTERNAL_3 = 103
  SIG_SUBPKT_INTERNAL_4 = 104
  SIG_SUBPKT_INTERNAL_5 = 105
  SIG_SUBPKT_INTERNAL_6 = 106
  SIG_SUBPKT_INTERNAL_7 = 107
  SIG_SUBPKT_INTERNAL_8 = 108
  SIG_SUBPKT_INTERNAL_9 = 109
  SIG_SUBPKT_INTERNAL_A = 110
  ENCRYPTION_TYPE_UNENCRYPTED = 0
  ENCRYPTION_TYPE_S2K_SPECIFIED = 255
  ENCRYPTION_TYPE_SHA1_CHECK = 254
  OLD_PKT_LEN_ONE_OCTET = 0
  OLD_PKT_LEN_TWO_OCTET = 1
  OLD_PKT_LEN_FOUR_OCTET = 2
  USR_ATTR_SUBPKT_IMG = 1
  TRUST_UNTRUSTED = 0
  TRUST_MARGINAL = 4
  TRUST_FULL = 5
  TRUST_ULTIMATE = 6
  TRUST_TRUSTED = 120
  TRP_VERSION = '\x01'
  TRP_KEY = '\x0c'
  TRP_USERID = '\r'
  TRUST_PACKET_LENGTH = 40
  SEEK_SET = 0
  SEEK_CUR = 1
  SEEK_END = 2
Function Details [hide private]

exportKey(keyId, keyRing, armored=False)

source code 
Export the key from the keyring, performing the necessary locking
Parameters:
  • keyId (str) - the key ID
  • keyRing (file or path) - the keyring from where the key is to be extracted
  • armor (bool) - If True, exports the key in a Radix-64 encoding (armor)
Returns: stream
the key in a stream

armorKeyData(keyData, stream)

source code 
Write the Radix-64 encoded version of the key data.
Parameters:
  • keyData - key data

binSeqToString(sequence)

source code 
sequence is a sequence of unsigned chars. Return the string with a corresponding char for each item

stringToAscii(sequence)

source code 
sequence is a sequence of characters. Return the string with the hex representation for each character

addPackets(pkts, fpath, pktIdFunc, messageFactory, streamIterFunc)

source code 
Add packets to the file. Return the packet IDs for the added packets

readSignature(fileobj)

source code 
Read a signature packet from a stream.
Parameters:
  • fileobj (stream) - a stream to read the key from
Returns: PGP_Signature
the Signature packet
Raises:

parseAsciiArmor(asciiData, dest)

source code 
Parse an armored (Radix-64 encoded) PGP message.
Parameters:
  • asciiData (string or stream) - the Radix-64 encoded PGP message
  • dest (stream) - a stream to deposit the message into
Returns: bool
the unencoded PGP messsage, or None if the encoded message was incorrect
Raises:
  • PGPError - if the CRC does not match the message

parseAsciiArmorKey(asciiData)

source code 
Parse an armored (Radix-64 encoded) PGP message.
Parameters:
  • asciiData (string or stream) - the Radix-64 encoded PGP message
Returns: string or None
the unencoded PGP messsage, or None if the encoded message was incorrect
Raises:
  • PGPError - if the CRC does not match the message