a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 a3955269 all rights reversed, no rights reserved. |
| 3 | */ |
| 4 | |
| 5 | ////////////////////////////////////////////////////////////////////////////// |
| 6 | |
| 7 | #include <string.h> |
| 8 | #include <stdio.h> |
| 9 | #include <dlfcn.h> |
| 10 | |
| 11 | #include "include/libcrypt_samsung.h" |
| 12 | |
| 13 | ////////////////////////////////////////////////////////////////////////////// |
a3955269 | 6ff55ce | 2013-01-08 16:14:56 +0000 | [diff] [blame] | 14 | |
| 15 | int decrypt_EDK( |
| 16 | dek_t *dek, const edk_payload_t *edk, /*const*/ char *passwd) |
| 17 | { |
| 18 | void *lib = dlopen("libsec_km.so", RTLD_LAZY); |
| 19 | |
| 20 | if(!lib) |
| 21 | return -100; |
| 22 | |
| 23 | int r = -101; |
| 24 | decrypt_EDK_t sym = (decrypt_EDK_t)dlsym(lib, "decrypt_EDK"); |
| 25 | if(sym) |
| 26 | r = sym(dek, edk, passwd); |
| 27 | |
| 28 | dlclose(lib); |
| 29 | |
| 30 | return r; |
| 31 | } |
| 32 | |
| 33 | int mount_ecryptfs_drive( |
| 34 | const char *passwd, const char *source, const char *target, int filter) |
| 35 | { |
| 36 | void *lib = dlopen("libsec_ecryptfs.so", RTLD_LAZY); |
| 37 | if(!lib) |
| 38 | return -100; |
| 39 | |
| 40 | int r = -101; |
| 41 | mount_ecryptfs_drive_t sym = (mount_ecryptfs_drive_t)dlsym(lib, "mount_ecryptfs_drive"); |
| 42 | if(sym) |
| 43 | r = sym(passwd, source, target, filter); |
| 44 | |
| 45 | dlclose(lib); |
| 46 | |
| 47 | return r; |
| 48 | } |
| 49 | |
Dees_Troy | c8bafa1 | 2013-01-10 15:43:00 +0000 | [diff] [blame] | 50 | int unmount_ecryptfs_drive( |
| 51 | const char *source) |
| 52 | { |
| 53 | void *lib = dlopen("libsec_ecryptfs.so", RTLD_LAZY); |
| 54 | if(!lib) |
| 55 | return -100; |
| 56 | |
| 57 | int r = -101; |
| 58 | unmount_ecryptfs_drive_t sym = (unmount_ecryptfs_drive_t)dlsym(lib, "unmount_ecryptfs_drive"); |
| 59 | if(sym) |
| 60 | r = sym(source); |
| 61 | |
| 62 | dlclose(lib); |
| 63 | |
| 64 | return r; |
| 65 | } |