Browse Source

"Decrypt" unencrypted

jl777
jl777 7 years ago
parent
commit
5d49880f4d
  1. 23
      iguana/exchanges/LP_privkey.c

23
iguana/exchanges/LP_privkey.c

@ -571,14 +571,23 @@ uint8_t *JPG_decrypt(uint16_t *indp,int32_t *recvlenp,uint8_t space[JPG_ENCRYPTE
int32_t LP_opreturn_decrypt(uint16_t *ind16p,uint8_t *decoded,uint8_t *encoded,int32_t encodedlen,char *passphrase)
{
bits256 privkey; int32_t msglen; uint8_t *extracted,space[JPG_ENCRYPTED_MAXSIZE + crypto_box_ZEROBYTES];
vcalc_sha256(0,privkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
msglen = ((int32_t)encoded[1] << 8) | encoded[0];
*ind16p = ((int32_t)encoded[3] << 8) | encoded[2];
if ( msglen == encodedlen && (extracted= JPG_decrypt(ind16p,&msglen,space,encoded,privkey)) != 0 )
if ( passphrase != 0 && passphrase[0] != 0 )
{
vcalc_sha256(0,privkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
msglen = ((int32_t)encoded[1] << 8) | encoded[0];
*ind16p = ((int32_t)encoded[3] << 8) | encoded[2];
if ( msglen == encodedlen && (extracted= JPG_decrypt(ind16p,&msglen,space,encoded,privkey)) != 0 )
{
memcpy(decoded,extracted,msglen);
return(msglen);
} else return(-1);
}
else
{
memcpy(decoded,extracted,msglen);
return(msglen);
} else return(-1);
*ind16p = calc_crc32(0,extracted,encodedlen);
memcpy(decoded,extracted,encodedlen);
return(encodedlen);
}
}
int32_t LP_opreturn_encrypt(uint8_t *dest,int32_t maxsize,uint8_t *data,int32_t datalen,char *passphrase,uint16_t ind16)

Loading…
Cancel
Save