mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
context fixes
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user