Commit 1aefe1c8 authored by npzacs's avatar npzacs

Add aacs_error_str()

parent 5795c79c
- Add support for AACS2 content certificate.
- Add aacs_set_key_caching().
- Add aacs_error_str().
- Issue a warning when using AACS2 capable drive.
- Fix parsing title entries from multiple KEYDB.cfg files.
- Fix memory leak with multiple KEYDB.cfg files.
......
......@@ -41,29 +41,6 @@ static const char *_hex2str(const uint8_t *s, unsigned n)
return str;
}
static const char *_error_str(int error_code)
{
switch (error_code) {
case AACS_SUCCESS:
return "No errors";
case AACS_ERROR_CORRUPTED_DISC:
return "Corrupted BluRay disc";
case AACS_ERROR_NO_CONFIG:
return "Missing configuration file(s)";
case AACS_ERROR_NO_PK:
return "No matching processing key in configuration file(s)";
case AACS_ERROR_NO_CERT:
return "No valid certificates in configuration file(s)";
case AACS_ERROR_CERT_REVOKED:
return "All available certificates have been revoked";
case AACS_ERROR_MMC_OPEN:
return "MMC open failed";
case AACS_ERROR_MMC_FAILURE:
return "MMC authentication failed";
}
return "Unknown error";
}
static void _dump_rl(const char *type, AACS_RL_ENTRY *rl, int num_entries, int mkb_version)
{
int ii;
......@@ -107,7 +84,7 @@ int main (int argc, char **argv)
error_code = aacs_open_device(aacs, argv[1], argc > 2 ? argv[2] : NULL);
if (error_code) {
fprintf(stderr, "libaacs open failed: %s\n", _error_str(error_code));
fprintf(stderr, "libaacs open failed: %s\n", aacs_error_str(error_code));
} else {
printf("libaacs open succeed.\n");
}
......
......@@ -1121,6 +1121,26 @@ void aacs_get_version(int *major, int *minor, int *micro)
*micro = AACS_VERSION_MICRO;
}
const char *aacs_error_str(int err)
{
static const char * const str[] = {
[-AACS_SUCCESS] = "Success",
[-AACS_ERROR_CORRUPTED_DISC] = "Corrupt disc",
[-AACS_ERROR_NO_CONFIG] = "Missing configuration file",
[-AACS_ERROR_NO_PK] = "No matching processing key",
[-AACS_ERROR_NO_CERT] = "No valid certificate",
[-AACS_ERROR_CERT_REVOKED] = "Revoked certificate",
[-AACS_ERROR_MMC_OPEN] = "Failed opening MMC device",
[-AACS_ERROR_MMC_FAILURE] = "MMC failure",
[-AACS_ERROR_NO_DK] = "No matching device key",
};
err = -err;
if (err < 0 || (size_t)err >= sizeof(str) / sizeof(str[0]) || !str[err]) {
return "Unknown error code";
}
return str[err];
}
/* aacs_open2() wrapper for backwards compability */
AACS *aacs_open(const char *path, const char *configfile_path)
{
......
......@@ -40,6 +40,8 @@
#define AACS_ERROR_MMC_FAILURE -7 /* MMC failed */
#define AACS_ERROR_NO_DK -8 /* no matching device key */
AACS_PUBLIC const char *aacs_error_str(int error);
/**
* Opaque type for AACS object
*/
......
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