Ejemplo n.º 1
0
 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]))
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 def from_bytes(cls, ctx, source):
     return PacketPile(invoke(lib.pgp_packet_pile_from_bytes,
                              ffi.from_buffer(source), len(source)),
                       context=ctx)
Ejemplo n.º 4
0
 def from_bytes(cls, fp):
     return Fingerprint(
         lib.pgp_fingerprint_from_bytes(
             ffi.cast("uint8_t *", ffi.from_buffer(fp)), len(fp)))
Ejemplo n.º 5
0
 def decrypt(self, algo, key):
     invoke(lib.pgp_packet_parser_decrypt, self.ref(), algo,
            ffi.from_buffer(key), len(key))
Ejemplo n.º 6
0
 def from_bytes(cls, ctx, source):
     return PacketParserResult(invoke(lib.pgp_packet_parser_from_bytes,
                                      ffi.from_buffer(source), len(source)),
                               context=ctx)
Ejemplo n.º 7
0
 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))))
Ejemplo n.º 8
0
 def from_bytes(cls, ctx, source):
     return Cert(invoke(lib.pgp_cert_from_bytes, ffi.from_buffer(source),
                        len(source)),
                 context=ctx)
Ejemplo n.º 9
0
 def from_bytes(cls, ctx, source):
     return TPK(invoke(lib.pgp_tpk_from_bytes, ffi.from_buffer(source),
                       len(source)),
                context=ctx)