MCPcopy Create free account
hub / github.com/SecurityInnovation/PGPy / PKESessionKeyV3

Class PKESessionKeyV3

pgpy/packet/packets.py:94–284  ·  view source on GitHub ↗

5.1. Public-Key Encrypted Session Key Packets (Tag 1) A Public-Key Encrypted Session Key packet holds the session key used to encrypt a message. Zero or more Public-Key Encrypted Session Key packets and/or Symmetric-Key Encrypted Session Key packets may precede a Symmetricall

Source from the content-addressed store, hash-verified

92
93
94class PKESessionKeyV3(PKESessionKey):
95 """
96 5.1. Public-Key Encrypted Session Key Packets (Tag 1)
97
98 A Public-Key Encrypted Session Key packet holds the session key used
99 to encrypt a message. Zero or more Public-Key Encrypted Session Key
100 packets and/or Symmetric-Key Encrypted Session Key packets may
101 precede a Symmetrically Encrypted Data Packet, which holds an
102 encrypted message. The message is encrypted with the session key,
103 and the session key is itself encrypted and stored in the Encrypted
104 Session Key packet(s). The Symmetrically Encrypted Data Packet is
105 preceded by one Public-Key Encrypted Session Key packet for each
106 OpenPGP key to which the message is encrypted. The recipient of the
107 message finds a session key that is encrypted to their public key,
108 decrypts the session key, and then uses the session key to decrypt
109 the message.
110
111 The body of this packet consists of:
112
113 - A one-octet number giving the version number of the packet type.
114 The currently defined value for packet version is 3.
115
116 - An eight-octet number that gives the Key ID of the public key to
117 which the session key is encrypted. If the session key is
118 encrypted to a subkey, then the Key ID of this subkey is used
119 here instead of the Key ID of the primary key.
120
121 - A one-octet number giving the public-key algorithm used.
122
123 - A string of octets that is the encrypted session key. This
124 string takes up the remainder of the packet, and its contents are
125 dependent on the public-key algorithm used.
126
127 Algorithm Specific Fields for RSA encryption
128
129 - multiprecision integer (MPI) of RSA encrypted value m**e mod n.
130
131 Algorithm Specific Fields for Elgamal encryption:
132
133 - MPI of Elgamal (Diffie-Hellman) value g**k mod p.
134
135 - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
136
137 The value "m" in the above formulas is derived from the session key
138 as follows. First, the session key is prefixed with a one-octet
139 algorithm identifier that specifies the symmetric encryption
140 algorithm used to encrypt the following Symmetrically Encrypted Data
141 Packet. Then a two-octet checksum is appended, which is equal to the
142 sum of the preceding session key octets, not including the algorithm
143 identifier, modulo 65536. This value is then encoded as described in
144 PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
145 form the "m" value used in the formulas above. See Section 13.1 of
146 this document for notes on OpenPGP's use of PKCS#1.
147
148 Note that when an implementation forms several PKESKs with one
149 session key, forming a message that can be decrypted by several keys,
150 the implementation MUST make a new PKCS#1 encoding for each key.
151

Callers 1

encryptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…