context fixes

This commit is contained in:
TLINDEN
2014-05-06 11:49:31 +02:00
parent db264ff16b
commit 729c137e3c
11 changed files with 48 additions and 44 deletions

View File

@@ -25,7 +25,7 @@
using namespace std;
using namespace pcp;
Crypto::Crypto(PcpContext C, Key &skey, PubKey &pkey) {
Crypto::Crypto(PcpContext &C, Key &skey, PubKey &pkey) {
P = pkey;
S = skey;
PTX = C;
@@ -33,7 +33,7 @@ Crypto::Crypto(PcpContext C, Key &skey, PubKey &pkey) {
pcphash_add(PTX.ptx, P.K, PCP_KEY_TYPE_PUBLIC);
}
Crypto::Crypto(PcpContext C, Vault &v, Key &skey, PubKey &pkey) {
Crypto::Crypto(PcpContext &C, Vault &v, Key &skey, PubKey &pkey) {
P = pkey;
S = skey;
PTX = C;
@@ -47,6 +47,7 @@ bool Crypto::encrypt(FILE *in, FILE *out, bool sign) {
//HASH_ADD_STR( pubhash, id, P.K);
Pcpstream *pin = ps_new_file(in);
Pcpstream *pout = ps_new_file(out);
ptx_dump(PTX.ptx);
size_t clen = pcp_encrypt_stream(PTX.ptx, pin, pout, S.K, pubhash, sign);
if(clen <= 0)
throw exception(PTX);
@@ -58,6 +59,7 @@ bool Crypto::encrypt(FILE *in, FILE *out, bool sign) {
bool Crypto::decrypt(FILE *in, FILE *out, bool verify) {
Pcpstream *pin = ps_new_file(in);
Pcpstream *pout = ps_new_file(out);
ptx_dump(PTX.ptx);
if(pcp_decrypt_stream(PTX.ptx, pin, pout, S.K, NULL, verify) <= 0)
throw exception(PTX);
ps_close(pin);