diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-17 17:54:30 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-17 17:54:30 +0100 |
commit | 72f7f83fa697ac44d962dc65ef9329dcfe6fd3e8 (patch) | |
tree | 3b2af100212cee4ae26e548d0535db705e5f616d /ffi/lang | |
parent | 3f58832474a4b270e136544016a401ef773ac065 (diff) |
openpgp-ffi: Change prefix from 'sq' to 'pgp'.
- This change is the result of the following command, which can also
be used to automatically convert existing users of Sequoia's C
API:
git grep -il sq_ | while read F ; do sed -E -i -e 's/sq_(arbitrary_writer_new|armor_reader_from_bytes|armor_reader_from_file|armor_reader_headers|armor_reader_kind|armor_reader_new|armor_writer_new|decrypt|encryptor_new|error_free|error_status|error_string|fingerprint_as_bytes|fingerprint_clone|fingerprint_equal|fingerprint_free|fingerprint_from_bytes|fingerprint_from_hex|fingerprint_hash|fingerprint_to_hex|fingerprint_to_keyid|fingerprint_to_string|keyid_clone|keyid_equal|keyid_free|keyid_from_bytes|keyid_from_hex|keyid_hash|keyid_to_hex|keyid_to_string|key_pair_as_signer|key_pair_free|key_pair_new|literal_writer_new|packet_free|packet_kind|packet_parser_buffer_unread_content|packet_parser_decrypt|packet_parser_eof_free|packet_parser_eof_is_message|packet_parser_finish|packet_parser_free|packet_parser_from_bytes|packet_parser_from_file|packet_parser_from_reader|packet_parser_next|packet_parser_packet|packet_parser_recurse|packet_parser_recursion_depth|packet_parser_result_eof|packet_parser_result_free|packet_parser_result_packet_parser|packet_parser_result_tag|packet_pile_clone|packet_pile_free|packet_pile_from_bytes|packet_pile_from_file|packet_pile_from_reader|packet_pile_serialize|packet_tag|pkesk_decrypt|pkesk_recipient|p_key_alive|p_key_alive_at|p_key_clone|p_key_creation_time|p_key_expired|p_key_expired_at|p_key_fingerprint|p_key_into_key_pair|p_key_keyid|p_key_public_key_algo|p_key_public_key_bits|reader_free|reader_from_bytes|reader_from_fd|reader_from_file|reader_read|revocation_status_free|revocation_status_variant|secret_cached|signature_alive|signature_alive_at|signature_can_authenticate|signature_can_certify|signature_can_encrypt_at_rest|signature_can_encrypt_for_transport|signature_can_sign|signature_expired|signature_expired_at|signature_free|signature_is_group_key|signature_is_split_key|signature_issuer|signature_issuer_fingerprint|signature_to_packet|signer_free|signer_new|signer_new_detached|skesk_decrypt|tag_to_string|tpk_alive|tpk_alive_at|tpk_builder_add_certification_subkey|tpk_builder_add_encryption_subkey|tpk_builder_add_signing_subkey|tpk_builder_add_userid|tpk_builder_autocrypt|tpk_builder_default|tpk_builder_free|tpk_builder_generate|tpk_builder_set_cipher_suite|tpk_clone|tpk_dump|tpk_equal|tpk_expired|tpk_expired_at|tpk_fingerprint|tpk_free|tpk_from_bytes|tpk_from_file|tpk_from_packet_parser|tpk_from_packet_pile|tpk_from_reader|tpk_into_tsk|tpk_is_tsk|tpk_key_iter|tpk_key_iter_free|tpk_key_iter_next|tpk_merge|tpk_merge_packets|tpk_primary|tpk_primary_user_id|tpk_revocation_status|tpk_revoke|tpk_revoke_in_place|tpk_serialize|tpk_set_expiry|tpk_user_id_binding_iter|tsk_free|tsk_into_tpk|tsk_new|tsk_serialize|tsk_tpk|user_attribute_value|user_id_binding_iter_free|user_id_binding_iter_next|user_id_binding_selfsig|user_id_binding_user_id|user_id_value|verification_result_code|verification_result_level|verification_results_at_level|verification_result_signature|verify|writer_alloc|writer_free|writer_from_bytes|writer_from_fd|writer_from_file|writer_stack_finalize|writer_stack_finalize_one|writer_stack_message|writer_stack_write|writer_stack_write_all|writer_write|reader|writer|packet_parser|packet_parser_result|packet_parser_eof|keyid|fingerprint|revocation_status|revocation_status_variant|armor_kind|armor_header|tag|unknown|signature|one_pass_sig|p_key|user_id|user_attribute|literal|compressed_data|pkesk|skesk|seip|mdc|packet|packet_pile|reason_for_revocation|user_id_binding|user_id_binding_iter|tpk_key_iter|tpk|tsk|tpk_builder|tpk_cipher_suite|public_key_algorithm|writer_stack|encryption_mode|secret|verification_results|verification_result|verification_result_code|sequoia_decrypt_get_public_keys_cb_t|sequoia_decrypt_get_secret_keys_cb_t|sequoia_decrypt_check_signatures_cb_t|mpi|signer|key_pair|p_key|status|error)/pgp_\1/g' -e 's/SQ_(ARMOR_KIND_ANY|ARMOR_KIND_FILE|ARMOR_KIND_FORCE_WIDTH|ARMOR_KIND_MESSAGE|ARMOR_KIND_PUBLICKEY|ARMOR_KIND_SECRETKEY|ARMOR_KIND_SIGNATURE|ENCRYPTION_MODE_AT_REST|ENCRYPTION_MODE_FOR_TRANSPORT|PUBLIC_KEY_ALGO_DSA|PUBLIC_KEY_ALGO_ECDH|PUBLIC_KEY_ALGO_ECDSA|PUBLIC_KEY_ALGO_EDDSA|PUBLIC_KEY_ALGO_ELGAMAL_ENCRYPT|PUBLIC_KEY_ALGO_ELGAMAL_ENCRYPT_SIGN|PUBLIC_KEY_ALGO_FORCE_WIDTH|PUBLIC_KEY_ALGO_RSA_ENCRYPT|PUBLIC_KEY_ALGO_RSA_ENCRYPT_SIGN|PUBLIC_KEY_ALGO_RSA_SIGN|REASON_FOR_REVOCATION_FORCE_WIDTH|REASON_FOR_REVOCATION_KEY_COMPROMISED|REASON_FOR_REVOCATION_KEY_RETIRED|REASON_FOR_REVOCATION_KEY_SUPERSEDED|REASON_FOR_REVOCATION_UID_RETIRED|REASON_FOR_REVOCATION_UNSPECIFIED|REVOCATION_STATUS_COULD_BE|REVOCATION_STATUS_FORCE_WIDTH|REVOCATION_STATUS_NOT_AS_FAR_AS_WE_KNOW|REVOCATION_STATUS_REVOKED|STATUS_BAD_SIGNATURE|STATUS_FORCE_WIDTH|STATUS_INDEX_OUT_OF_RANGE|STATUS_INVALID_ARGUMENT|STATUS_INVALID_OPERATION|STATUS_INVALID_PASSWORD|STATUS_INVALID_SESSION_KEY|STATUS_IO_ERROR|STATUS_MALFORMED_MESSAGE|STATUS_MALFORMED_PACKET|STATUS_MALFORMED_TPK|STATUS_MANIPULATED_MESSAGE|STATUS_MISSING_SESSION_KEY|STATUS_NETWORK_POLICY_VIOLATION|STATUS_SUCCESS|STATUS_UNKNOWN_ERROR|STATUS_UNSUPPORTED_AEAD_ALGORITHM|STATUS_UNSUPPORTED_ELLIPTIC_CURVE|STATUS_UNSUPPORTED_HASH_ALGORITHM|STATUS_UNSUPPORTED_PUBLICKEY_ALGORITHM|STATUS_UNSUPPORTED_SIGNATURE_TYPE|STATUS_UNSUPPORTED_SYMMETRIC_ALGORITHM|STATUS_UNSUPPORTED_TPK|TAG_COMPRESSED_DATA|TAG_LITERAL|TAG_MARKER|TAG_MDC|TAG_ONE_PASS_SIG|TAG_PKESK|TAG_PRIVATE|TAG_PUBLIC_KEY|TAG_PUBLIC_SUBKEY|TAG_RESERVED|TAG_SECRET_KEY|TAG_SECRET_SUBKEY|TAG_SED|TAG_SEIP|TAG_SIGNATURE|TAG_SKESK|TAG_TRUST|TAG_UNASSIGNED|TAG_USER_ATTRIBUTE|TAG_USER_ID|TPK_CIPHER_SUITE_CV|TPK_CIPHER_SUITE_FORCE_WIDTH|TPK_CIPHER_SUITE_RSA|VERIFICATION_RESULT_CODE_BAD_CHECKSUM|VERIFICATION_RESULT_CODE_FORCE_WIDTH|VERIFICATION_RESULT_CODE_GOOD_CHECKSUM|VERIFICATION_RESULT_CODE_MISSING_KEY)/PGP_\1/g' $F ; done
Diffstat (limited to 'ffi/lang')
-rw-r--r-- | ffi/lang/python/sequoia/core.py | 22 | ||||
-rw-r--r-- | ffi/lang/python/sequoia/error.py | 26 | ||||
-rw-r--r-- | ffi/lang/python/sequoia/glue.py | 2 | ||||
-rw-r--r-- | ffi/lang/python/sequoia/openpgp.py | 172 | ||||
-rw-r--r-- | ffi/lang/python/sequoia/store.py | 4 |
5 files changed, 113 insertions, 113 deletions
diff --git a/ffi/lang/python/sequoia/core.py b/ffi/lang/python/sequoia/core.py index 117e1207..a7e12808 100644 --- a/ffi/lang/python/sequoia/core.py +++ b/ffi/lang/python/sequoia/core.py @@ -30,14 +30,14 @@ class Context(SQObject): lib.sq_config_ipc_policy(cfg, ipc_policy.value) if ephemeral: lib.sq_config_ephemeral(cfg) - err = ffi.new("sq_error_t[1]") + err = ffi.new("pgp_error_t[1]") o = lib.sq_config_build(cfg, err) if o == ffi.NULL: raise Error._from(err[0]) super(Context, self).__init__(o) class AbstractReader(SQObject, io.RawIOBase): - _del = lib.sq_reader_free + _del = lib.pgp_reader_free def readable(self): return True @@ -46,7 +46,7 @@ class AbstractReader(SQObject, io.RawIOBase): def readinto(self, buf): return invoke( - lib.sq_reader_read, + lib.pgp_reader_read, self.ref(), ffi.cast("uint8_t *", ffi.from_buffer(buf)), len(buf)) @@ -65,24 +65,24 @@ class Reader(AbstractReader): @classmethod def open(cls, ctx, filename): return Reader( - invoke(lib.sq_reader_from_file, + invoke(lib.pgp_reader_from_file, filename.encode()), context=ctx) @classmethod def from_fd(cls, ctx, fd): - return Reader(lib.sq_reader_from_fd(fd), + return Reader(lib.pgp_reader_from_fd(fd), context=ctx) @classmethod def from_bytes(cls, ctx, buf): return Reader( - lib.sq_reader_from_bytes( + lib.pgp_reader_from_bytes( ffi.cast("uint8_t *", ffi.from_buffer(buf)), len(buf)), context=ctx) class AbstractWriter(SQObject, io.RawIOBase): - _del = lib.sq_writer_free + _del = lib.pgp_writer_free def readable(self): return False @@ -91,7 +91,7 @@ class AbstractWriter(SQObject, io.RawIOBase): def write(self, buf): return invoke( - lib.sq_writer_write, + lib.pgp_writer_write, self.ref(), ffi.cast("const uint8_t *", ffi.from_buffer(buf)), len(buf)) @@ -110,18 +110,18 @@ class Writer(AbstractWriter): @classmethod def open(cls, ctx, filename): return Writer( - invoke(lib.sq_writer_from_file, + invoke(lib.pgp_writer_from_file, filename.encode()), context=ctx) @classmethod def from_fd(cls, ctx, fd): - return Writer(lib.sq_writer_from_fd(fd), + return Writer(lib.pgp_writer_from_fd(fd), context=ctx) @classmethod def from_bytes(cls, ctx, buf): return Writer( - lib.sq_writer_from_bytes( + lib.pgp_writer_from_bytes( ffi.cast("uint8_t *", ffi.from_buffer(buf)), len(buf)), context=ctx) diff --git a/ffi/lang/python/sequoia/error.py b/ffi/lang/python/sequoia/error.py index 29eb2545..192b7d18 100644 --- a/ffi/lang/python/sequoia/error.py +++ b/ffi/lang/python/sequoia/error.py @@ -7,7 +7,7 @@ class Error(Exception): if o == ffi.NULL: return MalformedValue() - status = lib.sq_error_status(o) + status = lib.pgp_error_status(o) return _status_map[status](o) @classmethod @@ -22,8 +22,8 @@ class MalformedValue(Error, ValueError): class SQError(Error): def __init__(self, o): - self.__o = ffi.gc(o, lib.sq_error_free) - super(SQError, self).__init__(sq_str(lib.sq_error_string(self.__o))) + self.__o = ffi.gc(o, lib.pgp_error_free) + super(SQError, self).__init__(sq_str(lib.pgp_error_string(self.__o))) class Success(SQError): pass @@ -56,14 +56,14 @@ class InvalidSessionKey(SQError): pass _status_map = { - lib.SQ_STATUS_SUCCESS: Success, - lib.SQ_STATUS_UNKNOWN_ERROR: UnknownError, - lib.SQ_STATUS_NETWORK_POLICY_VIOLATION: NetworkPolicyViolation, - lib.SQ_STATUS_IO_ERROR: IoError, - lib.SQ_STATUS_INVALID_OPERATION: InvalidOperataion, - lib.SQ_STATUS_MALFORMED_PACKET: MalformedPacket, - lib.SQ_STATUS_UNSUPPORTED_HASH_ALGORITHM: UnsupportedHashAlgorithm, - lib.SQ_STATUS_UNSUPPORTED_SYMMETRIC_ALGORITHM: UnsupportedSymmetricAlgorithm, - lib.SQ_STATUS_INVALID_PASSWORD: InvalidPassword, - lib.SQ_STATUS_INVALID_SESSION_KEY: InvalidSessionKey, + lib.PGP_STATUS_SUCCESS: Success, + lib.PGP_STATUS_UNKNOWN_ERROR: UnknownError, + lib.PGP_STATUS_NETWORK_POLICY_VIOLATION: NetworkPolicyViolation, + lib.PGP_STATUS_IO_ERROR: IoError, + lib.PGP_STATUS_INVALID_OPERATION: InvalidOperataion, + lib.PGP_STATUS_MALFORMED_PACKET: MalformedPacket, + lib.PGP_STATUS_UNSUPPORTED_HASH_ALGORITHM: UnsupportedHashAlgorithm, + lib.PGP_STATUS_UNSUPPORTED_SYMMETRIC_ALGORITHM: UnsupportedSymmetricAlgorithm, + lib.PGP_STATUS_INVALID_PASSWORD: InvalidPassword, + lib.PGP_STATUS_INVALID_SESSION_KEY: InvalidSessionKey, } diff --git a/ffi/lang/python/sequoia/glue.py b/ffi/lang/python/sequoia/glue.py index 5bfd4aae..11468dfd 100644 --- a/ffi/lang/python/sequoia/glue.py +++ b/ffi/lang/python/sequoia/glue.py @@ -11,7 +11,7 @@ def invoke(fun, *args): If an error is encountered, an exception is raised. """ - err = ffi.new("sq_error_t[1]") + err = ffi.new("pgp_error_t[1]") result = fun(err, *args) if err[0] != ffi.NULL: raise Error._from(err[0]) diff --git a/ffi/lang/python/sequoia/openpgp.py b/ffi/lang/python/sequoia/openpgp.py index 747f0b9f..73f58c0b 100644 --- a/ffi/lang/python/sequoia/openpgp.py +++ b/ffi/lang/python/sequoia/openpgp.py @@ -6,116 +6,116 @@ from .glue import _str, SQObject, invoke from .core import AbstractReader, AbstractWriter class KeyID(SQObject): - _del = lib.sq_keyid_free - _clone = lib.sq_keyid_clone - _str = lib.sq_keyid_to_string - _eq = lib.sq_keyid_equal - _hash = lib.sq_keyid_hash + _del = lib.pgp_keyid_free + _clone = lib.pgp_keyid_clone + _str = lib.pgp_keyid_to_string + _eq = lib.pgp_keyid_equal + _hash = lib.pgp_keyid_hash @classmethod def from_bytes(cls, fp): if len(fp) != 8: raise Error("KeyID must be of length 8") - return KeyID(lib.sq_keyid_from_bytes( + return KeyID(lib.pgp_keyid_from_bytes( ffi.cast("uint8_t *", ffi.from_buffer(fp)))) @classmethod def from_hex(cls, fp): - return KeyID(lib.sq_keyid_from_hex(fp.encode())) + return KeyID(lib.pgp_keyid_from_hex(fp.encode())) def hex(self): - return _str(lib.sq_keyid_to_hex(self.ref())) + return _str(lib.pgp_keyid_to_hex(self.ref())) class Fingerprint(SQObject): - _del = lib.sq_fingerprint_free - _clone = lib.sq_fingerprint_clone - _str = lib.sq_fingerprint_to_string - _eq = lib.sq_fingerprint_equal - _hash = lib.sq_fingerprint_hash + _del = lib.pgp_fingerprint_free + _clone = lib.pgp_fingerprint_clone + _str = lib.pgp_fingerprint_to_string + _eq = lib.pgp_fingerprint_equal + _hash = lib.pgp_fingerprint_hash @classmethod def from_bytes(cls, fp): - return Fingerprint(lib.sq_fingerprint_from_bytes( + return Fingerprint(lib.pgp_fingerprint_from_bytes( ffi.cast("uint8_t *", ffi.from_buffer(fp)), len(fp))) @classmethod def from_hex(cls, fp): - return Fingerprint(lib.sq_fingerprint_from_hex(fp.encode())) + return Fingerprint(lib.pgp_fingerprint_from_hex(fp.encode())) def hex(self): - return _str(lib.sq_fingerprint_to_hex(self.ref())) + return _str(lib.pgp_fingerprint_to_hex(self.ref())) def keyid(self): - return KeyID(lib.sq_fingerprint_to_keyid(self.ref())) + return KeyID(lib.pgp_fingerprint_to_keyid(self.ref())) class PacketPile(SQObject): - _del = lib.sq_packet_pile_free - _clone = lib.sq_packet_pile_clone + _del = lib.pgp_packet_pile_free + _clone = lib.pgp_packet_pile_clone @classmethod def from_reader(cls, ctx, reader): - return PacketPile(invoke(lib.sq_packet_pile_from_reader, reader.ref()), + return PacketPile(invoke(lib.pgp_packet_pile_from_reader, reader.ref()), context=ctx) @classmethod def open(cls, ctx, filename): - return PacketPile(invoke(lib.sq_packet_pile_from_file, filename.encode()), + return PacketPile(invoke(lib.pgp_packet_pile_from_file, filename.encode()), context=ctx) @classmethod def from_bytes(cls, ctx, source): - return PacketPile(invoke(lib.sq_packet_pile_from_bytes, + return PacketPile(invoke(lib.pgp_packet_pile_from_bytes, ffi.from_buffer(source), len(source)), context=ctx) def serialize(self, writer): - status = invoke(lib.sq_packet_pile_serialize, + status = invoke(lib.pgp_packet_pile_serialize, self.ref(), writer.ref()) if status: raise Error._last(self.context()) class TPK(SQObject): - _del = lib.sq_tpk_free - _clone = lib.sq_tpk_clone - _eq = lib.sq_tpk_equal + _del = lib.pgp_tpk_free + _clone = lib.pgp_tpk_clone + _eq = lib.pgp_tpk_equal @classmethod def from_reader(cls, ctx, reader): - return TPK(invoke(lib.sq_tpk_from_reader, reader.ref()), + return TPK(invoke(lib.pgp_tpk_from_reader, reader.ref()), context=ctx) @classmethod def open(cls, ctx, filename): - return TPK(invoke(lib.sq_tpk_from_file, filename.encode()), + return TPK(invoke(lib.pgp_tpk_from_file, filename.encode()), context=ctx) @classmethod def from_packet_pile(cls, ctx, packet_pile): - return TPK(invoke(lib.sq_tpk_from_packet_pile, packet_pile.ref_consume()), + return TPK(invoke(lib.pgp_tpk_from_packet_pile, packet_pile.ref_consume()), context=ctx) @classmethod def from_bytes(cls, ctx, source): - return TPK(invoke(lib.sq_tpk_from_bytes, + return TPK(invoke(lib.pgp_tpk_from_bytes, ffi.from_buffer(source), len(source)), context=ctx) def serialize(self, writer): - status = invoke(lib.sq_tpk_serialize, + status = invoke(lib.pgp_tpk_serialize, self.ref(), writer.ref()) if status: raise Error._last(self.context()) def fingerprint(self): - return Fingerprint(lib.sq_tpk_fingerprint(self.ref()), + return Fingerprint(lib.pgp_tpk_fingerprint(self.ref()), context=self.context()) def merge(self, other): - new = invoke(lib.sq_tpk_merge, + new = invoke(lib.pgp_tpk_merge, self.ref_consume(), other.ref_consume()) if new == ffi.NULL: @@ -123,20 +123,20 @@ class TPK(SQObject): self.ref_replace(new) def dump(self): - lib.sq_tpk_dump(self.ref()) + lib.pgp_tpk_dump(self.ref()) class Kind(Enum): - Message = lib.SQ_ARMOR_KIND_MESSAGE - PublicKey = lib.SQ_ARMOR_KIND_PUBLICKEY - SecretKey = lib.SQ_ARMOR_KIND_SECRETKEY - Signature = lib.SQ_ARMOR_KIND_SIGNATURE - File = lib.SQ_ARMOR_KIND_FILE - Any = lib.SQ_ARMOR_KIND_ANY + Message = lib.PGP_ARMOR_KIND_MESSAGE + PublicKey = lib.PGP_ARMOR_KIND_PUBLICKEY + SecretKey = lib.PGP_ARMOR_KIND_SECRETKEY + Signature = lib.PGP_ARMOR_KIND_SIGNATURE + File = lib.PGP_ARMOR_KIND_FILE + Any = lib.PGP_ARMOR_KIND_ANY class ArmorReader(AbstractReader): @classmethod def new(cls, ctx, inner, kind=Kind.Any): - ar = ArmorReader(lib.sq_armor_reader_new(inner.ref(), + ar = ArmorReader(lib.pgp_armor_reader_new(inner.ref(), kind.value), context=ctx) ar.inner = inner @@ -149,7 +149,7 @@ class ArmorReader(AbstractReader): class ArmorWriter(AbstractWriter): @classmethod def new(cls, ctx, inner, kind): - aw = ArmorWriter(invoke(lib.sq_armor_writer_new, + aw = ArmorWriter(invoke(lib.pgp_armor_writer_new, inner.ref(), kind.value, ffi.NULL, 0), #XXX headers @@ -162,35 +162,35 @@ class ArmorWriter(AbstractWriter): self.inner.close() class Tag(Enum): - PKESK = lib.SQ_TAG_PKESK - Signature = lib.SQ_TAG_SIGNATURE - SKESK = lib.SQ_TAG_SKESK - OnePassSig = lib.SQ_TAG_ONE_PASS_SIG - SecretKey = lib.SQ_TAG_SECRET_KEY - PublicKey = lib.SQ_TAG_PUBLIC_KEY - SecretSubkey = lib.SQ_TAG_SECRET_SUBKEY - CompressedData = lib.SQ_TAG_COMPRESSED_DATA - SED = lib.SQ_TAG_SED - Marker = lib.SQ_TAG_MARKER - Literal = lib.SQ_TAG_LITERAL - Trust = lib.SQ_TAG_TRUST - UserID = lib.SQ_TAG_USER_ID - PublicSubkey = lib.SQ_TAG_PUBLIC_SUBKEY - Unassigned15 = lib.SQ_TAG_UNASSIGNED15 - Unassigned16 = lib.SQ_TAG_UNASSIGNED16 - UserAttribute = lib.SQ_TAG_USER_ATTRIBUTE - SEIP = lib.SQ_TAG_SEIP - MDC = lib.SQ_TAG_MDC + PKESK = lib.PGP_TAG_PKESK + Signature = lib.PGP_TAG_SIGNATURE + SKESK = lib.PGP_TAG_SKESK + OnePassSig = lib.PGP_TAG_ONE_PASS_SIG + SecretKey = lib.PGP_TAG_SECRET_KEY + PublicKey = lib.PGP_TAG_PUBLIC_KEY + SecretSubkey = lib.PGP_TAG_SECRET_SUBKEY + CompressedData = lib.PGP_TAG_COMPRESSED_DATA + SED = lib.PGP_TAG_SED + Marker = lib.PGP_TAG_MARKER + Literal = lib.PGP_TAG_LITERAL + Trust = lib.PGP_TAG_TRUST + UserID = lib.PGP_TAG_USER_ID + PublicSubkey = lib.PGP_TAG_PUBLIC_SUBKEY + Unassigned15 = lib.PGP_TAG_UNASSIGNED15 + Unassigned16 = lib.PGP_TAG_UNASSIGNED16 + UserAttribute = lib.PGP_TAG_USER_ATTRIBUTE + SEIP = lib.PGP_TAG_SEIP + MDC = lib.PGP_TAG_MDC # xxx the rest class Key(SQObject): @property def fingerprint(self): - return Fingerprint(lib.sq_p_key_fingerprint(self.ref())) + return Fingerprint(lib.pgp_p_key_fingerprint(self.ref())) @property def keyid(self): - return KeyID(lib.sq_p_key_keyid(self.ref())) + return KeyID(lib.pgp_p_key_keyid(self.ref())) class PublicKey(Key): pass @@ -205,14 +205,14 @@ class UserID(SQObject): @property def value(self): buf_len = ffi.new("size_t[1]") - buf = lib.sq_user_id_value(self.ref(), buf_len) + buf = lib.pgp_user_id_value(self.ref(), buf_len) return ffi.buffer(buf, buf_len[0]) class UserAttribute(SQObject): @property def value(self): buf_len = ffi.new("size_t[1]") - buf = lib.sq_user_attribute_value(self.ref(), buf_len) + buf = lib.pgp_user_attribute_value(self.ref(), buf_len) return ffi.buffer(buf, buf_len[0]) class SKESK(SQObject): @@ -221,7 +221,7 @@ class SKESK(SQObject): key = ffi.new("uint8_t[32]") key_len = ffi.new("size_t[1]") key_len[0] = len(key) - invoke(lib.sq_skesk_decrypt, + invoke(lib.pgp_skesk_decrypt, self.ref(), ffi.from_buffer(passphrase), len(passphrase), @@ -244,17 +244,17 @@ class Packet(SQObject): } @property def tag(self): - return Tag(lib.sq_packet_tag(self.ref())) + return Tag(lib.pgp_packet_tag(self.ref())) def __str__(self): return "<Packet tag={}>".format(self.tag) def match(self): return self._map[self.tag](self.ref(), context=self.context(), owner=self) class PacketParserResult(SQObject): - _del = lib.sq_packet_parser_result_free + _del = lib.pgp_packet_parser_result_free def packet_parser(self): - ref = lib.sq_packet_parser_result_packet_parser(self.ref()) + ref = lib.pgp_packet_parser_result_packet_parser(self.ref()) if ref != ffi.NULL: # Success! We are consumed. self._delete(skip_free=True) @@ -263,7 +263,7 @@ class PacketParserResult(SQObject): return None def eof(self): - ref = lib.sq_packet_parser_result_eof(self.ref()) + ref = lib.pgp_packet_parser_result_eof(self.ref()) if ref != ffi.NULL: # Success! We are consumed. self._delete(skip_free=True) @@ -272,30 +272,30 @@ class PacketParserResult(SQObject): return None class PacketParserEOF(SQObject): - _del = lib.sq_packet_parser_eof_free + _del = lib.pgp_packet_parser_eof_free def is_message(self): - return bool(lib.sq_packet_parser_eof_is_message(self.ref())) + return bool(lib.pgp_packet_parser_eof_is_message(self.ref())) class PacketParser(SQObject): - _del = lib.sq_packet_parser_free + _del = lib.pgp_packet_parser_free @classmethod def from_reader(cls, ctx, reader): return PacketParserResult( - invoke(lib.sq_packet_parser_from_reader, reader.ref()), + invoke(lib.pgp_packet_parser_from_reader, reader.ref()), context=ctx) @classmethod def open(cls, ctx, filename): return PacketParserResult( - invoke(lib.sq_packet_parser_from_file, filename.encode()), + invoke(lib.pgp_packet_parser_from_file, filename.encode()), context=ctx) @classmethod def from_bytes(cls, ctx, source): return PacketParserResult( - invoke(lib.sq_packet_parser_from_bytes, + invoke(lib.pgp_packet_parser_from_bytes, ffi.from_buffer(source), len(source)), context=ctx) @@ -306,21 +306,21 @@ class PacketParser(SQObject): @property def packet(self): - return Packet(lib.sq_packet_parser_packet(self.ref()), + return Packet(lib.pgp_packet_parser_packet(self.ref()), context=self.context(), owner=self) @property def recursion_depth(self): - return lib.sq_packet_parser_recursion_depth(self.ref()) + return lib.pgp_packet_parser_recursion_depth(self.ref()) def next(self): - packet = ffi.new("sq_packet_t[1]") + packet = ffi.new("pgp_packet_t[1]") old_rl = ffi.new("uint8_t[1]") - ppr = ffi.new("sq_packet_parser_result_t[1]") + ppr = ffi.new("pgp_packet_parser_result_t[1]") new_rl = ffi.new("uint8_t[1]") - invoke(lib.sq_packet_parser_next, + invoke(lib.pgp_packet_parser_next, self.ref_consume(), packet, ppr) @@ -328,12 +328,12 @@ class PacketParser(SQObject): return (Packet(packet[0]), PacketParserResult(ppr[0], self.context())) def recurse(self): - packet = ffi.new("sq_packet_t[1]") + packet = ffi.new("pgp_packet_t[1]") old_rl = ffi.new("uint8_t[1]") - ppr = ffi.new("sq_packet_parser_result_t[1]") + ppr = ffi.new("pgp_packet_parser_result_t[1]") new_rl = ffi.new("uint8_t[1]") - invoke(lib.sq_packet_parser_recurse, + invoke(lib.pgp_packet_parser_recurse, self.ref_consume(), packet, ppr) @@ -342,13 +342,13 @@ class PacketParser(SQObject): def buffer_unread_content(self): buf_len = ffi.new("size_t[1]") - buf = invoke(lib.sq_packet_parser_buffer_unread_content, + buf = invoke(lib.pgp_packet_parser_buffer_unread_content, self.ref(), buf_len) return ffi.buffer(buf, buf_len[0]) def decrypt(self, algo, key): - invoke(lib.sq_packet_parser_decrypt, + invoke(lib.pgp_packet_parser_decrypt, self.ref(), algo, ffi.from_buffer(key), diff --git a/ffi/lang/python/sequoia/store.py b/ffi/lang/python/sequoia/store.py index f38cd42c..4a7a41a9 100644 --- a/ffi/lang/python/sequoia/store.py +++ b/ffi/lang/python/sequoia/store.py @@ -19,7 +19,7 @@ class Store(SQObject): @classmethod def list_keys(cls, ctx): def next_fn(i): - fpp = ffi.new("sq_fingerprint_t[1]") + fpp = ffi.new("pgp_fingerprint_t[1]") key = lib.sq_key_iter_next(i, fpp) if key == ffi.NULL: return ffi.NULL @@ -61,7 +61,7 @@ class Store(SQObject): def iter(self): def next_fn(i): labelp = ffi.new("char *[1]") - fpp = ffi.new("sq_fingerprint_t[1]") + fpp = ffi.new("pgp_fingerprint_t[1]") binding = lib.sq_binding_iter_next(i, labelp, fpp) if binding == ffi.NULL: return ffi.NULL |