def decrypt(self, passphrase): algo = ffi.new("uint8_t[1]") key = ffi.new("uint8_t[32]") key_len = ffi.new("size_t[1]") key_len[0] = len(key) invoke(lib.pgp_skesk_decrypt, self.ref(), ffi.from_buffer(passphrase), len(passphrase), algo, key, key_len) return (algo[0], ffi.buffer(key, key_len[0]))
def new(cls, ctx, uri, cert=None): if not cert: ks = lib.sq_keyserver_new(ctx.ref(), uri.encode()) else: ks = lib.sq_keyserver_with_cert( ctx.ref(), uri.encode(), ffi.cast("uint8_t *", ffi.from_buffer(cert)), len(cert)) return KeyServer(ks, context=ctx)
def from_bytes(cls, ctx, source): return PacketPile(invoke(lib.pgp_packet_pile_from_bytes, ffi.from_buffer(source), len(source)), context=ctx)
def from_bytes(cls, fp): return Fingerprint( lib.pgp_fingerprint_from_bytes( ffi.cast("uint8_t *", ffi.from_buffer(fp)), len(fp)))
def decrypt(self, algo, key): invoke(lib.pgp_packet_parser_decrypt, self.ref(), algo, ffi.from_buffer(key), len(key))
def from_bytes(cls, ctx, source): return PacketParserResult(invoke(lib.pgp_packet_parser_from_bytes, ffi.from_buffer(source), len(source)), context=ctx)
def from_bytes(cls, fp): if len(fp) != 8: raise Error("KeyID must be of length 8") return KeyID( lib.pgp_keyid_from_bytes(ffi.cast("uint8_t *", ffi.from_buffer(fp))))
def from_bytes(cls, ctx, source): return Cert(invoke(lib.pgp_cert_from_bytes, ffi.from_buffer(source), len(source)), context=ctx)
def from_bytes(cls, ctx, source): return TPK(invoke(lib.pgp_tpk_from_bytes, ffi.from_buffer(source), len(source)), context=ctx)