diff --git a/bindings/py/pypcp/raw.py b/bindings/py/pypcp/raw.py index 3f3f699..3347e99 100644 --- a/bindings/py/pypcp/raw.py +++ b/bindings/py/pypcp/raw.py @@ -1,553 +1,63 @@ PCP_RAW_CODE = ''' -/*** ./gencffi.pl: from ../../include/pcp/base85.h:36 */ -int decode_85(PCPCTX *ptx, char *dst, const char *buffer, int len); - -/*** ./gencffi.pl: from ../../include/pcp/base85.h:36 */ -void encode_85(char *buf, const unsigned char *data, int bytes); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -Buffer *buffer_new(size_t blocksize, char *name); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -Buffer *buffer_new_str(char *name); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -Buffer *buffer_new_buf(char *name, void *data, size_t datasize); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_init(Buffer *b, size_t blocksize, char *name); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_free(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_clear(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_rewind(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add(Buffer *b, const void *data, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add_buf(Buffer *dst, Buffer *src); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add_str(Buffer *b, const char * fmt, ...); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add_hex(Buffer *b, void *data, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_resize(Buffer *b, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -int buffer_done(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -size_t buffer_get_chunk(Buffer *b, void *buf, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -size_t buffer_get_chunk_tobuf(Buffer *b, Buffer *dst, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -byte *buffer_get(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -char *buffer_get_str(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -byte *buffer_get_remainder(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -size_t buffer_extract(Buffer *b, void *buf, size_t offset, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -size_t buffer_fwd_offset(Buffer *b, size_t fwdby); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_dump(const Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_info(const Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -size_t buffer_size(const Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -size_t buffer_left(const Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint8_t buffer_get8(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint16_t buffer_get16(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint32_t buffer_get32(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint64_t buffer_get64(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint16_t buffer_get16na(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint32_t buffer_get32na(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint64_t buffer_get64na(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint8_t buffer_last8(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint16_t buffer_last16(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint32_t buffer_last32(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -uint64_t buffer_last64(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -size_t buffer_fd_read(Buffer *b, FILE *in, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add8(Buffer *b, uint8_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add16(Buffer *b, uint16_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add32(Buffer *b, uint32_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add64(Buffer *b, uint64_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add16be(Buffer *b, uint16_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add32be(Buffer *b, uint32_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:690 */ -void buffer_add64be(Buffer *b, uint64_t v); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:985 */ -PCPCTX *ptx_new(); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:985 */ -void ptx_clean(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:985 */ -void fatal(PCPCTX *ptx, const char * fmt, ...); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:985 */ -void fatals_ifany(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:985 */ -void fatals_reset(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:985 */ -void final(const char * fmt, ...); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:985 */ -void ptx_dump(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:1323 */ -size_t pcp_encrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t *s, pcp_pubkey_t *p, int signcrypt, int anon); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:1323 */ -size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, int havehead, pcp_rec_t *recsign); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:1323 */ -size_t pcp_decrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t *s, byte *symkey, int verify, int anon); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:1323 */ -size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, pcp_rec_t *recverify); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:1323 */ -pcp_rec_t *pcp_rec_new(byte *cipher, size_t clen, pcp_key_t *secret, pcp_pubkey_t *pub); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:1323 */ -void pcp_rec_free(pcp_rec_t *r); - -/*** ./gencffi.pl: from ../../include/pcp/defines.h:1556 */ +/*** bindings/py/gencffi.pl: from include/pcp/defines.h:177 */ typedef unsigned char byte; -/*** ./gencffi.pl: from ../../include/pcp/defines.h:1556 */ +/*** bindings/py/gencffi.pl: from include/pcp/defines.h:177 */ typedef unsigned short dbyte; -/*** ./gencffi.pl: from ../../include/pcp/defines.h:1556 */ +/*** bindings/py/gencffi.pl: from include/pcp/defines.h:177 */ typedef unsigned int qbyte; -/*** ./gencffi.pl: from ../../include/pcp/digital_crc32.h:1599 */ -digital_update_crc32(unsigned int crc, const unsigned char *buf, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/digital_crc32.h:1599 */ -digital_crc32(const unsigned char *buf, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:1801 */ -byte *pcp_ed_sign(byte *message, size_t messagesize, pcp_key_t *s); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:1801 */ -byte *pcp_ed_verify(PCPCTX *ptx, byte *signature, size_t siglen, pcp_pubkey_t *p); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:1801 */ -byte *pcp_ed_verify_key(PCPCTX *ptx, byte *signature, size_t siglen, pcp_pubkey_t *p); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:1801 */ -size_t pcp_ed_sign_buffered(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, pcp_key_t *s, int z85); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:1801 */ -pcp_pubkey_t *pcp_ed_verify_buffered(PCPCTX *ptx, Pcpstream *in, pcp_pubkey_t *p); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:1801 */ -size_t pcp_ed_detachsign_buffered(Pcpstream *in, Pcpstream *out, pcp_key_t *s); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:1801 */ -pcp_pubkey_t *pcp_ed_detachverify_buffered(PCPCTX *ptx, Pcpstream *in, Pcpstream *sigfd, pcp_pubkey_t *p); - -/*** ./gencffi.pl: from ../../include/pcp/getpass.h:1823 */ -void pcp_echo_off(); - -/*** ./gencffi.pl: from ../../include/pcp/getpass.h:1823 */ -void pcp_echo_on(); - -/*** ./gencffi.pl: from ../../include/pcp/getpass.h:1823 */ -char *pcp_get_stdin(); - -/*** ./gencffi.pl: from ../../include/pcp/getpass.h:1823 */ -char *pcp_get_passphrase(char *prompt); - -/*** ./gencffi.pl: from ../../include/pcp/jenhash.h:1848 */ -unsigned jen_hash ( unsigned char *k, unsigned length, unsigned initval ); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -pcp_key_t *pcpkey_new (); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -void pcp_keypairs(byte *msk, byte *mpk, byte *csk, byte *cpk, byte *esk, byte *epk); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -char *pcppubkey_get_art(pcp_pubkey_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -char *pcpkey_get_art(pcp_key_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -pcp_key_t *pcpkey_encrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -pcp_key_t *pcpkey_decrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -pcp_pubkey_t *pcpkey_pub_from_secret(pcp_key_t *key); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -char *pcp_getkeyid(pcp_key_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -char *pcp_getpubkeyid(pcp_pubkey_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -byte *pcppubkey_getchecksum(pcp_pubkey_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -byte *pcpkey_getchecksum(pcp_key_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -pcp_key_t * key2be(pcp_key_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -pcp_key_t *key2native(pcp_key_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -pcp_pubkey_t * pubkey2be(pcp_pubkey_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -pcp_pubkey_t *pubkey2native(pcp_pubkey_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -byte * pcp_gennonce(); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -byte *pcp_derivekey(PCPCTX *ptx, char *passphrase, byte *nonce); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -void pcp_seckeyblob(Buffer *b, pcp_key_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -void pcp_pubkeyblob(Buffer *b, pcp_pubkey_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -Buffer *pcp_keyblob(void *k, int type); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -int pcp_sanitycheck_pub(PCPCTX *ptx, pcp_pubkey_t *key); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -int pcp_sanitycheck_key(PCPCTX *ptx, pcp_key_t *key); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -void pcp_dumpkey(pcp_key_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -void pcp_dumppubkey(pcp_pubkey_t *k); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:2162 */ -void pcpkey_setowner(pcp_key_t *key, char *owner, char *mail); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -void pcphash_del(PCPCTX *ptx, void *key, int type); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -void pcphash_clean(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -void pcphash_cleanpub(pcp_pubkey_t *pub); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -pcp_key_t *pcphash_keyexists(PCPCTX *ptx, char *id); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -pcp_pubkey_t *pcphash_pubkeyexists(PCPCTX *ptx, char *id); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -void pcphash_add(PCPCTX *ptx, void *key, int type); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -int pcphash_count(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -int pcphash_countpub(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:2315 */ -pcp_keysig_t *pcphash_keysigexists(PCPCTX *ptx, char *id); - -/*** ./gencffi.pl: from ../../include/pcp/keysig.h:2365 */ -pcp_keysig_t *keysig2be(pcp_keysig_t *s); - -/*** ./gencffi.pl: from ../../include/pcp/keysig.h:2365 */ -pcp_keysig_t *keysig2native(pcp_keysig_t *s); - -/*** ./gencffi.pl: from ../../include/pcp/keysig.h:2365 */ -Buffer *pcp_keysig2blob(pcp_keysig_t *s); - -/*** ./gencffi.pl: from ../../include/pcp/keysig.h:2365 */ -pcp_keysig_t *pcp_keysig_new(Buffer *blob); - -/*** ./gencffi.pl: from ../../include/pcp/mem.h:2423 */ -void *ucmalloc(size_t s); - -/*** ./gencffi.pl: from ../../include/pcp/mem.h:2423 */ -void *smalloc(size_t s); - -/*** ./gencffi.pl: from ../../include/pcp/mem.h:2423 */ -void *urmalloc(size_t s); - -/*** ./gencffi.pl: from ../../include/pcp/mem.h:2423 */ -void *srmalloc(size_t s); - -/*** ./gencffi.pl: from ../../include/pcp/mem.h:2423 */ -void *ucrealloc(void *d, size_t oldlen, size_t newlen); - -/*** ./gencffi.pl: from ../../include/pcp/mem.h:2423 */ -void ucfree(void *d, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/mem.h:2423 */ -void sfree(void *d); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -Buffer *pcp_export_rfc_pub (pcp_key_t *sk); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -Buffer *pcp_export_pbp_pub(pcp_key_t *sk); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -Buffer *pcp_export_yaml_pub(pcp_key_t *sk); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -Buffer *pcp_export_perl_pub(pcp_key_t *sk); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -Buffer *pcp_export_c_pub(pcp_key_t *sk); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -Buffer *pcp_export_secret(PCPCTX *ptx, pcp_key_t *sk, char *passphrase); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -pcp_ks_bundle_t *pcp_import_binpub(PCPCTX *ptx, byte *raw, size_t rawsize); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -pcp_ks_bundle_t *pcp_import_pub(PCPCTX *ptx, byte *raw, size_t rawsize); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -pcp_ks_bundle_t *pcp_import_pub_rfc(PCPCTX *ptx, Buffer *blob); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -pcp_ks_bundle_t *pcp_import_pub_pbp(PCPCTX *ptx, Buffer *blob); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -pcp_key_t *pcp_import_binsecret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passphrase); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -pcp_key_t *pcp_import_secret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passphrase); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphrase); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -int _check_keysig_h(PCPCTX *ptx, Buffer *blob, rfc_pub_sig_h *h); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -int _check_hash_keysig(PCPCTX *ptx, Buffer *blob, pcp_pubkey_t *p, pcp_keysig_t *sk); - -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:2698 */ -int _check_sigsubs(PCPCTX *ptx, Buffer *blob, pcp_pubkey_t *p, rfc_pub_sig_s *subheader); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -Pcpstream *ps_init(void); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -Pcpstream *ps_new_file(FILE *backendfd); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -Pcpstream *ps_new_inbuffer(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -Pcpstream *ps_new_outbuffer(); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_finish(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_print(Pcpstream *stream, const char * fmt, ...); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_tell(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -Buffer *ps_buffer(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -void ps_close(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -int ps_end(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -int ps_err(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -void ps_setdetermine(Pcpstream *stream, size_t blocksize); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -void ps_armor(Pcpstream *stream, size_t blocksize); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -void ps_unarmor(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_read_decode(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -void ps_determine(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_read_next(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_read_raw(Pcpstream *stream, void *buf, size_t readbytes); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -void ps_write_encode(Pcpstream *stream, Buffer *dst); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -size_t ps_write_buf(Pcpstream *stream, Buffer *z); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -int ps_left(Pcpstream *stream); - -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:2989 */ -int ps_readline(Pcpstream *stream, Buffer *line); - -/*** ./gencffi.pl: from ../../include/pcp/plist.h:3193 */ -typedef struct _plist_t plist_t; - -/*** ./gencffi.pl: from ../../include/pcp/plist.h:3193 */ -struct _plist_t { - char *value; - struct _plist_t *next; - struct _plist_t *first; -}; - -/*** ./gencffi.pl: from ../../include/pcp/randomart.h:3247 */ -char *key_fingerprint_randomart(unsigned char *dgst_raw, unsigned int dgst_raw_len); - -/*** ./gencffi.pl: from ../../include/pcp/scrypt.h:3290 */ -byte * pcp_scrypt(PCPCTX *ptx, char *passwd, size_t passwdlen, byte *nonce, size_t noncelen); - -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_key_t pcp_key_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_pubkey_t pcp_pubkey_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pbp_pubkey_t pbp_pubkey_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_rec_t pcp_rec_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_keysig_t pcp_keysig_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_ctx_t PCPCTX; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _vault_t vault_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _vault_header_t vault_header_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _vault_item_header_t vault_item_header_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_buffer Buffer; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_stream_t Pcpstream; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_rfc_pubkey_header_t rfc_pub_h; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_rfc_pubkey_0x21_t rfc_pub_k; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_rfc_pubkey_sigheader_0x21_t rfc_pub_sig_h; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_rfc_pubkey_sigsub_0x21_t rfc_pub_sig_s; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ typedef struct _pcp_ks_bundle_t pcp_ks_bundle_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_key_t { byte masterpub[32]; /**< ED25519 master public key signing key */ byte mastersecret[64]; /**< ED25519 master secret key signing key */ @@ -567,7 +77,7 @@ struct _pcp_key_t { byte hh[56]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_pubkey_t { byte masterpub[32]; /**< ED25519 master public key signing key */ byte sigpub[32]; /**< ED25519 public signing key */ @@ -585,7 +95,7 @@ struct _pcp_pubkey_t { byte hh[56]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pbp_pubkey_t { byte sigpub[32]; byte edpub[32]; @@ -595,7 +105,7 @@ struct _pbp_pubkey_t { char name[1024]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_rec_t { size_t ciphersize; /**< the size of the encrypted recipient list */ byte *cipher; /**< contains the whole encrypted recipient list */ @@ -603,7 +113,7 @@ struct _pcp_rec_t { pcp_pubkey_t *pub; /**< if verification were ok, contains the public key of the signer */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_keysig_t { uint8_t type; uint32_t size; @@ -613,7 +123,7 @@ struct _pcp_keysig_t { byte hh[56]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_ctx_t { char *pcp_err; /**< last error message. retrieve with fatals_ifany() */ byte pcp_errset; /**< indicates if an error occurred. */ @@ -625,7 +135,7 @@ struct _pcp_ctx_t { pcp_keysig_t *pcpkeysig_hash; /**< hash for key sigs */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _vault_t { char *filename; /**< The filename of the vault (full path) */ FILE *fd; /**< Filehandle if opened */ @@ -638,14 +148,14 @@ struct _vault_t { byte checksum[32]; /**< SHA256 checksum over the whole vault */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _vault_header_t { uint8_t fileid; /**< File id, proprietary. Marks the vault as a vault */ uint32_t version; /**< File version */ byte checksum[32]; /**< SHA256 checksum over the whole vault */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _vault_item_header_t { uint8_t type; /**< Item type (secret key, public, key, keysig, \see _PCP_KEY_TYPES */ uint32_t size; /**< Size of the item */ @@ -653,7 +163,7 @@ struct _vault_item_header_t { byte checksum[32]; /**< SHA256 checksum of the item */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_buffer { char *name; /**< just for convenience in error messages and the like, so we know which buffer cause trouble */ uint8_t allocated; /**< marks the buffer as allocated */ @@ -665,7 +175,7 @@ struct _pcp_buffer { void *buf; /**< the actual storage buffer */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_stream_t { FILE *fd; /**< The backend FILE stream */ Buffer *b; /**< The backend Buffer object */ @@ -685,21 +195,21 @@ struct _pcp_stream_t { size_t pos; /**< remember i/o position */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_rfc_pubkey_header_t { uint8_t version; uint64_t ctime; uint8_t cipher; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_rfc_pubkey_0x21_t { byte sig_ed25519_pub[32]; byte ed25519_pub[32]; byte curve25519_pub[32]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_rfc_pubkey_sigheader_0x21_t { uint8_t version; uint8_t type; @@ -708,349 +218,716 @@ struct _pcp_rfc_pubkey_sigheader_0x21_t { uint16_t numsubs; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_rfc_pubkey_sigsub_0x21_t { uint32_t size; uint8_t type; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:3674 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:557 */ struct _pcp_ks_bundle_t { pcp_pubkey_t *p; pcp_keysig_t *s; }; -/*** ./gencffi.pl: from ../../include/pcp/uthash.h:4622 */ -typedef unsigned int uint32_t; +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +pcp_key_t *pcpkey_new (); -/*** ./gencffi.pl: from ../../include/pcp/uthash.h:4622 */ -typedef byte uint8_t; +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +void pcp_keypairs(byte *msk, byte *mpk, byte *csk, byte *cpk, byte *esk, byte *epk); -/*** ./gencffi.pl: from ../../include/pcp/uthash.h:4622 */ -for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +char *pcppubkey_get_art(pcp_pubkey_t *k); -/*** ./gencffi.pl: from ../../include/pcp/uthash.h:4622 */ -for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +char *pcpkey_get_art(pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/util.h:4726 */ -char *_lc(char *in); +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +pcp_key_t *pcpkey_encrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase); -/*** ./gencffi.pl: from ../../include/pcp/util.h:4726 */ -long int _findoffset(byte *bin, size_t binlen, char *sigstart, size_t hlen); +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +pcp_key_t *pcpkey_decrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase); -/*** ./gencffi.pl: from ../../include/pcp/util.h:4726 */ -void _xorbuf(byte *iv, byte *buf, size_t xlen); +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +pcp_pubkey_t *pcpkey_pub_from_secret(pcp_key_t *key); -/*** ./gencffi.pl: from ../../include/pcp/util.h:4726 */ -void _dump(char *n, byte *d, size_t s); +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +char *pcp_getkeyid(pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +char *pcp_getpubkeyid(pcp_pubkey_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +byte *pcppubkey_getchecksum(pcp_pubkey_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +byte *pcpkey_getchecksum(pcp_key_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +pcp_key_t * key2be(pcp_key_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +pcp_key_t *key2native(pcp_key_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +pcp_pubkey_t * pubkey2be(pcp_pubkey_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +pcp_pubkey_t *pubkey2native(pcp_pubkey_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +byte * pcp_gennonce(); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +byte *pcp_derivekey(PCPCTX *ptx, char *passphrase, byte *nonce); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +void pcp_seckeyblob(Buffer *b, pcp_key_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +void pcp_pubkeyblob(Buffer *b, pcp_pubkey_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +Buffer *pcp_keyblob(void *k, int type); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +int pcp_sanitycheck_pub(PCPCTX *ptx, pcp_pubkey_t *key); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +int pcp_sanitycheck_key(PCPCTX *ptx, pcp_key_t *key); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +void pcp_dumpkey(pcp_key_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +void pcp_dumppubkey(pcp_pubkey_t *k); + +/*** bindings/py/gencffi.pl: from include/pcp/key.h:871 */ +void pcpkey_setowner(pcp_key_t *key, char *owner, char *mail); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +Buffer *buffer_new(size_t blocksize, char *name); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +Buffer *buffer_new_str(char *name); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +Buffer *buffer_new_buf(char *name, void *data, size_t datasize); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_init(Buffer *b, size_t blocksize, char *name); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_free(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_clear(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_rewind(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add(Buffer *b, const void *data, size_t len); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add_buf(Buffer *dst, Buffer *src); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add_str(Buffer *b, const char * fmt, ...); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add_hex(Buffer *b, void *data, size_t len); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_resize(Buffer *b, size_t len); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +int buffer_done(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +size_t buffer_get_chunk(Buffer *b, void *buf, size_t len); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +size_t buffer_get_chunk_tobuf(Buffer *b, Buffer *dst, size_t len); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +byte *buffer_get(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +char *buffer_get_str(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +byte *buffer_get_remainder(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +size_t buffer_extract(Buffer *b, void *buf, size_t offset, size_t len); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +size_t buffer_fwd_offset(Buffer *b, size_t fwdby); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_dump(const Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_info(const Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +size_t buffer_size(const Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +size_t buffer_left(const Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint8_t buffer_get8(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint16_t buffer_get16(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint32_t buffer_get32(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint64_t buffer_get64(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint16_t buffer_get16na(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint32_t buffer_get32na(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint64_t buffer_get64na(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint8_t buffer_last8(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint16_t buffer_last16(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint32_t buffer_last32(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +uint64_t buffer_last64(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +size_t buffer_fd_read(Buffer *b, FILE *in, size_t len); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add8(Buffer *b, uint8_t v); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add16(Buffer *b, uint16_t v); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add32(Buffer *b, uint32_t v); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add64(Buffer *b, uint64_t v); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add16be(Buffer *b, uint16_t v); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add32be(Buffer *b, uint32_t v); + +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:1525 */ +void buffer_add64be(Buffer *b, uint64_t v); + +/*** bindings/py/gencffi.pl: from include/pcp/context.h:1621 */ +PCPCTX *ptx_new(); + +/*** bindings/py/gencffi.pl: from include/pcp/context.h:1621 */ +void ptx_clean(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/context.h:1621 */ +void fatal(PCPCTX *ptx, const char * fmt, ...); + +/*** bindings/py/gencffi.pl: from include/pcp/context.h:1621 */ +void fatals_ifany(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/context.h:1621 */ +void fatals_reset(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/context.h:1621 */ +void final(const char * fmt, ...); + +/*** bindings/py/gencffi.pl: from include/pcp/context.h:1621 */ +void ptx_dump(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:1823 */ +byte *pcp_ed_sign(byte *message, size_t messagesize, pcp_key_t *s); + +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:1823 */ +byte *pcp_ed_verify(PCPCTX *ptx, byte *signature, size_t siglen, pcp_pubkey_t *p); + +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:1823 */ +byte *pcp_ed_verify_key(PCPCTX *ptx, byte *signature, size_t siglen, pcp_pubkey_t *p); + +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:1823 */ +size_t pcp_ed_sign_buffered(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, pcp_key_t *s, int z85); + +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:1823 */ +pcp_pubkey_t *pcp_ed_verify_buffered(PCPCTX *ptx, Pcpstream *in, pcp_pubkey_t *p); + +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:1823 */ +size_t pcp_ed_detachsign_buffered(Pcpstream *in, Pcpstream *out, pcp_key_t *s); + +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:1823 */ +pcp_pubkey_t *pcp_ed_detachverify_buffered(PCPCTX *ptx, Pcpstream *in, Pcpstream *sigfd, pcp_pubkey_t *p); + +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:2166 */ +size_t pcp_encrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t *s, pcp_pubkey_t *p, int signcrypt, int anon); + +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:2166 */ +size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, int havehead, pcp_rec_t *recsign); + +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:2166 */ +size_t pcp_decrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t *s, byte *symkey, int verify, int anon); + +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:2166 */ +size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, pcp_rec_t *recverify); + +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:2166 */ +pcp_rec_t *pcp_rec_new(byte *cipher, size_t clen, pcp_key_t *secret, pcp_pubkey_t *pub); + +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:2166 */ +void pcp_rec_free(pcp_rec_t *r); + +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:2166 */ +byte *_gen_ctr_nonce(uint64_t ctr); + +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:2166 */ +uint64_t _get_nonce_ctr(byte *nonce); + +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ vault_t *pcpvault_init(PCPCTX *ptx, char *filename); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ vault_t *pcpvault_new(PCPCTX *ptx, char *filename, int is_tmp); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ int pcpvault_create(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ int pcpvault_additem(PCPCTX *ptx, vault_t *vault, void *item, size_t itemsize, uint8_t type); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ int pcpvault_addkey(PCPCTX *ptx, vault_t *vault, void *item, uint8_t type); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ int pcpvault_close(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ void pcpvault_free(vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ int pcpvault_fetchall(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ int pcpvault_writeall(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ int pcpvault_copy(PCPCTX *ptx, vault_t *tmp, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ void pcpvault_unlink(vault_t *tmp); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ byte *pcpvault_create_checksum(PCPCTX *ptx); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ void pcpvault_update_checksum(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ vault_header_t * vh2be(vault_header_t *h); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ vault_header_t * vh2native(vault_header_t *h); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ vault_item_header_t * ih2be(vault_item_header_t *h); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:4956 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:2396 */ vault_item_header_t * ih2native(vault_item_header_t *h); -/*** ./gencffi.pl: from ../../include/pcp/version.h:4993 */ -int pcp_version(); +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +Buffer *pcp_export_rfc_pub (pcp_key_t *sk); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +Buffer *pcp_export_pbp_pub(pcp_key_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +Buffer *pcp_export_yaml_pub(pcp_key_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +Buffer *pcp_export_perl_pub(pcp_key_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +Buffer *pcp_export_c_pub(pcp_key_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +Buffer *pcp_export_secret(PCPCTX *ptx, pcp_key_t *sk, char *passphrase); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +pcp_ks_bundle_t *pcp_import_binpub(PCPCTX *ptx, byte *raw, size_t rawsize); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +pcp_ks_bundle_t *pcp_import_pub(PCPCTX *ptx, byte *raw, size_t rawsize); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +pcp_ks_bundle_t *pcp_import_pub_rfc(PCPCTX *ptx, Buffer *blob); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +pcp_ks_bundle_t *pcp_import_pub_pbp(PCPCTX *ptx, Buffer *blob); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +pcp_key_t *pcp_import_binsecret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passphrase); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +pcp_key_t *pcp_import_secret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passphrase); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphrase); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +int _check_keysig_h(PCPCTX *ptx, Buffer *blob, rfc_pub_sig_h *h); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +int _check_hash_keysig(PCPCTX *ptx, Buffer *blob, pcp_pubkey_t *p, pcp_keysig_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:2671 */ +int _check_sigsubs(PCPCTX *ptx, Buffer *blob, pcp_pubkey_t *p, rfc_pub_sig_s *subheader); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +void pcphash_del(PCPCTX *ptx, void *key, int type); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +void pcphash_clean(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +void pcphash_cleanpub(pcp_pubkey_t *pub); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +pcp_key_t *pcphash_keyexists(PCPCTX *ptx, char *id); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +pcp_pubkey_t *pcphash_pubkeyexists(PCPCTX *ptx, char *id); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +void pcphash_add(PCPCTX *ptx, void *key, int type); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +int pcphash_count(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +int pcphash_countpub(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:2824 */ +pcp_keysig_t *pcphash_keysigexists(PCPCTX *ptx, char *id); + +/*** bindings/py/gencffi.pl: from include/pcp/scrypt.h:2867 */ +byte * pcp_scrypt(PCPCTX *ptx, char *passwd, size_t passwdlen, byte *nonce, size_t noncelen); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +Pcpstream *ps_init(void); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +Pcpstream *ps_new_file(FILE *backendfd); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +Pcpstream *ps_new_inbuffer(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +Pcpstream *ps_new_outbuffer(); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_finish(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_print(Pcpstream *stream, const char * fmt, ...); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_tell(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +Buffer *ps_buffer(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +void ps_close(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +int ps_end(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +int ps_err(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +void ps_setdetermine(Pcpstream *stream, size_t blocksize); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +void ps_armor(Pcpstream *stream, size_t blocksize); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +void ps_unarmor(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_read_decode(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +void ps_determine(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_read_next(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_read_raw(Pcpstream *stream, void *buf, size_t readbytes); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +void ps_write_encode(Pcpstream *stream, Buffer *dst); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +size_t ps_write_buf(Pcpstream *stream, Buffer *z); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +int ps_left(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:3158 */ +int ps_readline(Pcpstream *stream, Buffer *line); + +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ byte *pcp_padfour(byte *src, size_t srclen, size_t *dstlen); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ -size_t pcp_unpadfour(byte *src, size_t srclen); - -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ byte *pcp_z85_decode(PCPCTX *ptx, char *z85block, size_t *dstlen); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ char *pcp_z85_encode(byte *raw, size_t srclen, size_t *dstlen, int doblock); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ char *pcp_readz85file(PCPCTX *ptx, FILE *infile); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ char *pcp_readz85string(PCPCTX *ptx, byte *input, size_t bufsize); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ uint8_t is_utf8(const byte * bytes); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ size_t _buffer_is_binary(byte *buf, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ uint8_t _parse_zchar(Buffer *z, uint8_t c, uint8_t is_comment); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ long int z85_header_startswith(Buffer *buf, char *what); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ int z85_isheader(Buffer *buf); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ int z85_isend(Buffer *buf); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ int z85_isbegin(Buffer *buf); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ int z85_iscomment(Buffer *buf); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ int z85_isempty(Buffer *line); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:5171 */ -int z85_isencoded(Buffer *line); +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:3324 */ +int z85_isencoded(Buffer *line);''' -/*** ./gencffi.pl: from ../../include/pcp/zmq_z85.h:5202 */ -uint8_t *zmq_z85_decode (uint8_t *dest, char *string); - -/*** ./gencffi.pl: from ../../include/pcp/zmq_z85.h:5202 */ -char *zmq_z85_encode (char *dest, uint8_t *data, size_t size);''' - -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ASYM_CIPHER = 5 -# ./gencffi.pl: from ../../include/pcp/version.h:4993 -PCP_VERSION = \ - - -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_C = 4 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_BLOCK_SIZE = 32 * 1024 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_PK_HEADER = "----- BEGIN ED25519-CURVE29915 PUBLIC KEY -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SK_FOOTER = "----- END ED25519-CURVE29915 PRIVATE KEY -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ENFILE_HEADER = "----- BEGIN PCP ENCRYPTED FILE -----\r\n" -# ./gencffi.pl: from ../../include/pcp/version.h:4993 -PCP_MAKE_VERSION(major, = minor, patch) \ - - -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_NATIVE = 1 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PBP_COMPAT_SALT = "qa~t](84z<1t<1oz:ik.@IRNyhG=8q(on9}4#!/_h#a7wqK{Nt$T?W>,mt8NqYq&6U,rSYI2GRDd:Bcm" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_HASH_CIPHER = 0x22 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_HASH_NAME = "BLAKE2" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_NOTATION = 20 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_CIPHER_NAME = "ED25519" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_CIPHER = 0x23 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ZFILE_HEADER = "----- BEGIN Z85 ENCODED FILE -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIG_END = "----- END ED25519 SIGNATURE -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_KEY_VERSION = 6 -# ./gencffi.pl: from ../../include/pcp/version.h:4993 -PCP_VERSION_MAJOR = 0 - - -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_PK_CIPHER = 0x21 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_KEY_PRIMITIVE = "CURVE25519-ED25519-SALSA20-POLY1305" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_RFC_CIPHER = 0x21 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ASYM_CIPHER_ANON = 6 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_PERL = 6 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ENFILE_FOOTER = "\r\n----- END PCP ENCRYPTED FILE -----\r\n" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_YAML = 3 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SYM_CIPHER = 23 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_TYPE = 0x1F -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_PY = 5 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_KEYFLAGS = 27 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SK_HEADER = "----- BEGIN ED25519-CURVE29915 PRIVATE KEY -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIGPREFIX = "\nnacl-" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ME = "Pretty Curved Privacy" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ZFILE_FOOTER = "----- END Z85 ENCODED FILE -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_SIGEXPIRE = 3 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ENCRYPT_MAC = 56 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_PK_FOOTER = "----- END ED25519-CURVE29915 PUBLIC KEY -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_CTIME = 2 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_VAULT_ID = 14 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIG_HEADER = "----- BEGIN ED25519 SIGNED MESSAGE -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ASYM_CIPHER_SIG = 24 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_PK_CIPHER_NAME = "CURVE25519-ED25519-POLY1305-SALSA20" -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_PBP = 2 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_VAULT_VERSION = 2 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_CRYPTO_ADD = (32 - 16) -# ./gencffi.pl: from ../../include/pcp/version.h:4993 -PCP_VERSION_PATCH = 4 - - -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_KEYEXPIRE = 9 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIG_VERSION = 2 -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIG_START = "----- BEGIN ED25519 SIGNATURE -----" -# ./gencffi.pl: from ../../include/pcp/version.h:4993 -PCP_VERSION_MINOR = 2 - - -# ./gencffi.pl: from ../../include/pcp/defines.h:1556 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_VERSION = 0x01 diff --git a/configure.ac b/configure.ac index 370ca64..98a6500 100755 --- a/configure.ac +++ b/configure.ac @@ -218,12 +218,6 @@ if test "x${_havenacl}" != "xno" -a "x$cross_compile" = "xno"; then ) fi -AC_ARG_ENABLE([cbc], - [AS_HELP_STRING([--enable-cbc], - [Enable CBC@1k encryption mode (default: EBC @32k)])], - [AC_DEFINE(PCP_CBC, 1, Define if you want to enable CBC mode)], - []) - # Check for some target-specific stuff case "$host" in @@ -410,7 +404,6 @@ AC_MSG_RESULT([ target platform: ${host} big endian cpu: ${bigendian} cross compile: ${cross_compile} - have nacl: ${_havenacl} build python binding: ${python} build c++ binding: ${enable_cpp_binding} diff --git a/include/pcp.h b/include/pcp.h index fe070bf..0458136 100644 --- a/include/pcp.h +++ b/include/pcp.h @@ -8,9 +8,9 @@ extern "C" { #include "pcp/config.h" #include "pcp/base85.h" #include "pcp/buffer.h" -#include "pcp/config.h" #include "pcp/context.h" #include "pcp/crypto.h" +#include "pcp/crypto_scrypt.h" #include "pcp/defines.h" #include "pcp/digital_crc32.h" #include "pcp/ed.h" diff --git a/include/pcp/config.h.in b/include/pcp/config.h.in index 4e6cca1..e0196ac 100644 --- a/include/pcp/config.h.in +++ b/include/pcp/config.h.in @@ -185,9 +185,6 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Define if you want to enable CBC mode */ -#undef PCP_CBC - /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS diff --git a/include/pcp/defines.h b/include/pcp/defines.h index 89583b0..8f7979e 100644 --- a/include/pcp/defines.h +++ b/include/pcp/defines.h @@ -114,21 +114,11 @@ typedef enum _PCP_KEY_TYPES { #define PCP_SIG_VERSION 2 /* crypto file format stuff */ -/* enabled via config.h (configure --enable-cbc) */ -#ifndef PCP_CBC - #define PCP_ASYM_CIPHER 5 - #define PCP_ASYM_CIPHER_ANON 6 - #define PCP_SYM_CIPHER 23 - #define PCP_ASYM_CIPHER_SIG 24 - #define PCP_BLOCK_SIZE 32 * 1024 -#else -/* CBC mode, use smaller blocks */ - #define PCP_ASYM_CIPHER 7 - #define PCP_ASYM_CIPHER_ANON 9 - #define PCP_ASYM_CIPHER_SIG 8 - #define PCP_SYM_CIPHER 25 - #define PCP_BLOCK_SIZE 1 * 1024 -#endif +#define PCP_ASYM_CIPHER 5 +#define PCP_ASYM_CIPHER_ANON 6 +#define PCP_SYM_CIPHER 23 +#define PCP_ASYM_CIPHER_SIG 24 +#define PCP_BLOCK_SIZE 32 * 1024 #define PCP_CRYPTO_ADD (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES) #define PCP_BLOCK_SIZE_IN (PCP_BLOCK_SIZE) + PCP_CRYPTO_ADD + crypto_secretbox_NONCEBYTES diff --git a/include/pcp/plist.h b/include/pcp/plist.h index 9e1b1a3..31c3de4 100644 --- a/include/pcp/plist.h +++ b/include/pcp/plist.h @@ -60,6 +60,13 @@ static inline void p_add(plist_t **lst, char *value) { } } +static inline void p_add_me(plist_t **lst) { + char *me = (char *)malloc(13); + strcpy(me, "__self__"); + p_add(lst, me); + free(me); +} + static inline void p_clean(plist_t *lst) { plist_t *iter = lst->first; plist_t *tmp; diff --git a/libpcp/crypto.c b/libpcp/crypto.c index a6317e3..74df780 100644 --- a/libpcp/crypto.c +++ b/libpcp/crypto.c @@ -242,6 +242,24 @@ size_t pcp_decrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t } free(recipient); } + + /* do the same with our secret keys, just in case the sender used -M */ + if(recmatch == 0) { + pcp_key_t *k; + pcphash_iterate(ptx, k) { + cur = pcpkey_pub_from_secret(k); + byte *recipient; + recipient = pcp_box_decrypt(ptx, s, cur, rec_buf, PCP_ASYM_RECIPIENT_SIZE, &rec_size); + if(recipient != NULL && rec_size == crypto_secretbox_KEYBYTES) { + /* found a match */ + recmatch = 1; + symkey = smalloc(crypto_secretbox_KEYBYTES); + memcpy(symkey, recipient, crypto_secretbox_KEYBYTES); + free(recipient); + break; + } + } + } } if(verify) { size_t R = nrec * (PCP_ASYM_RECIPIENT_SIZE); @@ -255,11 +273,14 @@ size_t pcp_decrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t goto errdef1; } + fatals_reset(ptx); + /* step 5, actually decrypt the file, finally */ if(verify) { pcp_rec_t *rec = pcp_rec_new(reccipher, nrec * PCP_ASYM_RECIPIENT_SIZE, NULL, cur); size_t s = pcp_decrypt_stream_sym(ptx, in, out, symkey, rec); pcp_rec_free(rec); + ucfree(reccipher, lenrec * PCP_ASYM_RECIPIENT_SIZE); sfree(symkey); return s; } @@ -425,17 +446,6 @@ size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, byte * } } -#ifdef PCP_CBC - /* write the IV, pad it with rubbish, since pcp_decrypt_file_sym */ - /* reads in with PCP_BLOCK_SIZE_IN buffersize and uses the last */ - /* PCP_BLOCK_SIZE as IV. */ - byte *iv = urmalloc(PCP_BLOCK_SIZE); - byte *ivpad = urmalloc(PCP_BLOCK_SIZE_IN - PCP_BLOCK_SIZE); - - ps_write(out, ivpad, PCP_BLOCK_SIZE_IN - PCP_BLOCK_SIZE); - ps_write(out, iv, PCP_BLOCK_SIZE); -#endif - /* 32k-Block-mode. */ in_buf = ucmalloc(PCP_BLOCK_SIZE); while(!ps_end(in)) { @@ -446,11 +456,6 @@ size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, byte * /* generate nonce and put current buffer counter into it */ buf_nonce = _gen_ctr_nonce(ctr++); -#ifdef PCP_CBC - /* apply IV to current clear */ - _xorbuf(iv, in_buf, cur_bufsize); -#endif - es = pcp_sodium_mac(&buf_cipher, in_buf, cur_bufsize, buf_nonce, symkey); ps_write(out, buf_nonce, crypto_secretbox_NONCEBYTES); @@ -464,10 +469,6 @@ size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, byte * crypto_generichash_update(st, buf_cipher, es); //crypto_generichash_update(st, in_buf, cur_bufsize); -#ifdef PCP_CBC - /* make current cipher to next IV, ignore nonce and pad */ - memcpy(iv, &buf_cipher[PCP_CRYPTO_ADD], PCP_BLOCK_SIZE); -#endif } if(ps_err(out) != 0) { @@ -537,10 +538,6 @@ size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte * signature_cr = ucmalloc(siglen_cr); } -#ifdef PCP_CBC - byte *iv = NULL; /* will be filled during 1st loop */ -#endif - in_buf = ucmalloc(PCP_BLOCK_SIZE_IN); while(!ps_end(in)) { @@ -556,15 +553,6 @@ size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte * } } -#ifdef PCP_CBC - if(iv == NULL) { - /* first block is the IV, don't write it out and skip to the next block */ - iv = ucmalloc(PCP_BLOCK_SIZE); - memcpy(iv, &in_buf[PCP_CRYPTO_ADD + crypto_secretbox_NONCEBYTES], PCP_BLOCK_SIZE); - continue; - } -#endif - ciphersize = cur_bufsize - crypto_secretbox_NONCEBYTES; memcpy(buf_nonce, in_buf, crypto_secretbox_NONCEBYTES); memcpy(buf_cipher, &in_buf[crypto_secretbox_NONCEBYTES], ciphersize); @@ -581,11 +569,6 @@ size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte * pastctr = ctr; es = pcp_sodium_verify_mac(&buf_clear, buf_cipher, ciphersize, buf_nonce, symkey); -#ifdef PCP_CBC - /* take last IV and apply it to current clear */ - _xorbuf(iv, buf_clear, cur_bufsize - (PCP_CRYPTO_ADD + crypto_secretbox_NONCEBYTES)); -#endif - out_size += ciphersize - PCP_CRYPTO_ADD; if(es == 0) { @@ -610,10 +593,6 @@ size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte * out_size = 0; break; } -#ifdef PCP_CBC - /* use last cipher as next IV */ - memcpy(iv, &in_buf[PCP_CRYPTO_ADD + crypto_secretbox_NONCEBYTES], PCP_BLOCK_SIZE); -#endif } ucfree(in_buf, PCP_BLOCK_SIZE_IN); diff --git a/libpcp/key.c b/libpcp/key.c index 38312c7..acfbd07 100644 --- a/libpcp/key.c +++ b/libpcp/key.c @@ -207,12 +207,11 @@ pcp_key_t *pcpkey_decrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase) { memcpy(key->mastersecret, decrypted, 64); memcpy(key->edsecret, decrypted + 64, 64); memcpy(key->secret, decrypted +128, 32); - ucfree(decrypted, 176); + ucfree(decrypted, 160); } else { fatal(ptx, "failed to decrypt the secret key (got %d, expected 32)!\n", es); - ucfree(decrypted, 176); - ucfree(key, sizeof(pcp_key_t)); + ucfree(decrypted, 160); return NULL; } diff --git a/src/encryption.c b/src/encryption.c index a508c83..b614a39 100644 --- a/src/encryption.c +++ b/src/encryption.c @@ -166,11 +166,11 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec pcp_pubkey_t *pub = NULL; pcp_key_t *secret = NULL; byte *symkey = NULL; - int self = 0; + int symmode = 0; if(id == NULL && recipient == NULL) { - /* self mode */ - self = 1; + /* sym mode */ + symmode = 1; char *passphrase; if(passwd == NULL) { pcp_readpass(&passphrase, @@ -195,8 +195,9 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec pcp_key_t *s = pcphash_keyexists(ptx, id); if(s != NULL) { tmp = pcpkey_pub_from_secret(s); - HASH_ADD_STR( pubhash, id, tmp); - self = 1; + pub = ucmalloc(sizeof(pcp_pubkey_t)); + memcpy(pub, tmp, sizeof(pcp_pubkey_t)); + HASH_ADD_STR( pubhash, id, pub); } else { fatal(ptx, "Could not find a public key with id 0x%s in vault %s!\n", @@ -220,7 +221,8 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec rec = recipient->first; while (rec != NULL) { _lc(rec->value); - if(strnstr(tmp->mail, rec->value, 255) != NULL || strnstr(tmp->owner, rec->value, 255) != NULL) { + if(strnstr(tmp->mail, rec->value, 255) != NULL + || strnstr(tmp->owner, rec->value, 255) != NULL) { pub = ucmalloc(sizeof(pcp_pubkey_t)); memcpy(pub, tmp, sizeof(pcp_pubkey_t)); HASH_ADD_STR( pubhash, id, pub); @@ -229,6 +231,19 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec rec = rec->next; } } + + /* look if we need to add ourselfes */ + rec = recipient->first; + while (rec != NULL) { + if(strnstr("__self__", rec->value, 13) != NULL) { + pcp_key_t *s = pcp_find_primary_secret(); + pcp_pubkey_t *p = pcpkey_pub_from_secret(s); + HASH_ADD_STR( pubhash, id, p); + break; + } + rec = rec->next; + } + if(HASH_COUNT(pubhash) == 0) { fatal(ptx, "no matching key found for specified recipient(s)!\n"); goto erren3; @@ -236,7 +251,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec } - if(self != 1) { + if(symmode != 1) { /* we're using a random secret keypair on our side */ if(anon) { secret = pcpkey_new(); @@ -295,7 +310,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec ps_armor(pout, PCP_BLOCK_SIZE/2); } - if(self == 1) { + if(symmode == 1) { clen = pcp_encrypt_stream_sym(ptx, pin, pout, symkey, 0, NULL); sfree(symkey); } @@ -339,5 +354,8 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec erren3: + if(tmp != NULL) + ucfree(tmp, sizeof(pcp_pubkey_t)); + return 1; } diff --git a/src/pcp.c b/src/pcp.c index 69f56bd..6088461 100644 --- a/src/pcp.c +++ b/src/pcp.c @@ -99,9 +99,10 @@ int main (int argc, char **argv) { /* crypto */ { "encrypt", no_argument, NULL, 'e' }, - { "encrypt-me", no_argument, NULL, 'm' }, + { "encrypt-sym", no_argument, NULL, 'm' }, { "decrypt", no_argument, NULL, 'd' }, { "anonymous", no_argument, NULL, 'A' }, + { "add-myself", no_argument, NULL, 'M' }, /* encoding */ { "z85-encode", no_argument, NULL, 'z' }, @@ -122,7 +123,7 @@ int main (int argc, char **argv) { { NULL, 0, NULL, 0 } }; - while ((opt = getopt_long(argc, argv, "klLV:vdehsO:i:I:pSPRtEx:DzaZr:gcymf:b1F:0KA", + while ((opt = getopt_long(argc, argv, "klLV:vdehsO:i:I:pSPRtEx:DzaZr:gcymf:b1F:0KAM", longopts, NULL)) != -1) { switch (opt) { @@ -265,6 +266,10 @@ int main (int argc, char **argv) { p_add(&recipient, optarg); userec = 1; break; + case 'M': + p_add_me(&recipient); + userec = 1; + break; case 'D': debug = 1; diff --git a/tests/unittests.cfg b/tests/unittests.cfg index 913c96d..334c979 100644 --- a/tests/unittests.cfg +++ b/tests/unittests.cfg @@ -234,6 +234,16 @@ temporarily disabled cmd = cat testdecrypted expect = /${md5msg}/ + + + cmd = $pcp -V va -e -M -I testmessage -O testencryptedself -x a + expect = /Alicia/ + + + + cmd = $pcp -V va -d -I testencryptedself -O testdecrypted -x a + expect = /successfully/ + #