Supported symmetric key algorithms.
| 162 | |
| 163 | |
| 164 | class SymmetricKeyAlgorithm(IntEnum): |
| 165 | """Supported symmetric key algorithms.""" |
| 166 | Plaintext = 0x00 |
| 167 | #: .. warning:: IDEA is insecure. PGPy only allows it to be used for decryption, not encryption! |
| 168 | IDEA = 0x01 |
| 169 | #: Triple-DES with 168-bit key derived from 192 |
| 170 | TripleDES = 0x02 |
| 171 | #: CAST5 (or CAST-128) with 128-bit key |
| 172 | CAST5 = 0x03 |
| 173 | #: Blowfish with 128-bit key and 16 rounds |
| 174 | Blowfish = 0x04 |
| 175 | #: AES with 128-bit key |
| 176 | AES128 = 0x07 |
| 177 | #: AES with 192-bit key |
| 178 | AES192 = 0x08 |
| 179 | #: AES with 256-bit key |
| 180 | AES256 = 0x09 |
| 181 | # Twofish with 256-bit key - not currently supported |
| 182 | Twofish256 = 0x0A |
| 183 | #: Camellia with 128-bit key |
| 184 | Camellia128 = 0x0B |
| 185 | #: Camellia with 192-bit key |
| 186 | Camellia192 = 0x0C |
| 187 | #: Camellia with 256-bit key |
| 188 | Camellia256 = 0x0D |
| 189 | |
| 190 | @property |
| 191 | def cipher(self): |
| 192 | bs = {SymmetricKeyAlgorithm.IDEA: algorithms.IDEA, |
| 193 | SymmetricKeyAlgorithm.TripleDES: algorithms.TripleDES, |
| 194 | SymmetricKeyAlgorithm.CAST5: algorithms.CAST5, |
| 195 | SymmetricKeyAlgorithm.Blowfish: algorithms.Blowfish, |
| 196 | SymmetricKeyAlgorithm.AES128: algorithms.AES, |
| 197 | SymmetricKeyAlgorithm.AES192: algorithms.AES, |
| 198 | SymmetricKeyAlgorithm.AES256: algorithms.AES, |
| 199 | SymmetricKeyAlgorithm.Twofish256: namedtuple('Twofish256', ['block_size'])(block_size=128), |
| 200 | SymmetricKeyAlgorithm.Camellia128: algorithms.Camellia, |
| 201 | SymmetricKeyAlgorithm.Camellia192: algorithms.Camellia, |
| 202 | SymmetricKeyAlgorithm.Camellia256: algorithms.Camellia} |
| 203 | |
| 204 | if self in bs: |
| 205 | return bs[self] |
| 206 | |
| 207 | raise NotImplementedError(repr(self)) |
| 208 | |
| 209 | @property |
| 210 | def is_supported(self): |
| 211 | return callable(self.cipher) |
| 212 | |
| 213 | @property |
| 214 | def is_insecure(self): |
| 215 | insecure_ciphers = {SymmetricKeyAlgorithm.IDEA} |
| 216 | return self in insecure_ciphers |
| 217 | |
| 218 | @property |
| 219 | def block_size(self): |
| 220 | return self.cipher.block_size |
| 221 |
no outgoing calls
no test coverage detected
searching dependent graphs…