How to use the pgpy.PGPUID.new function in PGPy

To help you get started, we’ve selected a few PGPy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SecurityInnovation / PGPy / tests / test_10_exceptions.py View on Github external
def test_or_typeerror(self):
        u = PGPUID.new("Asdf Qwert")
        with pytest.raises(TypeError):
            u |= 12
github SecurityInnovation / PGPy / tests / test_04_PGP_objects.py View on Github external
def abe():
    return PGPUID.new('Abraham Lincoln', comment='Honest Abe', email='abraham.lincoln@whitehouse.gov')
github SecurityInnovation / PGPy / tests / test_04_copy.py View on Github external
def uid():
    return PGPUID.new('Abraham Lincoln', comment='Honest Abe', email='abraham.lincoln@whitehouse.gov')
github SecurityInnovation / PGPy / tests / test_05_actions.py View on Github external
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)
github SecurityInnovation / PGPy / tests / test_10_exceptions.py View on Github external
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
github SecurityInnovation / PGPy / tests / test_05_actions.py View on Github external
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)
github hpk42 / muacrypt / core / autocrypt / pgpycrypto.py View on Github external
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