Commit aa733c8e authored by g3gg0's avatar g3gg0
Browse files

io_crypt: added 650D, added mingw exe target, fixed warnings

--HG--
branch : unified
parent 48b89cfacb2a
# Makefile for the io_decrypt software
HOST_OBJ=io_decrypt.host.o crypt_lfsr64.host.o crypt_rsa.host.o hash_password.host.o bigdigits.host.o bigd.host.o
C_FILES=io_decrypt.c crypt_lfsr64.c crypt_rsa.c hash_password.c bigdigits.c bigd.c
C_DEPS=crypt_lfsr64.h
HOST_BIN=io_decrypt
HOST_OBJ=${C_FILES:.c=.host.o}
HOSTCC=gcc
HOST_CFLAGS=-m32 -ggdb -mno-ms-bitfields -O2 -Wall -I$(SRC_DIR) -I. -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -std=c99 -DHOST_PROGRAM
HOST_LDFLAGS=-lm -m32
HOST_DEPS=crypt_lfsr64.h
HOST=host
ifdef CROSS
HOSTCC=~/mingw-w32/bin/i686-w64-mingw32-gcc
HOST_BIN=$(HOST_BIN).exe
HOST_CFLAGS=-m32 -ggdb -mno-ms-bitfields -O2 -Wall -I$(SRC_DIR) -I. -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -std=c99 -DHAVE_C99INCLUDES -D_GNU_SOURCE
HOST_LDFLAGS=-lm -m32
MINGW=i686-w64-mingw32
MINGW_GCC=$(MINGW)-gcc
MINGW_AR=$(MINGW)-ar
MINGW_OBJ=${C_FILES:.c=.w32.o}
MINGW_CFLAGS=$(HOST_CFLAGS)
MINGW_LDFLAGS=$(HOST_LDFLAGS)
ifdef FOR_OSX
HOST_CFLAGS=$(HOST_CFLAGS) -arch i386 -mmacosx-version-min=10.6
endif
%.host.o: %.c
$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ -c $<
$(HOSTCC) $(HOST_CFLAGS) -o $@ -c $<
$(HOST_BIN): $(HOST_OBJ) $(HOST_DEPS)
$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $(HOST_OBJ)
%.w32.o: %.c
$(MINGW_GCC) $(MINGW_CFLAGS) -o $@ -c $<
$(HOST_BIN).exe: $(HOST_C) $(HOST_DEPS)
$(HOST_BIN): $(HOST_OBJ) $(C_DEPS)
$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $(HOST_OBJ)
$(HOST_BIN).exe: $(MINGW_OBJ) $(C_DEPS)
$(MINGW_GCC) $(MINGW_CFLAGS) $(MINGW_LDFLAGS) -o $@ $(MINGW_OBJ)
clean::
$(call rm_files, $(HOST_BIN) $(HOST_BIN).exe)
......
......@@ -12,8 +12,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#define trace_write(x,...) do { 0; } while (0)
#define trace_write(x,...) do { (void)0; } while (0)
//#define trace_write(x,...) do { printf(__VA_ARGS__); printf("\n"); } while (0)
#endif
......@@ -193,6 +194,8 @@ static uint32_t crypt_lfsr64_encrypt(crypt_cipher_t *cipher_ctx, uint8_t *dst, u
offset += 1;
length -= 1;
}
return 0;
}
#undef IS_UNALIGNED
......@@ -228,10 +231,10 @@ void crypt_lfsr64_init(crypt_cipher_t *crypt_ctx, uint64_t password)
}
/* setup cipher ctx */
crypt_ctx->encrypt = &crypt_lfsr64_encrypt;
crypt_ctx->decrypt = &crypt_lfsr64_decrypt;
crypt_ctx->deinit = &crypt_lfsr64_deinit;
crypt_ctx->set_blocksize = &crypt_lfsr64_set_blocksize;
crypt_ctx->encrypt = (uint32_t (*)(void *, uint8_t *, uint8_t *, uint32_t, uint32_t))&crypt_lfsr64_encrypt;
crypt_ctx->decrypt = (uint32_t (*)(void *, uint8_t *, uint8_t *, uint32_t, uint32_t))&crypt_lfsr64_decrypt;
crypt_ctx->deinit = (void (*)(void *))&crypt_lfsr64_deinit;
crypt_ctx->set_blocksize = (void (*)(void *, uint32_t))&crypt_lfsr64_set_blocksize;
crypt_ctx->priv = ctx;
ctx->password = password;
......
......@@ -8,9 +8,11 @@
#include <menu.h>
#include <string.h>
//#define TRACE_DISABLED
#define TRACE_DISABLED
#include "../trace/trace.h"
extern char *module_card_drive;
#else
#include <stdio.h>
......@@ -22,7 +24,7 @@
#include <sys/stat.h>
#include <unistd.h>
#define trace_write(x,...) do { 0; } while (0)
#define trace_write(x,...) do { (void)0; } while (0)
//#define trace_write(x,...) do { printf(__VA_ARGS__); printf("\n"); } while (0)
#define NotifyBox(x,...) do { printf(__VA_ARGS__); printf("\n"); } while (0)
......@@ -50,6 +52,8 @@ size_t getFileSize(const char * filename, int *ret)
return 0;
}
char *module_card_drive = "";
#endif
#include <rand.h>
......@@ -553,8 +557,12 @@ static void crypt_rsa_deinit(void **crypt_ctx)
}
}
static uint32_t crypt_rsa_save(char *filename, t_crypt_key *key)
static uint32_t crypt_rsa_save(char *file, t_crypt_key *key)
{
char filename[32];
snprintf(filename, sizeof(filename), "%s%s", module_card_drive, file);
FILE* f = FIO_CreateFileEx(filename);
if(f == INVALID_PTR)
{
......@@ -573,7 +581,7 @@ static uint32_t crypt_rsa_save(char *filename, t_crypt_key *key)
uint32_t crypt_rsa_load(char *filename, t_crypt_key *key)
{
uint32_t size = 0;
int size = 0;
if(FIO_GetFileSize(filename, &size))
{
......@@ -748,10 +756,10 @@ void crypt_rsa_init(crypt_cipher_t *crypt_ctx)
}
/* setup cipher ctx */
crypt_ctx->encrypt = &crypt_rsa_encrypt;
crypt_ctx->decrypt = &crypt_rsa_decrypt;
crypt_ctx->deinit = &crypt_rsa_deinit;
crypt_ctx->set_blocksize = &crypt_rsa_set_blocksize;
crypt_ctx->encrypt = (uint32_t (*)(void *, uint8_t *, uint8_t *, uint32_t, uint32_t))&crypt_rsa_encrypt;
crypt_ctx->decrypt = (uint32_t (*)(void *, uint8_t *, uint8_t *, uint32_t, uint32_t))&crypt_rsa_decrypt;
crypt_ctx->deinit = (void (*)(void *))&crypt_rsa_deinit;
crypt_ctx->set_blocksize = (void (*)(void *, uint32_t))&crypt_rsa_set_blocksize;
crypt_ctx->priv = ctx;
/* load all keys that are on card */
......
#ifdef HOST_PROGRAM
#ifndef MODULE
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#define trace_write(x,...) do { 0; } while (0)
#define trace_write(x,...) do { (void)0; } while (0)
//#define trace_write(x,...) do { printf(__VA_ARGS__); printf("\n"); } while (0)
#else
......
......@@ -739,14 +739,12 @@ static unsigned int iocrypt_init()
{
if(streq(camera_model_short, "600D"))
{
/* not verified */
iodev_table = 0x1E684;
iodev_ctx = 0x7EB08;
iodev_ctx_size = 0x18;
}
else if(streq(camera_model_short, "7D"))
{
/* not verified */
iodev_table = 0x2D3B8;
iodev_ctx = 0x85510;
iodev_ctx_size = 0x18;
......@@ -763,6 +761,13 @@ static unsigned int iocrypt_init()
iodev_ctx = 0x67140;
iodev_ctx_size = 0x20;
}
else if(streq(camera_model_short, "650D"))
{
/* not verified */
iodev_table = 0x54060;
iodev_ctx = 0x7C278;
iodev_ctx_size = 0x20;
}
else
{
NotifyBox(2000, "io_crypt: Camera unsupported");
......@@ -801,7 +806,7 @@ static unsigned int iocrypt_init()
crypt_rsa_init(&iocrypt_rsa_ctx);
/* any file operation is routed through us now */
menu_add("Debug", iocrypt_menus, COUNT(iocrypt_menus) );
menu_add("Shoot", iocrypt_menus, COUNT(iocrypt_menus) );
return 0;
}
......
......@@ -159,7 +159,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, encrypted, encrypted, encrypted_size, 0);
uint32_t decrypted_size = iocrypt_rsa_ctx.decrypt(&iocrypt_rsa_ctx, (uint8_t *)encrypted, (uint8_t *)encrypted, encrypted_size, 0);
if(!decrypted_size || decrypted_size > encrypted_size)
{
......@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
if(ret > 0)
{
crypt_ctx.decrypt(&crypt_ctx, buffer, buffer, ret, file_offset);
crypt_ctx.decrypt(&crypt_ctx, (uint8_t *)buffer, (uint8_t *)buffer, ret, file_offset);
fwrite(buffer, 1, ret, out_file);
file_offset += ret;
}
......
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