From 5d49880f4d8b61cb58abeca6cd6876241c0096d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Mar 2018 11:56:22 +0200 Subject: [PATCH] "Decrypt" unencrypted --- iguana/exchanges/LP_privkey.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index f21ac86ac..6552cfbf0 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/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)