Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_or_typeerror(self):
u = PGPUID.new("Asdf Qwert")
with pytest.raises(TypeError):
u |= 12
def abe():
return PGPUID.new('Abraham Lincoln', comment='Honest Abe', email='abraham.lincoln@whitehouse.gov')
def uid():
return PGPUID.new('Abraham Lincoln', comment='Honest Abe', email='abraham.lincoln@whitehouse.gov')
def abe():
uid = PGPUID.new('Abraham Lincoln', comment='Honest Abe', email='abraham.lincoln@whitehouse.gov')
with open('tests/testdata/abe.jpg', 'rb') as abef:
abebytes = bytearray(os.fstat(abef.fileno()).st_size)
abef.readinto(abebytes)
uphoto = PGPUID.new(abebytes)
# Abe is pretty oldschool, so he uses a DSA primary key
# normally he uses an ElGamal subkey for encryption, but PGPy doesn't support that yet, so he's settled for RSA for now
key = PGPKey.new(PubKeyAlgorithm.DSA, 1024)
subkey = PGPKey.new(PubKeyAlgorithm.RSAEncryptOrSign, 1024)
key.add_uid(uid,
usage={KeyFlags.Certify, KeyFlags.Sign},
hashes=[HashAlgorithm.SHA224, HashAlgorithm.SHA1],
ciphers=[SymmetricKeyAlgorithm.AES128, SymmetricKeyAlgorithm.Camellia128, SymmetricKeyAlgorithm.CAST5],
compression=[CompressionAlgorithm.ZLIB])
key.add_uid(uphoto)
def temp_key():
u = PGPUID.new('User')
k = PGPKey.new(PubKeyAlgorithm.RSAEncryptOrSign, 512)
k.add_uid(u, usage={KeyFlags.Certify, KeyFlags.Sign}, hashes=[HashAlgorithm.SHA1])
sk = PGPKey.new(PubKeyAlgorithm.RSAEncryptOrSign, 512)
k.add_subkey(sk, usage={KeyFlags.EncryptCommunications})
return k
def userphoto():
with open('tests/testdata/pgp.jpg', 'rb') as pf:
pbytes = bytearray(os.fstat(pf.fileno()).st_size)
pf.readinto(pbytes)
return PGPUID.new(pbytes)
def _gen_skey_usage_all(self, emailadr):
skey = PGPKey.new(SKEY_ALG, KEY_SIZE)
# NOTE: pgpy implements separate attributes for name and e-mail
# address. Name is mandatory.
# Here e-mail address is used for the attribute name,
# so that the uid is 'e-mail adress'.
# If name attribute would be set to empty string
# and email to the e-mail address, the uid would be
# ' ', which we do not want.
uid = PGPUID.new(emailadr)
skey.add_uid(uid, usage=SKEY_USAGE_ALL, **SKEY_ARGS)
return skey