mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-16 19:40:57 +01:00
fixed decrypt from out buf
This commit is contained in:
20
TODO
20
TODO
@@ -1,23 +1,3 @@
|
||||
[15.Aug 14:29:22] --- [~/pcp/tests] ---
|
||||
% pcp1 -K key-alicia-pub
|
||||
Could not open input file <20>fz
|
||||
Error: No such file or directory
|
||||
*** Error in `pcp1': double free or corruption (top): 0x000000000208e460 ***
|
||||
Aborted
|
||||
|
||||
|
||||
% tests/sample
|
||||
hh: 56
|
||||
Alice encrypted 11 bytes for Bob:
|
||||
Pcpstreamoutbuf (0160): 05000000017842cd4e82f2ec585398765a2d0439197f5ce67984b22c4aa3d0f649929b21
|
||||
2d6d4b32538ce61e0cb3ed3a3f546fd214ece9c026febeb4f59c92338ab8d89496bb35a1
|
||||
a685abe4230101c0c69116fe04d552325c6722f2991df47631496253e8c6f27310e94852
|
||||
76c71f9f4cae4f22eb8f3e87b1898ff32131d88b19000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
Error: input file corrupted, incomplete or no recipients (got 53, exp 72)
|
||||
Error: Invalid argument
|
||||
*** Error in `tests/sample': double free or corruption (!prev): 0x0000000001893a30 ***
|
||||
Aborted
|
||||
|
||||
|
||||
If with -k passphrase has been retrieved interactively, ask
|
||||
|
||||
@@ -4,7 +4,7 @@ int main() {
|
||||
Buffer *inbuf;
|
||||
pcp_key_t *alice, *bob;
|
||||
pcp_pubkey_t *alicepub, *bobpub, *pubhash;
|
||||
Pcpstream *clear_in, *crypt_out, *clear_out;
|
||||
Pcpstream *clear_in, *crypt_out, *clear_out, *crypt_in;
|
||||
PCPCTX *ptx;
|
||||
char message[] = "hello world";
|
||||
|
||||
@@ -47,15 +47,18 @@ int main() {
|
||||
/* prepare the output buffer stream */
|
||||
clear_out = ps_new_outbuffer();
|
||||
|
||||
/* input buffer stream from crypto output */
|
||||
crypt_in = ps_new_inbuffer(ps_buffer(crypt_out));
|
||||
|
||||
/* in order for the decryptor find the senders public key,
|
||||
we need to put it into the context hash. this step can be
|
||||
omitted when using a Vault. */
|
||||
pcphash_add(ptx, alicepub, alicepub->type);
|
||||
|
||||
buffer_info(crypt_out->b);
|
||||
buffer_info(crypt_in->b);
|
||||
|
||||
/* try to decrypt the message */
|
||||
if(pcp_decrypt_stream(ptx, crypt_out, clear_out, bob, NULL, 0, 0) == 0)
|
||||
if(pcp_decrypt_stream(ptx, crypt_in, clear_out, bob, NULL, 0, 0) == 0)
|
||||
fatals_ifany(ptx);
|
||||
else {
|
||||
/* and finally print out the decrypted message */
|
||||
@@ -64,6 +67,7 @@ int main() {
|
||||
}
|
||||
|
||||
ps_close(clear_in);
|
||||
ps_close(crypt_in);
|
||||
ps_close(crypt_out);
|
||||
ps_close(clear_out);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user