libaacs | branch: master | npzacs <npz...@gmail.com> | Tue Apr 28 10:07:02 2015 
+0300| [9f7be2b226afbea5f774ea9e5fa1dd9f0ac9e9d1] | committer: npzacs

Factorize common code

> http://git.videolan.org/gitweb.cgi/libaacs.git/?a=commit;h=9f7be2b226afbea5f774ea9e5fa1dd9f0ac9e9d1
---

 src/libaacs/aacs.c |   28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/libaacs/aacs.c b/src/libaacs/aacs.c
index 2ea5e6d..d2d8ff4 100644
--- a/src/libaacs/aacs.c
+++ b/src/libaacs/aacs.c
@@ -846,36 +846,22 @@ static int _calc_uks(AACS *aacs, config_file *cf)
 
 static int _calc_title_hash(AACS *aacs)
 {
-    AACS_FILE_H *fp = NULL;
-    uint8_t *ukf_buf;
+    void    *data;
+    size_t   size;
     char     str[48];
-    int64_t  f_size;
     int      result = AACS_SUCCESS;
 
-    fp = _file_open(aacs, "AACS" DIR_SEP "Unit_Key_RO.inf");
-    if (!fp) {
-        BD_DEBUG(DBG_AACS | DBG_CRIT, "Error opening unit key file 
(AACS/Unit_Key_RO.inf)\n");
-        return AACS_ERROR_CORRUPTED_DISC;
-    }
-
-    file_seek(fp, 0, SEEK_END);
-    f_size = file_tell(fp);
-    file_seek(fp, 0, SEEK_SET);
-
-    ukf_buf = malloc(f_size);
-
-    if ((file_read(fp, ukf_buf, f_size)) == f_size) {
-        crypto_aacs_title_hash(ukf_buf, f_size, aacs->disc_id);
+    size = _read_file(aacs, "AACS" DIR_SEP "Unit_Key_RO.inf", &data);
+    if (size) {
+        crypto_aacs_title_hash(data, size, aacs->disc_id);
         BD_DEBUG(DBG_AACS, "Disc ID: %s\n", str_print_hex(str, aacs->disc_id, 
20));
+        X_FREE(data);
 
     } else {
         result = AACS_ERROR_CORRUPTED_DISC;
-        BD_DEBUG(DBG_AACS | DBG_CRIT, "Failed to read %lu bytes from unit key 
file (AACS/Unit_Key_RO.inf)", (unsigned long)f_size);
+        BD_DEBUG(DBG_AACS | DBG_CRIT, "Failed to read %lu bytes from unit key 
file (AACS/Unit_Key_RO.inf)", (unsigned long)size);
     }
 
-    file_close(fp);
-    X_FREE(ukf_buf);
-
     return result;
 }
 

_______________________________________________
libaacs-devel mailing list
libaacs-devel@videolan.org
https://mailman.videolan.org/listinfo/libaacs-devel

Reply via email to