From 6ff55cefd060b4c8f6c0fa97d5521516f9ee43f1 Mon Sep 17 00:00:00 2001 From: a3955269 Date: Tue, 8 Jan 2013 16:14:56 +0000 Subject: Add Samsung TouchWiz decryption Change-Id: I418680e59372160dabfe3e2d5f0208229aa151ae --- crypto/libcrypt_samsung/libcrypt_samsung.c | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 crypto/libcrypt_samsung/libcrypt_samsung.c (limited to 'crypto/libcrypt_samsung/libcrypt_samsung.c') diff --git a/crypto/libcrypt_samsung/libcrypt_samsung.c b/crypto/libcrypt_samsung/libcrypt_samsung.c new file mode 100644 index 000000000..4b9b9c5d5 --- /dev/null +++ b/crypto/libcrypt_samsung/libcrypt_samsung.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2013 a3955269 all rights reversed, no rights reserved. + */ + +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +#include "include/libcrypt_samsung.h" + +////////////////////////////////////////////////////////////////////////////// +void xconvert_key_to_hex_ascii(unsigned char *master_key, unsigned int keysize, + char *master_key_ascii) +{ + unsigned int i, a; + unsigned char nibble; + + for (i=0, a=0; i> 4) & 0xf; + master_key_ascii[a] = nibble + (nibble > 9 ? 0x37 : 0x30); + + nibble = master_key[i] & 0xf; + master_key_ascii[a+1] = nibble + (nibble > 9 ? 0x37 : 0x30); + } + + /* Add the null termination */ + master_key_ascii[a] = '\0'; + +} + +int decrypt_EDK( + dek_t *dek, const edk_payload_t *edk, /*const*/ char *passwd) +{ + void *lib = dlopen("libsec_km.so", RTLD_LAZY); + + if(!lib) + return -100; + + int r = -101; + decrypt_EDK_t sym = (decrypt_EDK_t)dlsym(lib, "decrypt_EDK"); + if(sym) + r = sym(dek, edk, passwd); + + dlclose(lib); + + return r; +} + +int mount_ecryptfs_drive( + const char *passwd, const char *source, const char *target, int filter) +{ + void *lib = dlopen("libsec_ecryptfs.so", RTLD_LAZY); + if(!lib) + return -100; + + int r = -101; + mount_ecryptfs_drive_t sym = (mount_ecryptfs_drive_t)dlsym(lib, "mount_ecryptfs_drive"); + if(sym) + r = sym(passwd, source, target, filter); + + dlclose(lib); + + return r; +} + -- cgit v1.2.3