diff --git a/ChangeLog b/ChangeLog index e6da116..5784387 100644 --- a/ChangeLog +++ b/ChangeLog @@ -46,6 +46,8 @@ NEXT to older pcp versions, but is more portable and removes to burden to keep this code up to date. + added option -X (read passphrase from file). + 0.2.4 fixed compiler macro misplacement (github#4). fixed invalid free (github#5). diff --git a/FAQ b/FAQ index af88ca3..ce8a9ca 100644 --- a/FAQ +++ b/FAQ @@ -2,3 +2,59 @@ ./configure --disable-debug make LDFLAGS="-all-static -s" + + += choosing a strong passphrase = + +A passphrase like Ahc so that it reads the passphrase +from that file. + +However if you call -X - then it will read the passphrase from +stdin. But what if the data to be processed shall be read from +stdin as well? + +Use a pipe: + + mkfifo /tmp/pwpipe + chmod 600 /tmp/pwpipe + export HISTIGNORE=printf + printf "%s\n", "password" > /tmp/pwpipe & + cat cleartext | pcp1 -e -O output -X /tmp/pwpipe + rm -f /tmp/pwpipe + +So, what happens here? We create a named pipe in /tmp/pwpipe and +print the passphrase into it. We use printf, because this is a +shell built-in and does not appear in any process listing or +process accounting. But note the '&' after the printf command: +we're sending it into the background. Why? Because a named pipe +is a real simple device. It blocks writing if there's no reader +and it blocks reading if there's no writer. So in our case we +put the passphrase into it, but the printf command will be blocked +until some other process reads it from the pipe, which is precisely +what happens in the next line. Pcp uses the pipe (because of -X), +reads the passphrase from there and proceeds with it's normal +business. Meanwhile the printf command exits. + + + +[1] +https://firstlook.org/theintercept/2015/03/26/passphrases-can-memorize-attackers-cant-guess/ + +[2] +http://www.openwall.com/passwdqc/ diff --git a/README b/README index 2911893..d3305c4 100644 --- a/README +++ b/README @@ -65,7 +65,38 @@ QUICKSTART just sick of Alice and Bob. We're running NSA-free, so we're using other sample names as well. -INSTALLATION +FILES AND PIPES + Pcp behaves like any other unix tool. If not otherwise specified it will + read input from standard input (STDIN) and print output to standard + output (STDOUT). For instance: + + pcp1 -e -O output + + will read the text to be encrypted from standard input, because -I has + not been specified. It works the same with -O: + + pcp1 -e -I myfile + + In this case the encrypted result will be written to standard output. + + Therefore it is possible to use pcp within pipes. Another more realistic + example: + + ssh remote cat file | pcp1 -ez | mailx -s 'as requested' bob@somewhere + + here we encrypt a file symmetrically without downloading it from a + remote ssh server and sending the encrypted result via email to someone. + + The behavior is the same with any other functionality where files are + involved like importing or exporting keys. However, there's one + exception: If the option -X (--password-file) has been used and is set + to -, then this will take precedence over any other possible use of + standard input. So if you want to encrypt something and don't specify an + input file you cannot use -X -, and vice versa. IF you use -X - the + passphrase will be read from standard input, which then can't be used + further for input files elsewhere. Pcp will exit with an error in such a + case. =head1 INSTALLATION + There are currently no packages available, so pcp has to be compiled from source. Follow these steps: diff --git a/README.pod b/README.pod index 95c7af3..cc99612 100644 --- a/README.pod +++ b/README.pod @@ -69,6 +69,39 @@ Oh - and if you're wondering why I named them Alicia and Bobby: I was just sick of Alice and Bob. We're running NSA-free, so we're using other sample names as well. +=head1 FILES AND PIPES + +Pcp behaves like any other unix tool. If not otherwise specified +it will read input from standard input (STDIN) and print output +to standard output (STDOUT). For instance: + + pcp1 -e -O output + +will read the text to be encrypted from standard input, because B<-I> +has not been specified. It works the same with B<-O>: + + pcp1 -e -I myfile + +In this case the encrypted result will be written to standard output. + +Therefore it is possible to use pcp within pipes. Another more +realistic example: + + ssh remote cat file | pcp1 -ez | mailx -s 'as requested' bob@somewhere + +here we encrypt a file symmetrically without downloading it from a +remote ssh server and sending the encrypted result via email to +someone. + +The behavior is the same with any other functionality where files are involved +like importing or exporting keys. However, there's one exception: +If the option B<-X> (B<--password-file>) has been used and is set +to B<->, then this will take precedence over any other possible use +of standard input. So if you want to encrypt something and don't +specify an input file you cannot use B<-X ->, and vice versa. IF +you use B<-X -> the passphrase will be read from standard input, which +then can't be used further for input files elsewhere. Pcp will exit +with an error in such a case. =head1 INSTALLATION There are currently no packages available, so B has to be diff --git a/autogen.sh b/autogen.sh index 1f1dfb5..3d44b15 100755 --- a/autogen.sh +++ b/autogen.sh @@ -60,8 +60,7 @@ Pretty Curved Privacy - File encryption using eliptic curve cryptography. (cd src && ./usage.sh) # generate pypcp types - cd bindings/py - ./gencffi.pl include/pcp/defines.h include/pcp/structs.h include/pcp/key.h \ + bindings/py/gencffi.pl include/pcp/defines.h include/pcp/structs.h include/pcp/key.h \ include/pcp/buffer.h include/pcp/context.h \ include/pcp/ed.h include/pcp/crypto.h include/pcp/vault.h \ include/pcp/mgmt.h include/pcp/keyhash.h \ diff --git a/bindings/py/pypcp/raw.py b/bindings/py/pypcp/raw.py index a7d62fb..007655c 100644 --- a/bindings/py/pypcp/raw.py +++ b/bindings/py/pypcp/raw.py @@ -1,72 +1,62 @@ PCP_RAW_CODE = ''' -/*** ./gencffi.pl: from ../../include/pcp/defines.h:177 */ +/*** bindings/py/gencffi.pl: from include/pcp/defines.h:177 */ typedef unsigned char byte; -/*** ./gencffi.pl: from ../../include/pcp/defines.h:177 */ +/*** bindings/py/gencffi.pl: from include/pcp/defines.h:177 */ typedef unsigned short dbyte; -/*** ./gencffi.pl: from ../../include/pcp/defines.h:177 */ +/*** bindings/py/gencffi.pl: from include/pcp/defines.h:177 */ typedef unsigned int qbyte; -/*** ./gencffi.pl: from ../../include/pcp/plist.h:83 */ -typedef struct _plist_t plist_t; - -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_key_t pcp_key_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_pubkey_t pcp_pubkey_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pbp_pubkey_t pbp_pubkey_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_rec_t pcp_rec_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_keysig_t pcp_keysig_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_ctx_t PCPCTX; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _vault_t vault_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _vault_header_t vault_header_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _vault_item_header_t vault_item_header_t; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_buffer Buffer; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_stream_t Pcpstream; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_rfc_pubkey_header_t rfc_pub_h; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_rfc_pubkey_0x21_t rfc_pub_k; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_rfc_pubkey_sigheader_0x21_t rfc_pub_sig_h; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_rfc_pubkey_sigsub_0x21_t rfc_pub_sig_s; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ typedef struct _pcp_ks_bundle_t pcp_ks_bundle_t; -/*** ./gencffi.pl: from ../../include/pcp/plist.h:83 */ -struct _plist_t { - char *value; - struct _plist_t *next; - struct _plist_t *first; -}; - -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_key_t { byte masterpub[32]; /**< ED25519 master public key signing key */ byte mastersecret[64]; /**< ED25519 master secret key signing key */ @@ -86,7 +76,7 @@ struct _pcp_key_t { byte hh[56]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_pubkey_t { byte masterpub[32]; /**< ED25519 master public key signing key */ byte sigpub[32]; /**< ED25519 public signing key */ @@ -104,7 +94,7 @@ struct _pcp_pubkey_t { byte hh[56]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pbp_pubkey_t { byte sigpub[32]; byte edpub[32]; @@ -114,7 +104,7 @@ struct _pbp_pubkey_t { char name[1024]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_rec_t { size_t ciphersize; /**< the size of the encrypted recipient list */ byte *cipher; /**< contains the whole encrypted recipient list */ @@ -122,7 +112,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:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_keysig_t { uint8_t type; uint32_t size; @@ -132,7 +122,7 @@ struct _pcp_keysig_t { byte hh[56]; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_ctx_t { char *pcp_err; /**< last error message. retrieve with fatals_ifany() */ byte pcp_errset; /**< indicates if an error occurred. */ @@ -144,7 +134,7 @@ struct _pcp_ctx_t { pcp_keysig_t *pcpkeysig_hash; /**< hash for key sigs */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _vault_t { char *filename; /**< The filename of the vault (full path) */ FILE *fd; /**< Filehandle if opened */ @@ -157,14 +147,14 @@ struct _vault_t { byte checksum[32]; /**< SHA256 checksum over the whole vault */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ 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:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ 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 */ @@ -172,7 +162,7 @@ struct _vault_item_header_t { byte checksum[32]; /**< SHA256 checksum of the item */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ 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 */ @@ -184,7 +174,7 @@ struct _pcp_buffer { void *buf; /**< the actual storage buffer */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_stream_t { FILE *fd; /**< The backend FILE stream */ Buffer *b; /**< The backend Buffer object */ @@ -204,21 +194,21 @@ struct _pcp_stream_t { size_t pos; /**< remember i/o position */ }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_rfc_pubkey_header_t { uint8_t version; uint64_t ctime; uint8_t cipher; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ 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:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_rfc_pubkey_sigheader_0x21_t { uint8_t version; uint8_t type; @@ -227,771 +217,696 @@ struct _pcp_rfc_pubkey_sigheader_0x21_t { uint16_t numsubs; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_rfc_pubkey_sigsub_0x21_t { uint32_t size; uint8_t type; }; -/*** ./gencffi.pl: from ../../include/pcp/structs.h:380 */ +/*** bindings/py/gencffi.pl: from include/pcp/structs.h:380 */ struct _pcp_ks_bundle_t { pcp_pubkey_t *p; pcp_keysig_t *s; }; -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -Buffer *buffer_new(size_t blocksize, char *name); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -Buffer *buffer_new_str(char *name); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -Buffer *buffer_new_buf(char *name, void *data, size_t datasize); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_init(Buffer *b, size_t blocksize, char *name); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_free(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_clear(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_rewind(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add(Buffer *b, const void *data, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add_buf(Buffer *dst, Buffer *src); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add_str(Buffer *b, const char * fmt, ...); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add_hex(Buffer *b, void *data, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_resize(Buffer *b, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -int buffer_done(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -size_t buffer_get_chunk(Buffer *b, void *buf, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -size_t buffer_get_chunk_tobuf(Buffer *b, Buffer *dst, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -byte *buffer_get(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -char *buffer_get_str(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -byte *buffer_get_remainder(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -size_t buffer_extract(Buffer *b, void *buf, size_t offset, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -size_t buffer_fwd_offset(Buffer *b, size_t fwdby); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_dump(const Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_info(const Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -size_t buffer_size(const Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -size_t buffer_left(const Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint8_t buffer_get8(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint16_t buffer_get16(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint32_t buffer_get32(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint64_t buffer_get64(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint16_t buffer_get16na(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint32_t buffer_get32na(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint64_t buffer_get64na(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint8_t buffer_last8(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint16_t buffer_last16(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint32_t buffer_last32(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -uint64_t buffer_last64(Buffer *b); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -size_t buffer_fd_read(Buffer *b, FILE *in, size_t len); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add8(Buffer *b, uint8_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add16(Buffer *b, uint16_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add32(Buffer *b, uint32_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add64(Buffer *b, uint64_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add16be(Buffer *b, uint16_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add32be(Buffer *b, uint32_t v); - -/*** ./gencffi.pl: from ../../include/pcp/buffer.h:654 */ -void buffer_add64be(Buffer *b, uint64_t v); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:96 */ -PCPCTX *ptx_new(); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:96 */ -void ptx_clean(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:96 */ -void fatal(PCPCTX *ptx, const char * fmt, ...); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:96 */ -void fatals_ifany(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:96 */ -void fatals_reset(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:96 */ -void final(const char * fmt, ...); - -/*** ./gencffi.pl: from ../../include/pcp/context.h:96 */ -void ptx_dump(PCPCTX *ptx); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:343 */ -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:343 */ -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:343 */ -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:343 */ -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:343 */ -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:343 */ -void pcp_rec_free(pcp_rec_t *r); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:343 */ -byte *_gen_ctr_nonce(uint64_t ctr); - -/*** ./gencffi.pl: from ../../include/pcp/crypto.h:343 */ -uint64_t _get_nonce_ctr(byte *nonce); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:202 */ -byte *pcp_ed_sign(byte *message, size_t messagesize, pcp_key_t *s); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:202 */ -byte *pcp_ed_verify(PCPCTX *ptx, byte *signature, size_t siglen, pcp_pubkey_t *p); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:202 */ -byte *pcp_ed_verify_key(PCPCTX *ptx, byte *signature, size_t siglen, pcp_pubkey_t *p); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:202 */ -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:202 */ -pcp_pubkey_t *pcp_ed_verify_buffered(PCPCTX *ptx, Pcpstream *in, pcp_pubkey_t *p); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:202 */ -size_t pcp_ed_detachsign_buffered(Pcpstream *in, Pcpstream *out, pcp_key_t *s); - -/*** ./gencffi.pl: from ../../include/pcp/ed.h:202 */ -pcp_pubkey_t *pcp_ed_detachverify_buffered(PCPCTX *ptx, Pcpstream *in, Pcpstream *sigfd, pcp_pubkey_t *p); - -/*** ./gencffi.pl: from ../../include/pcp/getpass.h:22 */ -void pcp_echo_off(); - -/*** ./gencffi.pl: from ../../include/pcp/getpass.h:22 */ -void pcp_echo_on(); - -/*** ./gencffi.pl: from ../../include/pcp/getpass.h:22 */ -char *pcp_get_stdin(); - -/*** ./gencffi.pl: from ../../include/pcp/getpass.h:22 */ -char *pcp_get_passphrase(char *prompt); - -/*** ./gencffi.pl: from ../../include/pcp/jenhash.h:25 */ -unsigned jen_hash ( unsigned char *k, unsigned length, unsigned initval ); - -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ pcp_key_t *pcpkey_new (); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ void pcp_keypairs(byte *msk, byte *mpk, byte *csk, byte *cpk, byte *esk, byte *epk); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ char *pcppubkey_get_art(pcp_pubkey_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ char *pcpkey_get_art(pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ pcp_key_t *pcpkey_encrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ pcp_key_t *pcpkey_decrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ pcp_pubkey_t *pcpkey_pub_from_secret(pcp_key_t *key); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ char *pcp_getkeyid(pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ char *pcp_getpubkeyid(pcp_pubkey_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ byte *pcppubkey_getchecksum(pcp_pubkey_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ byte *pcpkey_getchecksum(pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ pcp_key_t * key2be(pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ pcp_key_t *key2native(pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ pcp_pubkey_t * pubkey2be(pcp_pubkey_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ pcp_pubkey_t *pubkey2native(pcp_pubkey_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ byte * pcp_gennonce(); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ byte *pcp_derivekey(PCPCTX *ptx, char *passphrase, byte *nonce); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ void pcp_seckeyblob(Buffer *b, pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ void pcp_pubkeyblob(Buffer *b, pcp_pubkey_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ Buffer *pcp_keyblob(void *k, int type); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ int pcp_sanitycheck_pub(PCPCTX *ptx, pcp_pubkey_t *key); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ int pcp_sanitycheck_key(PCPCTX *ptx, pcp_key_t *key); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ void pcp_dumpkey(pcp_key_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ void pcp_dumppubkey(pcp_pubkey_t *k); -/*** ./gencffi.pl: from ../../include/pcp/key.h:314 */ +/*** bindings/py/gencffi.pl: from include/pcp/key.h:314 */ void pcpkey_setowner(pcp_key_t *key, char *owner, char *mail); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -void pcphash_del(PCPCTX *ptx, void *key, int type); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +Buffer *buffer_new(size_t blocksize, char *name); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -void pcphash_clean(PCPCTX *ptx); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +Buffer *buffer_new_str(char *name); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -void pcphash_cleanpub(pcp_pubkey_t *pub); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +Buffer *buffer_new_buf(char *name, void *data, size_t datasize); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -pcp_key_t *pcphash_keyexists(PCPCTX *ptx, char *id); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_init(Buffer *b, size_t blocksize, char *name); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -pcp_pubkey_t *pcphash_pubkeyexists(PCPCTX *ptx, char *id); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_free(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -void pcphash_add(PCPCTX *ptx, void *key, int type); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_clear(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -int pcphash_count(PCPCTX *ptx); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_rewind(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -int pcphash_countpub(PCPCTX *ptx); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add(Buffer *b, const void *data, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/keyhash.h:153 */ -pcp_keysig_t *pcphash_keysigexists(PCPCTX *ptx, char *id); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add_buf(Buffer *dst, Buffer *src); -/*** ./gencffi.pl: from ../../include/pcp/keysig.h:50 */ -pcp_keysig_t *keysig2be(pcp_keysig_t *s); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add_str(Buffer *b, const char * fmt, ...); -/*** ./gencffi.pl: from ../../include/pcp/keysig.h:50 */ -pcp_keysig_t *keysig2native(pcp_keysig_t *s); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add_hex(Buffer *b, void *data, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/keysig.h:50 */ -Buffer *pcp_keysig2blob(pcp_keysig_t *s); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_resize(Buffer *b, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/keysig.h:50 */ -pcp_keysig_t *pcp_keysig_new(Buffer *blob); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +int buffer_done(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mem.h:58 */ -void *ucmalloc(size_t s); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +size_t buffer_get_chunk(Buffer *b, void *buf, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/mem.h:58 */ -void *smalloc(size_t s); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +size_t buffer_get_chunk_tobuf(Buffer *b, Buffer *dst, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/mem.h:58 */ -void *urmalloc(size_t s); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +byte *buffer_get(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mem.h:58 */ -void *srmalloc(size_t s); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +char *buffer_get_str(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mem.h:58 */ -void *ucrealloc(void *d, size_t oldlen, size_t newlen); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +byte *buffer_get_remainder(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mem.h:58 */ -void ucfree(void *d, size_t len); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +size_t buffer_extract(Buffer *b, void *buf, size_t offset, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/mem.h:58 */ -void sfree(void *d); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +size_t buffer_fwd_offset(Buffer *b, size_t fwdby); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -Buffer *pcp_export_rfc_pub (pcp_key_t *sk); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_dump(const Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -Buffer *pcp_export_pbp_pub(pcp_key_t *sk); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_info(const Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -Buffer *pcp_export_yaml_pub(pcp_key_t *sk); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +size_t buffer_size(const Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -Buffer *pcp_export_perl_pub(pcp_key_t *sk); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +size_t buffer_left(const Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -Buffer *pcp_export_c_pub(pcp_key_t *sk); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint8_t buffer_get8(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -Buffer *pcp_export_secret(PCPCTX *ptx, pcp_key_t *sk, char *passphrase); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint16_t buffer_get16(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -pcp_ks_bundle_t *pcp_import_binpub(PCPCTX *ptx, byte *raw, size_t rawsize); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint32_t buffer_get32(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -pcp_ks_bundle_t *pcp_import_pub(PCPCTX *ptx, byte *raw, size_t rawsize); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint64_t buffer_get64(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -pcp_ks_bundle_t *pcp_import_pub_rfc(PCPCTX *ptx, Buffer *blob); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint16_t buffer_get16na(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -pcp_ks_bundle_t *pcp_import_pub_pbp(PCPCTX *ptx, Buffer *blob); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint32_t buffer_get32na(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -pcp_key_t *pcp_import_binsecret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passphrase); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint64_t buffer_get64na(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -pcp_key_t *pcp_import_secret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passphrase); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint8_t buffer_last8(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphrase); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint16_t buffer_last16(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -int _check_keysig_h(PCPCTX *ptx, Buffer *blob, rfc_pub_sig_h *h); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint32_t buffer_last32(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -int _check_hash_keysig(PCPCTX *ptx, Buffer *blob, pcp_pubkey_t *p, pcp_keysig_t *sk); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +uint64_t buffer_last64(Buffer *b); -/*** ./gencffi.pl: from ../../include/pcp/mgmt.h:275 */ -int _check_sigsubs(PCPCTX *ptx, Buffer *blob, pcp_pubkey_t *p, rfc_pub_sig_s *subheader); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +size_t buffer_fd_read(Buffer *b, FILE *in, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -Pcpstream *ps_init(void); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add8(Buffer *b, uint8_t v); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -Pcpstream *ps_new_file(FILE *backendfd); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add16(Buffer *b, uint16_t v); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -Pcpstream *ps_new_inbuffer(Buffer *b); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add32(Buffer *b, uint32_t v); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -Pcpstream *ps_new_outbuffer(); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add64(Buffer *b, uint64_t v); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add16be(Buffer *b, uint16_t v); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add32be(Buffer *b, uint32_t v); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_finish(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/buffer.h:654 */ +void buffer_add64be(Buffer *b, uint64_t v); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_print(Pcpstream *stream, const char * fmt, ...); +/*** bindings/py/gencffi.pl: from include/pcp/context.h:96 */ +PCPCTX *ptx_new(); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_tell(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/context.h:96 */ +void ptx_clean(PCPCTX *ptx); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -Buffer *ps_buffer(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/context.h:96 */ +void fatal(PCPCTX *ptx, const char * fmt, ...); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -void ps_close(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/context.h:96 */ +void fatals_ifany(PCPCTX *ptx); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -int ps_end(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/context.h:96 */ +void fatals_reset(PCPCTX *ptx); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -int ps_err(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/context.h:96 */ +void final(const char * fmt, ...); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -void ps_setdetermine(Pcpstream *stream, size_t blocksize); +/*** bindings/py/gencffi.pl: from include/pcp/context.h:96 */ +void ptx_dump(PCPCTX *ptx); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -void ps_armor(Pcpstream *stream, size_t blocksize); +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:202 */ +byte *pcp_ed_sign(byte *message, size_t messagesize, pcp_key_t *s); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -void ps_unarmor(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:202 */ +byte *pcp_ed_verify(PCPCTX *ptx, byte *signature, size_t siglen, pcp_pubkey_t *p); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_read_decode(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:202 */ +byte *pcp_ed_verify_key(PCPCTX *ptx, byte *signature, size_t siglen, pcp_pubkey_t *p); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -void ps_determine(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:202 */ +size_t pcp_ed_sign_buffered(PCPCTX *ptx, Pcpstream *in, Pcpstream *out, pcp_key_t *s, int z85); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_read_next(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:202 */ +pcp_pubkey_t *pcp_ed_verify_buffered(PCPCTX *ptx, Pcpstream *in, pcp_pubkey_t *p); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes); +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:202 */ +size_t pcp_ed_detachsign_buffered(Pcpstream *in, Pcpstream *out, pcp_key_t *s); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -size_t ps_read_raw(Pcpstream *stream, void *buf, size_t readbytes); +/*** bindings/py/gencffi.pl: from include/pcp/ed.h:202 */ +pcp_pubkey_t *pcp_ed_detachverify_buffered(PCPCTX *ptx, Pcpstream *in, Pcpstream *sigfd, pcp_pubkey_t *p); -/*** ./gencffi.pl: from ../../include/pcp/pcpstream.h:291 */ -void ps_write_encode(Pcpstream *stream, Buffer *dst); +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:343 */ +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/pcpstream.h:291 */ -size_t ps_write_buf(Pcpstream *stream, Buffer *z); +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:343 */ +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/pcpstream.h:291 */ -int ps_left(Pcpstream *stream); +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:343 */ +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/pcpstream.h:291 */ -int ps_readline(Pcpstream *stream, Buffer *line); +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:343 */ +size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, pcp_rec_t *recverify); -/*** ./gencffi.pl: from ../../include/pcp/randomart.h:54 */ -char *key_fingerprint_randomart(unsigned char *dgst_raw, unsigned int dgst_raw_len); +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:343 */ +pcp_rec_t *pcp_rec_new(byte *cipher, size_t clen, pcp_key_t *secret, pcp_pubkey_t *pub); -/*** ./gencffi.pl: from ../../include/pcp/scrypt.h:42 */ -byte * pcp_scrypt(PCPCTX *ptx, char *passwd, size_t passwdlen, byte *nonce, size_t noncelen); +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:343 */ +void pcp_rec_free(pcp_rec_t *r); -/*** ./gencffi.pl: from ../../include/pcp/util.h:104 */ -char *_lc(char *in); +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:343 */ +byte *_gen_ctr_nonce(uint64_t ctr); -/*** ./gencffi.pl: from ../../include/pcp/util.h:104 */ -long int _findoffset(byte *bin, size_t binlen, char *sigstart, size_t hlen); +/*** bindings/py/gencffi.pl: from include/pcp/crypto.h:343 */ +uint64_t _get_nonce_ctr(byte *nonce); -/*** ./gencffi.pl: from ../../include/pcp/util.h:104 */ -void _xorbuf(byte *iv, byte *buf, size_t xlen); - -/*** ./gencffi.pl: from ../../include/pcp/util.h:104 */ -void _dump(char *n, byte *d, size_t s); - -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ vault_t *pcpvault_init(PCPCTX *ptx, char *filename); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ vault_t *pcpvault_new(PCPCTX *ptx, char *filename, int is_tmp); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ int pcpvault_create(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ int pcpvault_additem(PCPCTX *ptx, vault_t *vault, void *item, size_t itemsize, uint8_t type); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ int pcpvault_addkey(PCPCTX *ptx, vault_t *vault, void *item, uint8_t type); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ int pcpvault_close(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ void pcpvault_free(vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ int pcpvault_fetchall(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ int pcpvault_writeall(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ int pcpvault_copy(PCPCTX *ptx, vault_t *tmp, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ void pcpvault_unlink(vault_t *tmp); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ byte *pcpvault_create_checksum(PCPCTX *ptx); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ void pcpvault_update_checksum(PCPCTX *ptx, vault_t *vault); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ vault_header_t * vh2be(vault_header_t *h); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ vault_header_t * vh2native(vault_header_t *h); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ vault_item_header_t * ih2be(vault_item_header_t *h); -/*** ./gencffi.pl: from ../../include/pcp/vault.h:230 */ +/*** bindings/py/gencffi.pl: from include/pcp/vault.h:230 */ vault_item_header_t * ih2native(vault_item_header_t *h); -/*** ./gencffi.pl: from ../../include/pcp/version.h:35 */ -int pcp_version(); +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +Buffer *pcp_export_rfc_pub (pcp_key_t *sk); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +Buffer *pcp_export_pbp_pub(pcp_key_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +Buffer *pcp_export_yaml_pub(pcp_key_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +Buffer *pcp_export_perl_pub(pcp_key_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +Buffer *pcp_export_c_pub(pcp_key_t *sk); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +Buffer *pcp_export_secret(PCPCTX *ptx, pcp_key_t *sk, char *passphrase); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +pcp_ks_bundle_t *pcp_import_binpub(PCPCTX *ptx, byte *raw, size_t rawsize); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +pcp_ks_bundle_t *pcp_import_pub(PCPCTX *ptx, byte *raw, size_t rawsize); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +pcp_ks_bundle_t *pcp_import_pub_rfc(PCPCTX *ptx, Buffer *blob); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +pcp_ks_bundle_t *pcp_import_pub_pbp(PCPCTX *ptx, Buffer *blob); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +pcp_key_t *pcp_import_binsecret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passphrase); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +pcp_key_t *pcp_import_secret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passphrase); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphrase); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +int _check_keysig_h(PCPCTX *ptx, Buffer *blob, rfc_pub_sig_h *h); + +/*** bindings/py/gencffi.pl: from include/pcp/mgmt.h:275 */ +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:275 */ +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:153 */ +void pcphash_del(PCPCTX *ptx, void *key, int type); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:153 */ +void pcphash_clean(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:153 */ +void pcphash_cleanpub(pcp_pubkey_t *pub); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:153 */ +pcp_key_t *pcphash_keyexists(PCPCTX *ptx, char *id); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:153 */ +pcp_pubkey_t *pcphash_pubkeyexists(PCPCTX *ptx, char *id); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:153 */ +void pcphash_add(PCPCTX *ptx, void *key, int type); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:153 */ +int pcphash_count(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:153 */ +int pcphash_countpub(PCPCTX *ptx); + +/*** bindings/py/gencffi.pl: from include/pcp/keyhash.h:153 */ +pcp_keysig_t *pcphash_keysigexists(PCPCTX *ptx, char *id); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +Pcpstream *ps_init(void); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +Pcpstream *ps_new_file(FILE *backendfd); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +Pcpstream *ps_new_inbuffer(Buffer *b); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +Pcpstream *ps_new_outbuffer(); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_finish(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_print(Pcpstream *stream, const char * fmt, ...); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_tell(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +Buffer *ps_buffer(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +void ps_close(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +int ps_end(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +int ps_err(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +void ps_setdetermine(Pcpstream *stream, size_t blocksize); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +void ps_armor(Pcpstream *stream, size_t blocksize); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +void ps_unarmor(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_read_decode(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +void ps_determine(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_read_next(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_read_raw(Pcpstream *stream, void *buf, size_t readbytes); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +void ps_write_encode(Pcpstream *stream, Buffer *dst); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +size_t ps_write_buf(Pcpstream *stream, Buffer *z); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +int ps_left(Pcpstream *stream); + +/*** bindings/py/gencffi.pl: from include/pcp/pcpstream.h:291 */ +int ps_readline(Pcpstream *stream, Buffer *line); + +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ byte *pcp_padfour(byte *src, size_t srclen, size_t *dstlen); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ byte *pcp_z85_decode(PCPCTX *ptx, char *z85block, size_t *dstlen); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ char *pcp_z85_encode(byte *raw, size_t srclen, size_t *dstlen, int doblock); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ char *pcp_readz85file(PCPCTX *ptx, FILE *infile); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ char *pcp_readz85string(PCPCTX *ptx, byte *input, size_t bufsize); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ uint8_t is_utf8(const byte * bytes); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ size_t _buffer_is_binary(byte *buf, size_t len); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ uint8_t _parse_zchar(Buffer *z, uint8_t c, uint8_t is_comment); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ long int z85_header_startswith(Buffer *buf, char *what); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ int z85_isheader(Buffer *buf); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ int z85_isend(Buffer *buf); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ int z85_isbegin(Buffer *buf); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ int z85_iscomment(Buffer *buf); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ int z85_isempty(Buffer *line); -/*** ./gencffi.pl: from ../../include/pcp/z85.h:166 */ -int z85_isencoded(Buffer *line); +/*** bindings/py/gencffi.pl: from include/pcp/z85.h:166 */ +int z85_isencoded(Buffer *line);''' -/*** ./gencffi.pl: from ../../include/pcp/zmq_z85.h:31 */ -uint8_t *zmq_z85_decode (uint8_t *dest, char *string); - -/*** ./gencffi.pl: from ../../include/pcp/zmq_z85.h:31 */ -char *zmq_z85_encode (char *dest, uint8_t *data, size_t size);''' - -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ASYM_CIPHER = 5 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_C = 4 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_BLOCK_SIZE = 32 * 1024 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# 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:177 +# 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:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ENFILE_HEADER = "----- BEGIN PCP ENCRYPTED FILE -----\r\n" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_NATIVE = 1 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# 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:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_HASH_CIPHER = 0x22 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_HASH_NAME = "BLAKE2" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_NOTATION = 20 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_CIPHER_NAME = "ED25519" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_CIPHER = 0x23 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ZFILE_HEADER = "----- BEGIN Z85 ENCODED FILE -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIG_END = "----- END ED25519 SIGNATURE -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_PK_CIPHER = 0x21 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_KEY_PRIMITIVE = "CURVE25519-ED25519-SALSA20-POLY1305" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_RFC_CIPHER = 0x21 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ASYM_CIPHER_ANON = 6 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_PERL = 6 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# 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:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_YAML = 3 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SYM_CIPHER = 23 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_TYPE = 0x1F -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_PY = 5 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_KEYFLAGS = 27 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# 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:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIGPREFIX = "\nnacl-" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ME = "Pretty Curved Privacy" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ZFILE_FOOTER = "----- END Z85 ENCODED FILE -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_SIGEXPIRE = 3 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ENCRYPT_MAC = 56 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# 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:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_CTIME = 2 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_VAULT_ID = 14 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIG_HEADER = "----- BEGIN ED25519 SIGNED MESSAGE -----" -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_ASYM_CIPHER_SIG = 24 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# 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:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_FORMAT_PBP = 2 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_CRYPTO_ADD = (32 - 16) -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 EXP_SIG_SUB_KEYEXPIRE = 9 -# ./gencffi.pl: from ../../include/pcp/defines.h:177 +# bindings/py/gencffi.pl: from include/pcp/defines.h:177 PCP_SIG_START = "----- BEGIN ED25519 SIGNATURE -----" diff --git a/include/pcp.h b/include/pcp.h index d7def61..ed4bb53 100644 --- a/include/pcp.h +++ b/include/pcp.h @@ -7,6 +7,7 @@ extern "C" { #include "pcp/config.h" #include "pcp/buffer.h" +#include "pcp/config.h" #include "pcp/context.h" #include "pcp/crypto.h" #include "pcp/defines.h" diff --git a/libpcp/pcpstream.c b/libpcp/pcpstream.c index 4479016..3f25e00 100644 --- a/libpcp/pcpstream.c +++ b/libpcp/pcpstream.c @@ -1,7 +1,7 @@ /* This file is part of Pretty Curved Privacy (pcp1). - Copyright (C) 2013-2014 T.v.Dein. + Copyright (C) 2013-2015 T.v.Dein. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,7 +39,10 @@ Pcpstream *ps_init(void) { Pcpstream *ps_new_file(FILE *backendfd) { Pcpstream *stream = ps_init(); - stream->fd = backendfd; + if(backendfd == NULL) + stream->err = 1; + else + stream->fd = backendfd; return stream; } diff --git a/man/options.pod b/man/options.pod index 42c7f2f..c5d3298 100644 --- a/man/options.pod +++ b/man/options.pod @@ -9,6 +9,10 @@ will be used. -I --infile Input file. If not specified, stdin will be used. + -X --password-file Read passphrase from . If + is -, read from stdin. This takes + precedence over other uses of stdin + elsewhere, see below for more details. -i --keyid Specify a key id to import/export. -r --recipient Specify a recpipient, used for public key export and encryption. diff --git a/man/pcp.pod b/man/pcp.pod index 8b79d98..6daadfc 100644 --- a/man/pcp.pod +++ b/man/pcp.pod @@ -69,3 +69,36 @@ Oh - and if you're wondering why I named them Alicia and Bobby: I was just sick of Alice and Bob. We're running NSA-free, so we're using other sample names as well. +=head1 FILES AND PIPES + +Pcp behaves like any other unix tool. If not otherwise specified +it will read input from standard input (STDIN) and print output +to standard output (STDOUT). For instance: + + pcp1 -e -O output + +will read the text to be encrypted from standard input, because B<-I> +has not been specified. It works the same with B<-O>: + + pcp1 -e -I myfile + +In this case the encrypted result will be written to standard output. + +Therefore it is possible to use pcp within pipes. Another more +realistic example: + + ssh remote cat file | pcp1 -ez | mailx -s 'as requested' bob@somewhere + +here we encrypt a file symmetrically without downloading it from a +remote ssh server and sending the encrypted result via email to +someone. + +The behavior is the same with any other functionality where files are involved +like importing or exporting keys. However, there's one exception: +If the option B<-X> (B<--password-file>) has been used and is set +to B<->, then this will take precedence over any other possible use +of standard input. So if you want to encrypt something and don't +specify an input file you cannot use B<-X ->, and vice versa. IF +you use B<-X -> the passphrase will be read from standard input, which +then can't be used further for input files elsewhere. Pcp will exit +with an error in such a case. diff --git a/man/pcp1.1 b/man/pcp1.1 index e0d6459..109de92 100644 --- a/man/pcp1.1 +++ b/man/pcp1.1 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "PCP1 1" -.TH PCP1 1 "2015-04-19" "PCP 0.2.6" "USER CONTRIBUTED DOCUMENTATION" +.TH PCP1 1 "2015-05-30" "PCP 0.2.6" "USER CONTRIBUTED DOCUMENTATION" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -149,6 +149,7 @@ Pretty Curved Privacy \- File encryption using eliptic curve cryptography. \& \-V \-\-vault Specify an alternate vault file. \& \-O \-\-outfile Output file. STDOUT if unspecified. \& \-I \-\-infile Input file. STDIN if unspecified. +\& \-X \-\-password\-file Read passphrase from . \& \-i \-\-keyid Specify a key id for various operations. \& \-r \-\-recipient Specify a recpipient, multiple allowed. \& \-t \-\-text Print textual representation of ojects. @@ -195,6 +196,10 @@ Pretty Curved Privacy \- File encryption using eliptic curve cryptography. \& will be used. \& \-I \-\-infile Input file. If not specified, stdin \& will be used. +\& \-X \-\-password\-file Read passphrase from . If +\& is \-, read from stdin. This takes +\& precedence over other uses of stdin +\& elsewhere, see below for more details. \& \-i \-\-keyid Specify a key id to import/export. \& \-r \-\-recipient Specify a recpipient, used for public \& key export and encryption. @@ -392,6 +397,45 @@ to actually decrypt the message. Oh \- and if you're wondering why I named them Alicia and Bobby: I was just sick of Alice and Bob. We're running NSA-free, so we're using other sample names as well. +.SH "FILES AND PIPES" +.IX Header "FILES AND PIPES" +Pcp behaves like any other unix tool. If not otherwise specified +it will read input from standard input (\s-1STDIN\s0) and print output +to standard output (\s-1STDOUT\s0). For instance: +.PP +.Vb 1 +\& pcp1 \-e \-O output +.Ve +.PP +will read the text to be encrypted from standard input, because \fB\-I\fR +has not been specified. It works the same with \fB\-O\fR: +.PP +.Vb 1 +\& pcp1 \-e \-I myfile +.Ve +.PP +In this case the encrypted result will be written to standard output. +.PP +Therefore it is possible to use pcp within pipes. Another more +realistic example: +.PP +.Vb 1 +\& ssh remote cat file | pcp1 \-ez | mailx \-s \*(Aqas requested\*(Aq bob@somewhere +.Ve +.PP +here we encrypt a file symmetrically without downloading it from a +remote ssh server and sending the encrypted result via email to +someone. +.PP +The behavior is the same with any other functionality where files are involved +like importing or exporting keys. However, there's one exception: +If the option \fB\-X\fR (\fB\-\-password\-file\fR) has been used and is set +to \fB\-\fR, then this will take precedence over any other possible use +of standard input. So if you want to encrypt something and don't +specify an input file you cannot use \fB\-X \-\fR, and vice versa. \s-1IF\s0 +you use \fB\-X \-\fR the passphrase will be read from standard input, which +then can't be used further for input files elsewhere. Pcp will exit +with an error in such a case. .SH "PCP1 KEYS" .IX Header "PCP1 KEYS" \&\fBpcp1\fR keys are stored in a binary file, called \fBthe vault\fR. diff --git a/man/pcp1.pod b/man/pcp1.pod index 3e580b1..e6a4d0e 100644 --- a/man/pcp1.pod +++ b/man/pcp1.pod @@ -21,6 +21,7 @@ Pretty Curved Privacy - File encryption using eliptic curve cryptography. -V --vault Specify an alternate vault file. -O --outfile Output file. STDOUT if unspecified. -I --infile Input file. STDIN if unspecified. + -X --password-file Read passphrase from . -i --keyid Specify a key id for various operations. -r --recipient Specify a recpipient, multiple allowed. -t --text Print textual representation of ojects. @@ -66,6 +67,10 @@ Pretty Curved Privacy - File encryption using eliptic curve cryptography. will be used. -I --infile Input file. If not specified, stdin will be used. + -X --password-file Read passphrase from . If + is -, read from stdin. This takes + precedence over other uses of stdin + elsewhere, see below for more details. -i --keyid Specify a key id to import/export. -r --recipient Specify a recpipient, used for public key export and encryption. @@ -257,6 +262,39 @@ Oh - and if you're wondering why I named them Alicia and Bobby: I was just sick of Alice and Bob. We're running NSA-free, so we're using other sample names as well. +=head1 FILES AND PIPES + +Pcp behaves like any other unix tool. If not otherwise specified +it will read input from standard input (STDIN) and print output +to standard output (STDOUT). For instance: + + pcp1 -e -O output + +will read the text to be encrypted from standard input, because B<-I> +has not been specified. It works the same with B<-O>: + + pcp1 -e -I myfile + +In this case the encrypted result will be written to standard output. + +Therefore it is possible to use pcp within pipes. Another more +realistic example: + + ssh remote cat file | pcp1 -ez | mailx -s 'as requested' bob@somewhere + +here we encrypt a file symmetrically without downloading it from a +remote ssh server and sending the encrypted result via email to +someone. + +The behavior is the same with any other functionality where files are involved +like importing or exporting keys. However, there's one exception: +If the option B<-X> (B<--password-file>) has been used and is set +to B<->, then this will take precedence over any other possible use +of standard input. So if you want to encrypt something and don't +specify an input file you cannot use B<-X ->, and vice versa. IF +you use B<-X -> the passphrase will be read from standard input, which +then can't be used further for input files elsewhere. Pcp will exit +with an error in such a case. =head1 PCP1 KEYS diff --git a/src/encryption.c b/src/encryption.c index b614a39..666f0f8 100644 --- a/src/encryption.c +++ b/src/encryption.c @@ -1,7 +1,7 @@ /* This file is part of Pretty Curved Privacy (pcp1). - Copyright (C) 2013-2014 T.v.Dein. + Copyright (C) 2013-2015 T.v.Dein. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -67,7 +67,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i char *passphrase; if(passwd == NULL) { pcp_readpass(&passphrase, - "Enter passphrase for symetric decryption", NULL, 1); + "Enter passphrase for symetric decryption", NULL, 1, NULL); } else { passphrase = smalloc(strlen(passwd)+1); @@ -100,7 +100,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i char *passphrase; if(passwd == NULL) { pcp_readpass(&passphrase, - "Enter passphrase to decrypt your secret key", NULL, 1); + "Enter passphrase to decrypt your secret key", NULL, 1, NULL); } else { passphrase = smalloc(strlen(passwd)+1); @@ -174,7 +174,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec char *passphrase; if(passwd == NULL) { pcp_readpass(&passphrase, - "Enter passphrase for symetric encryption", "Repeat passphrase", 1); + "Enter passphrase for symetric encryption", "Repeat passphrase", 1, NULL); } else { passphrase = smalloc(strlen(passwd)+1); @@ -268,7 +268,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec char *passphrase; if(passwd == NULL) { pcp_readpass(&passphrase, - "Enter passphrase to decrypt your secret key", NULL, 1); + "Enter passphrase to decrypt your secret key", NULL, 1, NULL); } else { passphrase = smalloc(strlen(passwd)+1); diff --git a/src/keymgmt.c b/src/keymgmt.c index 87f0e1a..b0302d5 100644 --- a/src/keymgmt.c +++ b/src/keymgmt.c @@ -1,7 +1,7 @@ /* This file is part of Pretty Curved Privacy (pcp1). - Copyright (C) 2013 T.Linden. + Copyright (C) 2013-2015 T.Linden. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -79,7 +79,7 @@ void pcp_keygen(char *passwd) { if(passwd == NULL) { pcp_readpass(&passphrase, "Enter passphrase for key encryption", - "Enter the passphrase again", 1); + "Enter the passphrase again", 1, NULL); } else { passphrase = ucmalloc(strlen(passwd)+1); @@ -231,7 +231,7 @@ void pcp_exportsecret(char *keyid, int useid, char *outfile, int armor, char *pa if(passwd == NULL) { char *passphrase; pcp_readpass(&passphrase, - "Enter passphrase to decrypt your secret key", NULL, 1); + "Enter passphrase to decrypt your secret key", NULL, 1, NULL); key = pcpkey_decrypt(ptx, key, passphrase); if(key == NULL) { sfree(passphrase); @@ -255,7 +255,8 @@ void pcp_exportsecret(char *keyid, int useid, char *outfile, int armor, char *pa else { char *passphrase; pcp_readpass(&passphrase, - "Enter passphrase to encrypt the exported secret key", "Repeat passphrase", 1); + "Enter passphrase to encrypt the exported secret key", + "Repeat passphrase", 1, NULL); exported_sk = pcp_export_secret(ptx, key, passphrase); sfree(passphrase); } @@ -344,7 +345,7 @@ void pcp_exportpublic(char *keyid, char *passwd, char *outfile, int format, int else { char *passphrase; pcp_readpass(&passphrase, - "Enter passphrase to decrypt your secret key", NULL, 1); + "Enter passphrase to decrypt your secret key", NULL, 1, NULL); sk = pcpkey_decrypt(ptx, sk, passphrase); sfree(passphrase); } @@ -448,7 +449,7 @@ void pcpedit_key(char *keyid) { if(key != NULL) { if(key->secret[0] == 0) { char *passphrase; - pcp_readpass(&passphrase, "Enter passphrase to decrypt the key", NULL, 1); + pcp_readpass(&passphrase, "Enter passphrase to decrypt the key", NULL, 1, NULL); key = pcpkey_decrypt(ptx, key, passphrase); sfree(passphrase); } @@ -501,7 +502,7 @@ void pcpedit_key(char *keyid) { char *passphrase; pcp_readpass(&passphrase, "Enter new passphrase for key encryption (press enter to keep current)", - "Enter the passphrase again", 1); + "Enter the passphrase again", 1, NULL); if(strnlen(passphrase, 1024) > 0) { key = pcpkey_encrypt(ptx, key, passphrase); @@ -610,7 +611,7 @@ int pcp_import (vault_t *vault, FILE *in, char *passwd) { else { char *passphrase; pcp_readpass(&passphrase, - "Enter passphrase to decrypt the secret key file", NULL, 1); + "Enter passphrase to decrypt the secret key file", NULL, 1, NULL); sk = pcp_import_secret(ptx, buf, bufsize, passphrase); sfree(passphrase); } @@ -636,7 +637,7 @@ int pcp_import (vault_t *vault, FILE *in, char *passwd) { char *passphrase; pcp_readpass(&passphrase, "Enter passphrase for key encryption", - "Enter the passphrase again", 1); + "Enter the passphrase again", 1, NULL); if(strnlen(passphrase, 1024) > 0) { /* encrypt the key */ diff --git a/src/pcp.c b/src/pcp.c index 6088461..7413382 100644 --- a/src/pcp.c +++ b/src/pcp.c @@ -1,7 +1,7 @@ /* This file is part of Pretty Curved Privacy (pcp1). - Copyright (C) 2013 T.Linden. + Copyright (C) 2013-2015 T.Linden. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,8 +45,17 @@ char *default_vault() { return path; } +char *altin(char *infile, int stdinused) { + if(infile == NULL && stdinused == 1) { + fprintf(stderr, "Error: cannot use because -X had precedence!\n"); + exit(1); + } + return infile; +} + int main (int argc, char **argv) { - int opt, mode, usevault, useid, userec, lo, armor, detach, signcrypt, exportformat, anon; + int opt, mode, usevault, useid, userec, lo, armor, detach, \ + signcrypt, exportformat, anon, xpf; char *vaultfile = default_vault(); char *outfile = NULL; char *infile = NULL; @@ -54,6 +63,7 @@ int main (int argc, char **argv) { char *keyid = NULL; char *id = NULL; char *xpass = NULL; + char *xpassfile = NULL; char *extra = NULL; plist_t *recipient = NULL; FILE *in; @@ -69,6 +79,7 @@ int main (int argc, char **argv) { detach = 0; signcrypt = 0; anon = 0; + xpf = 0; exportformat = EXP_FORMAT_NATIVE; ptx = ptx_new(); @@ -81,6 +92,7 @@ int main (int argc, char **argv) { { "keyid", required_argument, NULL, 'i' }, { "text", required_argument, NULL, 't' }, { "xpass", required_argument, NULL, 'x' }, + { "password-file", required_argument, NULL, 'X' }, { "recipient", required_argument, NULL, 'r' }, /* key management */ @@ -123,7 +135,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:0KAM", + while ((opt = getopt_long(argc, argv, "klLV:vdehsO:i:I:pSPRtEx:DzaZr:gcymf:b1F:0KAMX:", longopts, NULL)) != -1) { switch (opt) { @@ -251,13 +263,18 @@ int main (int argc, char **argv) { strncpy(infile, optarg, strlen(optarg)+1); } break; + case 'X': + xpassfile = ucmalloc(strlen(optarg)+1); + strncpy(xpassfile, optarg, strlen(optarg)+1); + xpf = 1; + break; case 'i': keyid = ucmalloc(19); strncpy(keyid, optarg, 19); useid = 1; break; case 'x': - xpass = ucmalloc(strlen(optarg)+1); + xpass = smalloc(strlen(optarg)+1); strncpy(xpass, optarg, strlen(optarg)+1); if(strncmp(xpass, "n/a", 3) == 0) xpass[0] = '\0'; @@ -405,6 +422,13 @@ int main (int argc, char **argv) { free(extra); } + if(xpassfile != NULL) { + pcp_readpass(&xpass, "passphrase", NULL, 0, xpassfile); + if(xpassfile[0] != '-') + xpf = 0; + free(xpassfile); + } + /* check if there's some enviroment we could use */ if(usevault == 1) { char *_vaultfile = getenv("PCP_VAULT"); @@ -453,8 +477,10 @@ int main (int argc, char **argv) { break; case PCP_MODE_IMPORT: - if(infile == NULL) + if(infile == NULL) { + altin(NULL, xpf); in = stdin; + } else { if((in = fopen(infile, "rb")) == NULL) { fatal(ptx, "Could not open input file %s\n", infile); @@ -492,11 +518,11 @@ int main (int argc, char **argv) { if(useid == 1 && userec == 0) { /* one dst, FIXME: make id a list as well */ id = pcp_normalize_id(keyid); - pcpencrypt(id, infile, outfile, xpass, NULL, signcrypt, armor, anon); + pcpencrypt(id, altin(infile, xpf), outfile, xpass, NULL, signcrypt, armor, anon); } else if(useid == 0 && userec == 1) { /* multiple dst */ - pcpencrypt(NULL, infile, outfile, xpass, recipient, signcrypt, armor, anon); + pcpencrypt(NULL, altin(infile, xpf), outfile, xpass, recipient, signcrypt, armor, anon); } else { /* -i and -r specified */ @@ -509,11 +535,11 @@ int main (int argc, char **argv) { if(useid) { id = pcp_normalize_id(keyid); if(id != NULL) { - pcpdecrypt(id, useid, infile, outfile, xpass, signcrypt); + pcpdecrypt(id, useid, altin(infile, xpf), outfile, xpass, signcrypt); } } else { - pcpdecrypt(NULL, useid, infile, outfile, xpass, signcrypt); + pcpdecrypt(NULL, useid, altin(infile, xpf), outfile, xpass, signcrypt); } break; @@ -522,21 +548,21 @@ int main (int argc, char **argv) { if(outfile != NULL && sigfile != NULL) fatal(ptx, "You can't both specify -O and -f, use -O for std signatures and -f for detached ones\n"); else - pcpsign(infile, sigfile, xpass, armor, detach); + pcpsign(altin(infile, xpf), sigfile, xpass, armor, detach); } else - pcpsign(infile, outfile, xpass, armor, detach); + pcpsign(altin(infile, xpf), outfile, xpass, armor, detach); break; case PCP_MODE_VERIFY: if(useid) { id = pcp_normalize_id(keyid); if(id != NULL) { - pcpverify(infile, sigfile, id, detach); + pcpverify(altin(infile, xpf), sigfile, id, detach); } } else { - pcpverify(infile, sigfile, NULL, detach); + pcpverify(altin(infile, xpf), sigfile, NULL, detach); } break; @@ -564,7 +590,7 @@ int main (int argc, char **argv) { break; case PCP_MODE_ENCRYPT_ME: - pcpencrypt(NULL, infile, outfile, xpass, NULL, 0, armor, 0); + pcpencrypt(NULL, altin(infile, xpf), outfile, xpass, NULL, 0, armor, 0); break; case PCP_MODE_TEXT: @@ -606,7 +632,7 @@ int main (int argc, char **argv) { if(sigfile != NULL) free(sigfile); if(xpass != NULL) - ucfree(xpass, strlen(xpass)); + sfree(xpass); if(recipient != NULL) p_clean(recipient); if(id != NULL) diff --git a/src/readpass.c b/src/readpass.c index ddd5986..6ff7faa 100644 --- a/src/readpass.c +++ b/src/readpass.c @@ -40,7 +40,7 @@ */ int pcp_readpass(char ** passwd, const char * prompt, - const char * confirmprompt, int devtty) + const char * confirmprompt, int devtty, char *readfromfile) { FILE * readfrom; char passbuf[MAXPASSLEN]; @@ -51,9 +51,27 @@ pcp_readpass(char ** passwd, const char * prompt, /* * If devtty != 0, try to open /dev/tty; if that fails, or if devtty * is zero, we'll read the password from stdin instead. + * + * Added by tlinden: however, if readfromfile is defined, we'll + * read the password from there, but if it is '-' we'll use stdin + * as well. */ - if ((devtty == 0) || ((readfrom = fopen("/dev/tty", "r")) == NULL)) - readfrom = stdin; + if ((devtty == 0) || ((readfrom = fopen("/dev/tty", "r")) == NULL)) { + if(readfromfile != NULL) { + if(readfromfile[0] == '-') { + readfrom = stdin; + } + else { + if((readfrom = fopen(readfromfile, "r")) == NULL) { + fatal(ptx, "Could not open password file '%s'\n", readfromfile); + goto err1; + } + } + } + else { + readfrom = stdin; + } + } /* If we're reading from a terminal, try to disable echo. */ if ((usingtty = isatty(fileno(readfrom))) != 0) { @@ -102,20 +120,20 @@ retry: if (usingtty) tcsetattr(fileno(readfrom), TCSANOW, &term_old); - /* Close /dev/tty if we opened it. */ - if (readfrom != stdin) - fclose(readfrom); + /* Close /dev/tty if we opened it. + if readfromfile is defined and set to -, disable stdin */ + if (readfrom != stdin) { + fclose(readfrom); + } + else { + if(readfromfile != NULL) + stdin = NULL; + } /* Copy the password out. */ char *p = smalloc(strlen(passbuf) + 1); memcpy(p, passbuf, strlen(passbuf) + 1 ); *passwd = p; - /* - if ((*passwd = strdup(passbuf)) == NULL) { - fatal(ptx, "Cannot allocate memory\n"); - goto err1; - } - */ /* Zero any stored passwords. */ memset(passbuf, 0, MAXPASSLEN); diff --git a/src/readpass.h b/src/readpass.h index ee5d5f0..477e942 100644 --- a/src/readpass.h +++ b/src/readpass.h @@ -52,6 +52,6 @@ * ${passwd}. The obscure name is to avoid namespace collisions due to the * getpass / readpass / readpassphrase / etc. functions in various libraries. */ -int pcp_readpass(char **, const char *, const char *, int); +int pcp_readpass(char **, const char *, const char *, int, char *); #endif /* !_READPASS_H_ */ diff --git a/src/signature.c b/src/signature.c index 935b559..3fc38cc 100644 --- a/src/signature.c +++ b/src/signature.c @@ -1,7 +1,7 @@ /* This file is part of Pretty Curved Privacy (pcp1). - Copyright (C) 2013 T.Linden. + Copyright (C) 2013-2015 T.Linden. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -59,7 +59,7 @@ int pcpsign(char *infile, char *outfile, char *passwd, int z85, int detach) { char *passphrase; if(passwd == NULL) { pcp_readpass(&passphrase, - "Enter passphrase to decrypt your secret key", NULL, 1); + "Enter passphrase to decrypt your secret key", NULL, 1, NULL); } else { passphrase = smalloc(strlen(passwd)+1); diff --git a/src/usage.h b/src/usage.h index e3e49ea..d005cce 100644 --- a/src/usage.h +++ b/src/usage.h @@ -16,6 +16,7 @@ "-V --vault Specify an alternate vault file.\n" \ "-O --outfile Output file. STDOUT if unspecified.\n" \ "-I --infile Input file. STDIN if unspecified.\n" \ +"-X --password-file Read passphrase from .\n" \ "-i --keyid Specify a key id for various operations.\n" \ "-r --recipient Specify a recpipient, multiple allowed.\n" \ "-t --text Print textual representation of ojects.\n" \ diff --git a/src/usage.txt b/src/usage.txt index 6f4ca8d..45735b1 100644 --- a/src/usage.txt +++ b/src/usage.txt @@ -14,6 +14,7 @@ General Options: -V --vault Specify an alternate vault file. -O --outfile Output file. STDOUT if unspecified. -I --infile Input file. STDIN if unspecified. +-X --password-file Read passphrase from . -i --keyid Specify a key id for various operations. -r --recipient Specify a recpipient, multiple allowed. -t --text Print textual representation of ojects.