diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-11-28 15:27:33 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-11-28 16:26:43 +0100 |
commit | bbbc6da375d6584c7b2bcc74e838fff943f489d4 (patch) | |
tree | 0a965698c96dbc0fc8541c6adc2224935b68bc07 /ffi/lang | |
parent | f53c77752ff04c3713c175a76a06723042e681ae (diff) |
Call TPKs Certificates, update identifiers, documentation.
- Fixes #387.
Diffstat (limited to 'ffi/lang')
-rw-r--r-- | ffi/lang/python/sequoia/net.py | 8 | ||||
-rw-r--r-- | ffi/lang/python/sequoia/openpgp.py | 26 | ||||
-rw-r--r-- | ffi/lang/python/sequoia/store.py | 28 | ||||
-rw-r--r-- | ffi/lang/python/tests/test_cert.py (renamed from ffi/lang/python/tests/test_tpk.py) | 22 |
4 files changed, 42 insertions, 42 deletions
diff --git a/ffi/lang/python/sequoia/net.py b/ffi/lang/python/sequoia/net.py index a89c4e4f..de7a77fc 100644 --- a/ffi/lang/python/sequoia/net.py +++ b/ffi/lang/python/sequoia/net.py @@ -1,6 +1,6 @@ from _sequoia import ffi, lib -from .openpgp import TPK +from .openpgp import Cert from .error import Error from .glue import SQObject @@ -24,14 +24,14 @@ class KeyServer(SQObject): context=ctx) def get(self, keyid): - return TPK(lib.sq_keyserver_get(self.context().ref(), + return Cert(lib.sq_keyserver_get(self.context().ref(), self.ref(), keyid.ref()), context=self.context()) - def send(self, tpk): + def send(self, cert): r = lib.sq_keyserver_send(self.context().ref(), self.ref(), - tpk.ref()) + cert.ref()) if r: raise Error._last(self.context()) diff --git a/ffi/lang/python/sequoia/openpgp.py b/ffi/lang/python/sequoia/openpgp.py index 1c19d80a..7b36ba01 100644 --- a/ffi/lang/python/sequoia/openpgp.py +++ b/ffi/lang/python/sequoia/openpgp.py @@ -79,48 +79,48 @@ class PacketPile(SQObject): if status: raise Error._last(self.context()) -class TPK(SQObject): - _del = lib.pgp_tpk_free - _clone = lib.pgp_tpk_clone - _eq = lib.pgp_tpk_equal - _str = lib.pgp_tpk_to_string - _debug = lib.pgp_tpk_debug +class Cert(SQObject): + _del = lib.pgp_cert_free + _clone = lib.pgp_cert_clone + _eq = lib.pgp_cert_equal + _str = lib.pgp_cert_to_string + _debug = lib.pgp_cert_debug @classmethod def from_reader(cls, ctx, reader): - return TPK(invoke(lib.pgp_tpk_from_reader, reader.ref()), + return Cert(invoke(lib.pgp_cert_from_reader, reader.ref()), context=ctx) @classmethod def open(cls, ctx, filename): - return TPK(invoke(lib.pgp_tpk_from_file, filename.encode()), + return Cert(invoke(lib.pgp_cert_from_file, filename.encode()), context=ctx) @classmethod def from_packet_pile(cls, ctx, packet_pile): - return TPK(invoke(lib.pgp_tpk_from_packet_pile, packet_pile.ref_consume()), + return Cert(invoke(lib.pgp_cert_from_packet_pile, packet_pile.ref_consume()), context=ctx) @classmethod def from_bytes(cls, ctx, source): - return TPK(invoke(lib.pgp_tpk_from_bytes, + return Cert(invoke(lib.pgp_cert_from_bytes, ffi.from_buffer(source), len(source)), context=ctx) def serialize(self, writer): - status = invoke(lib.pgp_tpk_serialize, + status = invoke(lib.pgp_cert_serialize, self.ref(), writer.ref()) if status: raise Error._last(self.context()) def fingerprint(self): - return Fingerprint(lib.pgp_tpk_fingerprint(self.ref()), + return Fingerprint(lib.pgp_cert_fingerprint(self.ref()), context=self.context()) def merge(self, other): - new = invoke(lib.pgp_tpk_merge, + new = invoke(lib.pgp_cert_merge, self.ref_consume(), other.ref_consume()) if new == ffi.NULL: diff --git a/ffi/lang/python/sequoia/store.py b/ffi/lang/python/sequoia/store.py index 6cf4347b..97c601ec 100644 --- a/ffi/lang/python/sequoia/store.py +++ b/ffi/lang/python/sequoia/store.py @@ -2,7 +2,7 @@ from _sequoia import ffi, lib from .error import Error from .glue import _str, _static_str, SQObject, sq_iterator, sq_time -from .openpgp import Fingerprint, TPK +from .openpgp import Fingerprint, Cert class Store(object): @classmethod @@ -50,9 +50,9 @@ class Mapping(SQObject): label.encode(), fingerprint.ref()), context=self.context()) - def import_(self, label, tpk): - return TPK(lib.sq_mapping_import(self.context().ref(), self.ref(), - label.encode(), tpk.ref()), + def import_(self, label, cert): + return Cert(lib.sq_mapping_import(self.context().ref(), self.ref(), + label.encode(), cert.ref()), context=self.context()) def lookup(self, label): @@ -102,16 +102,16 @@ class Binding(SQObject): return Key(lib.sq_binding_key(self.context().ref(), self.ref()), self.context()) - def tpk(self): - return TPK(lib.sq_binding_tpk(self.context().ref(), self.ref()), + def cert(self): + return Cert(lib.sq_binding_cert(self.context().ref(), self.ref()), self.context()) - def import_(self, tpk): - return TPK(lib.sq_binding_import(self.context().ref(), self.ref(), tpk), + def import_(self, cert): + return Cert(lib.sq_binding_import(self.context().ref(), self.ref(), cert), self.context()) - def rotate(self, tpk): - return TPK(lib.sq_binding_rotate(self.context().ref(), self.ref(), tpk), + def rotate(self, cert): + return Cert(lib.sq_binding_rotate(self.context().ref(), self.ref(), cert), self.context()) def delete(self): @@ -134,12 +134,12 @@ class Key(SQObject): return Stats(lib.sq_key_stats(self.context().ref(), self.ref()), self.context()) - def tpk(self): - return TPK(lib.sq_key_tpk(self.context().ref(), self.ref()), + def cert(self): + return Cert(lib.sq_key_cert(self.context().ref(), self.ref()), self.context()) - def import_(self, tpk): - return TPK(lib.sq_key_import(self.context().ref(), self.ref(), tpk), + def import_(self, cert): + return Cert(lib.sq_key_import(self.context().ref(), self.ref(), cert), self.context()) def log(self): diff --git a/ffi/lang/python/tests/test_tpk.py b/ffi/lang/python/tests/test_cert.py index 5e06bd93..8c38f205 100644 --- a/ffi/lang/python/tests/test_tpk.py +++ b/ffi/lang/python/tests/test_cert.py @@ -2,7 +2,7 @@ from os.path import join from tempfile import TemporaryDirectory from sequoia.core import Context, NetworkPolicy, Reader, Writer -from sequoia.openpgp import ArmorReader, Fingerprint, TPK, PacketPile +from sequoia.openpgp import ArmorReader, Fingerprint, Cert, PacketPile pgp = "../../../openpgp/tests/data/keys/testy.pgp" asc = "../../../openpgp/tests/data/keys/testy.asc" @@ -12,7 +12,7 @@ def test_from_reader(): ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True) r = Reader.open(ctx, pgp) - t = TPK.from_reader(ctx, r) + t = Cert.from_reader(ctx, r) assert t.fingerprint() == fp def test_from_armor_reader(): @@ -21,26 +21,26 @@ def test_from_armor_reader(): k = open(asc, "rb").read() r = Reader.from_bytes(ctx, k) r = ArmorReader.new(ctx, r) - t = TPK.from_reader(ctx, r) + t = Cert.from_reader(ctx, r) assert t.fingerprint() == fp def test_from_file(): ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True) - t = TPK.open(ctx, pgp) + t = Cert.open(ctx, pgp) assert t.fingerprint() == fp def test_from_packet_pile(): ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True) r = PacketPile.open(ctx, pgp) - t = TPK.from_packet_pile(ctx, r) + t = Cert.from_packet_pile(ctx, r) assert t.fingerprint() == fp def test_from_bytes(): ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True) - t = TPK.from_bytes(ctx, open(pgp, "rb").read()) + t = Cert.from_bytes(ctx, open(pgp, "rb").read()) assert t.fingerprint() == fp def test_from_serialize(): @@ -49,25 +49,25 @@ def test_from_serialize(): with TemporaryDirectory() as tmp: sink = join(tmp, "a") - t = TPK.open(ctx, pgp) + t = Cert.open(ctx, pgp) with Writer.open(ctx, sink) as s: t.serialize(s) - t = TPK.open(ctx, sink) + t = Cert.open(ctx, sink) assert t.fingerprint() == fp def test_equals(): ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True) b = open(pgp, "rb").read() - t = TPK.from_bytes(ctx, b) - u = TPK.from_bytes(ctx, b) + t = Cert.from_bytes(ctx, b) + u = Cert.from_bytes(ctx, b) assert t == u def test_clone(): ctx = Context(network_policy=NetworkPolicy.Offline, ephemeral=True) - a = TPK.open(ctx, pgp) + a = Cert.open(ctx, pgp) b = a.copy() del a c = b.copy() |