This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit 90938eb4 authored by g3gg0's avatar g3gg0
Browse files

io_crypt: fix crash situation by processing in separate thread (gives caller...

io_crypt: fix crash situation by processing in separate thread (gives caller thread's CPU time and allows lower priority tasks which are necessary to run)

--HG--
branch : unified
parent 536fbadfcc31
......@@ -70,7 +70,7 @@ char *module_card_drive = "";
#include "bigd.h"
#include "bigdigits.h"
#define assert(x) do {} while(0)
#define assert(x) do { if(!(x)){ beep(); NotifyBox(5000, "ASSERT: "#x ); return -1;} } while(0)
static uint32_t crypt_rsa_keysize = 1024;
extern uint32_t iocrypt_trace_ctx;
......@@ -231,20 +231,18 @@ int generateRSAPrime(BIGD p, size_t nbits, bdigit_t e, size_t ntests,
int generateRSAKey(BIGD n, BIGD e, BIGD d, BIGD p, BIGD q, BIGD dP, BIGD dQ, BIGD qInv,
size_t nbits, bdigit_t ee, size_t ntests, unsigned char *seed, size_t seedlen,
BD_RANDFUNC randFunc)
BD_RANDFUNC randFunc, uint32_t *progress)
{
BIGD g, p1, q1, phi;
size_t np, nq;
unsigned char *myseed = NULL;
/* Initialise */
g = bdNew();
p1 = bdNew();
q1 = bdNew();
phi = bdNew();
// printf("Generating a %d-bit RSA key...\n", nbits);
/* We add an extra byte to the user-supplied seed */
myseed = (unsigned char*)malloc(seedlen + 1);
if (!myseed)
......@@ -258,16 +256,20 @@ int generateRSAKey(BIGD n, BIGD e, BIGD d, BIGD p, BIGD q, BIGD dP, BIGD dQ, BIG
np = nbits - nq;
/* Make sure seeds are slightly different for p and q */
*progress = 1;
myseed[seedlen] = rand();
generateRSAPrime(p, np, ee, ntests, myseed, seedlen+1, randFunc);
*progress = 33;
myseed[seedlen] = rand();
generateRSAPrime(q, nq, ee, ntests, myseed, seedlen+1, randFunc);
*progress = 66;
/* Check that p != q (if so, RNG is faulty!) */
assert(!bdIsEqual(p, q));
generateRSAPrime(e, nq, ee, ntests, myseed, seedlen+1, randFunc);
*progress = 95;
/* If q > p swap p and q so p > q */
if (bdCompare(p, q) < 1)
......@@ -312,11 +314,12 @@ int generateRSAKey(BIGD n, BIGD e, BIGD d, BIGD p, BIGD q, BIGD dP, BIGD dQ, BIG
bdFree(&q1);
bdFree(&phi);
*progress = 98;
return 0;
}
int crypt_rsa_generate(int nbits, t_crypt_key *priv_key, t_crypt_key *pub_key)
int crypt_rsa_generate(int nbits, t_crypt_key *priv_key, t_crypt_key *pub_key, uint32_t *progress)
{
int res = 0;
char *buffer = NULL;
......@@ -337,7 +340,10 @@ int crypt_rsa_generate(int nbits, t_crypt_key *priv_key, t_crypt_key *pub_key)
qInv = bdNew();
/* Create RSA key pair (n, e),(d, p, q, dP, dQ, qInv) */
res = generateRSAKey(n, e, d, p, q, dP, dQ, qInv, nbits+1, 3, 50, NULL, 0, crypt_rsa_rand);
char seed[256];
rand_fill(seed, sizeof(seed)/4);
res = generateRSAKey(n, e, d, p, q, dP, dQ, qInv, nbits+1, 3, 50, seed, sizeof(seed), crypt_rsa_rand, progress);
if(res != 0)
{
......@@ -407,8 +413,10 @@ clean_up:
bdFree(&dP);
bdFree(&dQ);
bdFree(&qInv);
*progress = 99;
return 0;
return res;
}
......@@ -476,6 +484,19 @@ t_crypt_key *crypt_rsa_get_pub(void *priv)
return &ctx->pub_key;
}
uint32_t crypt_rsa_get_keyprogress(crypt_priv_t *priv)
{
if(!priv)
{
return 0;
}
rsa_ctx_t *ctx = (rsa_ctx_t *)priv;
return ctx->progress;
}
/* returns the key size in bits */
uint32_t crypt_rsa_get_keysize(void *priv)
{
......@@ -526,7 +547,7 @@ static uint32_t crypt_rsa_encrypt(crypt_priv_t *priv, uint8_t *dst, uint8_t *src
if(crypt_rsa_blocksize(ctx) > length)
{
trace_write(iocrypt_trace_ctx, "crypt_rsa_decrypt: key size mismatch %d vs. %d", crypt_rsa_blocksize(ctx), length);
trace_write(iocrypt_trace_ctx, "crypt_rsa_encrypt: key size mismatch %d vs. %d", crypt_rsa_blocksize(ctx), length);
return 0;
}
......@@ -534,7 +555,7 @@ static uint32_t crypt_rsa_encrypt(crypt_priv_t *priv, uint8_t *dst, uint8_t *src
if(new_len > length)
{
trace_write(iocrypt_trace_ctx, "crypt_rsa_decrypt: buffer overflow %d vs. %d", new_len, length);
trace_write(iocrypt_trace_ctx, "crypt_rsa_encrypt: new size %d vs. %d old size", new_len, length);
return 0;
}
......@@ -660,12 +681,11 @@ void crypt_rsa_generate_keys(void *priv)
t_crypt_key pub_key;
rsa_ctx_t *ctx = (rsa_ctx_t *)priv;
trace_write(iocrypt_trace_ctx, "io_crypt: crypt_rsa_generate %d...", crypt_rsa_keysize);
crypt_rsa_generate(crypt_rsa_keysize, &priv_key, &pub_key);
ctx->progress = 0;
trace_write(iocrypt_trace_ctx, "io_crypt: crypt_rsa_generate %d", crypt_rsa_keysize);
crypt_rsa_generate(crypt_rsa_keysize, &priv_key, &pub_key, &ctx->progress);
trace_write(iocrypt_trace_ctx, "io_crypt: crypt_rsa_generate %d done", crypt_rsa_keysize);
NotifyBoxHide();
beep();
NotifyBox(2000, "RSA key generated!");
crypt_rsa_save("ML/DATA/io_crypt.key", &priv_key);
crypt_rsa_save("ML/DATA/io_crypt.pub", &pub_key);
......@@ -676,15 +696,18 @@ void crypt_rsa_generate_keys(void *priv)
crypt_rsa_load("ML/DATA/io_crypt.pub", &ctx->pub_key);
crypt_rsa_load("ML/DATA/io_crypt.key", &ctx->priv_key);
ctx->progress = 100;
}
static uint32_t crypt_rsa_testfunc(int size, t_crypt_key *priv_key, t_crypt_key *pub_key)
{
uint32_t ret = 0;
uint32_t progress = 0;
NotifyBox(2000, "crypt_rsa_generate %d...", size);
trace_write(iocrypt_trace_ctx, "io_crypt: crypt_rsa_generate %d...", size);
crypt_rsa_generate(size, priv_key, pub_key);
crypt_rsa_generate(size, priv_key, pub_key, &progress);
trace_write(iocrypt_trace_ctx, "io_crypt: crypt_rsa_generate %d done", size);
NotifyBox(2000, "crypt_rsa_generate %d... DONE", size);
......@@ -789,8 +812,12 @@ void crypt_rsa_init(crypt_cipher_t *crypt_ctx)
crypt_rsa_load("ML/DATA/io_crypt.key", &ctx->priv_key);
crypt_rsa_load("io_crypt.pub", &ctx->pub_key);
crypt_rsa_load("io_crypt.key", &ctx->priv_key);
trace_write(iocrypt_trace_ctx, "crypt_rsa_init: loaded %d bit key", crypt_rsa_get_keysize(ctx));
trace_write(iocrypt_trace_ctx, "crypt_rsa_init: initialized");
}
......
......@@ -13,12 +13,14 @@ typedef struct
{
t_crypt_key pub_key;
t_crypt_key priv_key;
uint32_t progress;
} rsa_ctx_t;
t_crypt_key *crypt_rsa_get_priv(crypt_priv_t *priv);
t_crypt_key *crypt_rsa_get_pub(crypt_priv_t *priv);
uint32_t crypt_rsa_get_keysize(crypt_priv_t *priv);
uint32_t crypt_rsa_get_keyprogress(crypt_priv_t *priv);
uint32_t crypt_rsa_blocksize(crypt_priv_t *priv);
void crypt_rsa_generate_keys(crypt_priv_t *priv);
void crypt_rsa_set_keysize(uint32_t size);
......
......@@ -38,9 +38,12 @@ static crypt_cipher_t iocrypt_rsa_ctx;
static fd_map_t iocrypt_files[32];
static struct semaphore *iocrypt_password_sem = 0;
static struct semaphore *iocrypt_scratch_sem = 0;
static char iocrypt_ime_text[128];
/* crypt thread data */
struct msg_queue *iocrypt_msgs = NULL;
static uint32_t iocrypt_shutdown = 0;
/* those are model specific */
static uint32_t iodev_table = 0;
static uint32_t iodev_ctx = 0;
......@@ -141,7 +144,7 @@ static uint32_t iocrypt_asym_init(int fd)
{
uint64_t file_key = 0;
uint32_t lfsr_blocksize = (8192 << iocrypt_block_size);
uint32_t blocksize = crypt_rsa_blocksize(&iocrypt_rsa_ctx);
uint32_t blocksize = crypt_rsa_blocksize(iocrypt_rsa_ctx.priv);
trace_write(iocrypt_trace_ctx, "iocrypt_save_asym_hdr: block size %d bytes, lfsr_blocksize %d bytes", blocksize, lfsr_blocksize);
if(!blocksize)
......@@ -155,7 +158,24 @@ static uint32_t iocrypt_asym_init(int fd)
memcpy(&file_key, key, sizeof(uint64_t));
/* encrypt the randomly generated per-file header with RSA public key */
uint32_t encrypted_size = iocrypt_rsa_ctx.encrypt(&iocrypt_rsa_ctx, (uint8_t*)key, (uint8_t*)key, blocksize, 0);
iocrypt_job_t job;
job.type = CRYPT_JOB_ENCRYPT;
job.semaphore = iocrypt_files[fd].semaphore;
job.ctx = &iocrypt_rsa_ctx;
job.dst = key;
job.buf = key;
job.length = blocksize;
job.fd_pos = 0;
trace_write(iocrypt_trace_ctx, "iocrypt_asym_init: encrypt");
msg_queue_post(iocrypt_msgs, &job);
/* wait until worker finished */
take_semaphore(job.semaphore, 0);
trace_write(iocrypt_trace_ctx, "iocrypt_asym_init: encrypt done");
uint32_t encrypted_size = job.ret;
/* write header, block size and encrypted key */
orig_iodev->WriteFile(fd, (uint8_t*)rsa_magic, 4);
......@@ -226,7 +246,7 @@ static uint32_t hook_iodev_OpenFile(void *iodev, char *filename, int32_t flags,
trace_write(iocrypt_trace_ctx, "iodev_OpenFile('%s', %d) = %d", filename, flags, fd);
if(fd < COUNT(iocrypt_files) && iocrypt_enabled && !drive_mode)
if(fd < COUNT(iocrypt_files) && iocrypt_enabled)
{
iocrypt_files[fd].crypt_ctx.priv = NULL;
iocrypt_files[fd].header_size = 0;
......@@ -349,7 +369,7 @@ static uint32_t hook_iodev_OpenFile(void *iodev, char *filename, int32_t flags,
{
trace_write(iocrypt_trace_ctx, " FAILED TO SET UP ENCRYPTION");
beep();
NotifyBox(2000, "No key entered, not encrypting!");
NotifyBox(2000, "RSA setup failed!");
break;
}
break;
......@@ -376,7 +396,7 @@ static uint32_t hook_iodev_OpenFile(void *iodev, char *filename, int32_t flags,
static uint32_t hook_iodev_ReadFile(uint32_t fd, uint8_t *buf, uint32_t length)
{
if(!iocrypt_enabled || drive_mode)
if(!iocrypt_enabled)
{
return orig_iodev->ReadFile(fd, buf, length);
}
......@@ -411,9 +431,24 @@ static uint32_t hook_iodev_ReadFile(uint32_t fd, uint8_t *buf, uint32_t length)
if(iocrypt_files[fd].crypt_ctx.priv)
{
trace_write(iocrypt_trace_ctx, " ->> DECRYPT");
iocrypt_files[fd].crypt_ctx.decrypt(iocrypt_files[fd].crypt_ctx.priv, buf, buf, length, fd_pos);
trace_write(iocrypt_trace_ctx, " ->> DONE");
/* let the data being encrypted asynchronously */
iocrypt_job_t job;
job.type = CRYPT_JOB_DECRYPT;
job.fd = fd;
job.semaphore = iocrypt_files[fd].semaphore;
job.ctx = &iocrypt_files[fd].crypt_ctx;
job.dst = buf;
job.buf = buf;
job.length = length;
job.fd_pos = fd_pos;
trace_write(iocrypt_trace_ctx, "iodev_ReadFile: decrypt");
msg_queue_post(iocrypt_msgs, &job);
/* wait until worker finished */
take_semaphore(job.semaphore, 0);
trace_write(iocrypt_trace_ctx, "iodev_ReadFile: decrypt done");
}
}
......@@ -424,52 +459,42 @@ static uint32_t hook_iodev_WriteFile(uint32_t fd, uint8_t *buf, uint32_t length)
{
uint32_t ret = 0;
if(fd < COUNT(iocrypt_files) && iocrypt_enabled && !drive_mode)
if(fd < COUNT(iocrypt_files) && iocrypt_enabled)
{
uint8_t *work_ptr = buf;
uint32_t misalign = ((uint32_t)buf) % 8;
uint32_t fd_pos = iodev_GetPosition(fd);
if(iocrypt_files[fd].crypt_ctx.priv)
{
trace_write(iocrypt_trace_ctx, "iodev_WriteFile pre(0x%08X, 0x%08X) -> %s, fd = %d, fd_pos = 0x%08X, misalign = %d", buf, length, iocrypt_files[fd].filename, fd, fd_pos, misalign);
/* if there is no buffer or the size is too big, do expensive in-place encryption */
if(iocrypt_scratch && (length <= CRYPT_SCRATCH_SIZE))
{
take_semaphore(iocrypt_scratch_sem, 0);
/* update buffer to write from */
work_ptr = &iocrypt_scratch[misalign];
trace_write(iocrypt_trace_ctx, " ->> double buffered");
}
trace_write(iocrypt_trace_ctx, " ->> ENCRYPT");
iocrypt_files[fd].crypt_ctx.encrypt(iocrypt_files[fd].crypt_ctx.priv, work_ptr, buf, length, fd_pos);
trace_write(iocrypt_trace_ctx, " ->> DONE");
/* when there is some encryption active, handle file offset */
iodev_SetPosition(fd, iodev_GetPosition(fd) + iocrypt_files[fd].header_size);
ret = orig_iodev->WriteFile(fd, work_ptr, length);
/* let the data being encrypted asynchronously */
iocrypt_job_t job;
job.type = CRYPT_JOB_ENCRYPT_WRITE;
job.fd = fd;
job.semaphore = iocrypt_files[fd].semaphore;
job.ctx = &iocrypt_files[fd].crypt_ctx;
job.buf = buf;
job.length = length;
job.fd_pos = fd_pos;
trace_write(iocrypt_trace_ctx, "iodev_WriteFile: encrypt");
msg_queue_post(iocrypt_msgs, &job);
/* wait until worker finished */
take_semaphore(job.semaphore, 0);
trace_write(iocrypt_trace_ctx, "iodev_WriteFile: encrypt done");
/* when there is some encryption active, handle file offset */
iodev_SetPosition(fd, iodev_GetPosition(fd) - iocrypt_files[fd].header_size);
trace_write(iocrypt_trace_ctx, "iodev_WriteFile post(0x%08X, 0x%08X) -> fd = %d, fd_pos = 0x%08X, fd_pos (now) = 0x%08X", buf, length, fd, fd_pos, iodev_GetPosition(fd));
/* if we were not able to write it from scratch, undo in-place encryption */
if(work_ptr == buf)
{
trace_write(iocrypt_trace_ctx, " ->> CLEANUP");
iocrypt_files[fd].crypt_ctx.decrypt(iocrypt_files[fd].crypt_ctx.priv, buf, buf, length, fd_pos);
trace_write(iocrypt_trace_ctx, " ->> DONE");
}
else
{
give_semaphore(iocrypt_scratch_sem);
}
return ret;
return job.ret;
}
}
......@@ -613,7 +638,7 @@ void crypt_rsa_generate_key()
NotifyBox(600000, "Generating RSA key.\nThis takes a while!");
iocrypt_rsa_key_active = 1;
crypt_rsa_generate_keys((void*)&iocrypt_rsa_ctx);
crypt_rsa_generate_keys(iocrypt_rsa_ctx.priv);
iocrypt_rsa_key_active = 0;
NotifyBoxHide();
......@@ -663,11 +688,11 @@ static MENU_UPDATE_FUNC(iocrypt_update)
case CRYPT_MODE_ASYMMETRIC:
case CRYPT_MODE_ASYMMETRIC_PARANOID:
if(!crypt_rsa_get_pub(&iocrypt_rsa_ctx))
if(!crypt_rsa_get_pub(iocrypt_rsa_ctx.priv))
{
MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Please create keys first. Files are not encrypted yet.");
}
else if(crypt_rsa_get_priv(&iocrypt_rsa_ctx))
else if(crypt_rsa_get_priv(iocrypt_rsa_ctx.priv))
{
MENU_SET_WARNING(MENU_WARN_ADVICE, "Move IO_CRYPT.KEY to a safe place and DELETE from card.");
}
......@@ -676,10 +701,6 @@ static MENU_UPDATE_FUNC(iocrypt_update)
break;
}
if(drive_mode)
{
MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Only available in single shot mode.");
}
if(iocrypt_rsa_key_active)
{
MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Still generating the RSA keys.");
......@@ -692,7 +713,7 @@ static MENU_UPDATE_FUNC(iocrypt_rsa_key_update)
if(iocrypt_rsa_key_active)
{
MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Still generating the RSA keys.");
MENU_SET_VALUE("Generating...");
MENU_SET_VALUE("Generating, %d %%", crypt_rsa_get_keyprogress(iocrypt_rsa_ctx.priv));
}
}
......@@ -775,6 +796,61 @@ static struct menu_entry iocrypt_menus[] =
},
};
static void iocrypt_task()
{
while(!iocrypt_shutdown && !ml_shutdown_requested)
{
int timeout = 500;
iocrypt_job_t *job = NULL;
/* fetch a new encryption job */
if(msg_queue_receive(iocrypt_msgs, &job, timeout))
{
continue;
}
switch(job->type)
{
/* combined encrypt and write job which is atomic */
case CRYPT_JOB_ENCRYPT_WRITE:
{
trace_write(iocrypt_trace_ctx, " ->> ENCRYPT");
job->ctx->encrypt(job->ctx->priv, iocrypt_scratch, job->buf, job->length, job->fd_pos);
trace_write(iocrypt_trace_ctx, " ->> WRITE");
job->ret = orig_iodev->WriteFile(job->fd, iocrypt_scratch, job->length);
trace_write(iocrypt_trace_ctx, " ->> DONE");
give_semaphore(job->semaphore);
break;
}
/* simple decryption */
case CRYPT_JOB_ENCRYPT:
{
trace_write(iocrypt_trace_ctx, " ->> ENCRYPT");
job->ret = job->ctx->encrypt(job->ctx->priv, job->dst, job->buf, job->length, job->fd_pos);
trace_write(iocrypt_trace_ctx, " ->> DONE");
give_semaphore(job->semaphore);
break;
}
/* simple decryption */
case CRYPT_JOB_DECRYPT:
{
trace_write(iocrypt_trace_ctx, " ->> DECRYPT");
job->ret = job->ctx->decrypt(job->ctx->priv, job->dst, job->buf, job->length, job->fd_pos);
trace_write(iocrypt_trace_ctx, " ->> DONE");
give_semaphore(job->semaphore);
break;
}
}
}
iocrypt_shutdown = 0;
}
static unsigned int iocrypt_init()
{
/* for debugging */
......@@ -791,7 +867,11 @@ static unsigned int iocrypt_init()
}
/* clear file map */
memset(iocrypt_files, 0x00, sizeof(iocrypt_files));
for(int pos = 0; pos < COUNT(iocrypt_files); pos++)
{
iocrypt_files[pos].crypt_ctx.priv = NULL;
iocrypt_files[pos].semaphore = create_named_semaphore("iocrypt_pw", 0);
}
if(streq(camera_model_short, "600D"))
{
......@@ -835,7 +915,6 @@ static unsigned int iocrypt_init()
}
iocrypt_password_sem = create_named_semaphore("iocrypt_pw", 1);
iocrypt_scratch_sem = create_named_semaphore("iocrypt_scratch", 1);
/* ask for the initial password */
if(iocrypt_ask_pass && iocrypt_enabled && (iocrypt_mode == CRYPT_MODE_SYMMETRIC || iocrypt_mode == CRYPT_MODE_BACKGROUND_SYM))
......@@ -856,9 +935,13 @@ static unsigned int iocrypt_init()
hook_iodev.CloseFile = &hook_iodev_CloseFile;
MEM(iodev_table) = (uint32_t)&hook_iodev;
/* create a message queue for processing crypt tasks asyncrhonously */
iocrypt_msgs = (struct msg_queue *) msg_queue_create("iocrypt_msgs", 100);
crypt_rsa_init(&iocrypt_rsa_ctx);
task_create("iocrypt_task", 0x1A, 0x1000, iocrypt_task, (void*)0);
/* any file operation is routed through us now */
menu_add("Shoot", iocrypt_menus, COUNT(iocrypt_menus) );
......@@ -867,8 +950,18 @@ static unsigned int iocrypt_init()
static unsigned int iocrypt_deinit()
{
iocrypt_shutdown = 1;
while(iocrypt_shutdown && !ml_shutdown_requested)
{
msleep(20);
}
MEM(iodev_table) = (uint32_t)orig_iodev;
shoot_free(iocrypt_scratch);
if(iocrypt_scratch)
{
shoot_free(iocrypt_scratch);
}
return 0;
}
......
......@@ -5,6 +5,11 @@
#define CRYPT_SCRATCH_SIZE 0x00800000
#define CRYPT_JOB_ENCRYPT 0
#define CRYPT_JOB_ENCRYPT_WRITE 1
#define CRYPT_JOB_DECRYPT 2
typedef void crypt_priv_t;
typedef struct crypt_cipher_t
......@@ -29,6 +34,7 @@ typedef struct
uint64_t file_key;
uint32_t header_size;
uint32_t file_size;
struct semaphore *semaphore;
char filename[64];
} fd_map_t;
......@@ -45,5 +51,17 @@ typedef struct
uint32_t (*unk5)();
} iodev_handlers_t;
typedef struct
{
uint32_t type;
crypt_cipher_t *ctx;
void *dst;
void *buf;
uint32_t length;
uint32_t fd_pos;
uint32_t ret;
uint32_t fd;
struct semaphore *semaphore;
} iocrypt_job_t;
#endif
......@@ -102,6 +102,7 @@ static crypt_cipher_t iocrypt_rsa_ctx;
int main(int argc, char *argv[])
{
//io_decrypt_test();
//crypt_rsa_test();
if(argc < 2)
{
......@@ -179,6 +180,12 @@ int main(int argc, char *argv[])
printf("File type: RSA+LFSR64\n");
crypt_rsa_init(&iocrypt_rsa_ctx);
if(crypt_rsa_get_keysize(iocrypt_rsa_ctx.priv) < 64)
{
printf("Invalid key size\n");
return;
}
uint32_t encrypted_size = 0;
......@@ -212,7 +219,7 @@ int main(int argc, char *argv[])
printf("Could not read '%s'\n", in_filename);
return -1;
}
uint32_t decrypted_size = iocrypt_rsa_ctx.decrypt(&iocrypt_rsa_ctx, (uint8_t *)encrypted, (uint8_t *)encrypted, encrypted_size, 0);
uint32_t decrypted_size = iocrypt_rsa_ctx.decrypt(iocrypt_rsa_ctx.priv, (uint8_t *)encrypted, (uint8_t *)encrypted, encrypted_size, 0);
if(!decrypted_size || decrypted_size > encrypted_size)
{
......@@ -251,7 +258,7 @@ int main(int argc, char *argv[])
uint32_t file_offset = 0;
crypt_cipher_t crypt_ctx;
crypt_lfsr64_init(&crypt_ctx, key);
crypt_ctx.set_blocksize(&crypt_ctx, lfsr_blocksize);
crypt_ctx.set_blocksize(crypt_ctx.priv, lfsr_blocksize);
while(!feof(in_file))
......@@ -260,7 +267,7 @@ int main(int argc, char *argv[])
if(ret > 0)
{
crypt_ctx.decrypt(&crypt_ctx, (uint8_t *)buffer, (uint8_t *)buffer, ret, file_offset);
crypt_ctx.decrypt(crypt_ctx.priv, (uint8_t *)buffer, (uint8_t *)buffer, ret, file_offset);
/* try to detect file type */
if(first)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment