int set_decryption_key(MOBIData *m, const char *serial, const char *pid) {

    if (!pid && !serial) {
        return SUCCESS;
    }
    if (!mobi_is_encrypted(m)) {
        printf("\nDocument is not encrypted, ignoring PID/serial\n");
        return SUCCESS;
    }
    if (m->rh && m->rh->encryption_type == MOBI_ENCRYPTION_V1) {
        printf("\nEncryption type 1, ignoring PID/serial\n");
        return SUCCESS;
    }
    int ret = SUCCESS;
    if (pid && (ret = set_decryption_pid(m, pid)) == SUCCESS) {
        return SUCCESS;
    }
    if (serial) {
        ret = set_decryption_serial(m, serial);
    }
    return ret;
}
int set_decryption_key(MOBIData *m, const char *serial, const char *pid) {

    if (!pid && !serial) {
        return SUCCESS;
    }
    if (!mobi_is_encrypted(m)) {
        printf("\nDocument is not encrypted, ignoring PID/serial\n");
        return SUCCESS;
    }
    if (m->rh && m->rh->encryption_type == MOBI_ENCRYPTION_V1) {
        printf("\nEncryption type 1, ignoring PID/serial\n");
        return SUCCESS;
    }
    int ret = SUCCESS;
    if (pid && (ret = set_decryption_pid(m, pid)) == SUCCESS) {
        return SUCCESS;
    }
    if (serial) {
        ret = set_decryption_serial(m, serial);
    }
    return ret;
}