Ejemplo n.º 1
0
srtp_err_status_t srtp_crypto_kernel_status ()
{
    srtp_err_status_t status;
    srtp_kernel_cipher_type_t  *ctype = crypto_kernel.cipher_type_list;
    srtp_kernel_auth_type_t    *atype = crypto_kernel.auth_type_list;
    srtp_kernel_debug_module_t *dm    = crypto_kernel.debug_module_list;

    /* for each cipher type, describe and test */
    while (ctype != NULL) {
        printf("cipher: %s\n", ctype->cipher_type->description);
        printf("  self-test: ");
        status = srtp_cipher_type_self_test(ctype->cipher_type);
        if (status) {
            printf("failed with error code %d\n", status);
            exit(status);
        }
        printf("passed\n");
        ctype = ctype->next;
    }

    /* for each auth type, describe and test */
    while (atype != NULL) {
        printf("auth func: %s\n", atype->auth_type->description);
        printf("  self-test: ");
        status = srtp_auth_type_self_test(atype->auth_type);
        if (status) {
            printf("failed with error code %d\n", status);
            exit(status);
        }
        printf("passed\n");
        atype = atype->next;
    }

    /* describe each debug module */
    printf("debug modules loaded:\n");
    while (dm != NULL) {
        printf("  %s ", dm->mod->name);
        if (dm->mod->on) {
            printf("(on)\n");
        } else {
            printf("(off)\n");
        }
        dm = dm->next;
    }

    return srtp_err_status_ok;
}
Ejemplo n.º 2
0
srtp_err_status_t srtp_crypto_kernel_status()
{
    srtp_err_status_t status;
    srtp_kernel_cipher_type_t *ctype = crypto_kernel.cipher_type_list;
    srtp_kernel_auth_type_t *atype = crypto_kernel.auth_type_list;

    /* for each cipher type, describe and test */
    while (ctype != NULL) {
        srtp_err_report(srtp_err_level_info, "cipher: %s\n",
                        ctype->cipher_type->description);
        srtp_err_report(srtp_err_level_info, "  self-test: ");
        status = srtp_cipher_type_self_test(ctype->cipher_type);
        if (status) {
            srtp_err_report(srtp_err_level_error, "failed with error code %d\n",
                            status);
            exit(status);
        }
        srtp_err_report(srtp_err_level_info, "passed\n");
        ctype = ctype->next;
    }

    /* for each auth type, describe and test */
    while (atype != NULL) {
        srtp_err_report(srtp_err_level_info, "auth func: %s\n",
                        atype->auth_type->description);
        srtp_err_report(srtp_err_level_info, "  self-test: ");
        status = srtp_auth_type_self_test(atype->auth_type);
        if (status) {
            srtp_err_report(srtp_err_level_error, "failed with error code %d\n",
                            status);
            exit(status);
        }
        srtp_err_report(srtp_err_level_info, "passed\n");
        atype = atype->next;
    }

    srtp_crypto_kernel_list_debug_modules();

    return srtp_err_status_ok;
}
Ejemplo n.º 3
0
srtp_err_status_t srtp_crypto_kernel_do_load_auth_type (srtp_auth_type_t *new_at, srtp_auth_type_id_t id, int replace)
{
    srtp_kernel_auth_type_t *atype, *new_atype;
    srtp_err_status_t status;

    /* defensive coding */
    if (new_at == NULL) {
        return srtp_err_status_bad_param;
    }

    if (new_at->id != id) {
        return srtp_err_status_bad_param;
    }

    /* check auth type by running self-test */
    status = srtp_auth_type_self_test(new_at);
    if (status) {
        return status;
    }

    /* walk down list, checking if this type is in the list already  */
    atype = crypto_kernel.auth_type_list;
    while (atype != NULL) {
        if (id == atype->id) {
            if (!replace) {
                return srtp_err_status_bad_param;
            }
            status = srtp_auth_type_test(new_at, atype->auth_type->test_data);
            if (status) {
                return status;
            }
            new_atype = atype;
            break;
        } else if (new_at == atype->auth_type) {
            return srtp_err_status_bad_param;
        }
        atype = atype->next;
    }

    /* if not found, put new_at at the head of the list */
    if (atype == NULL) {
        /* allocate memory */
        new_atype = (srtp_kernel_auth_type_t*)srtp_crypto_alloc(sizeof(srtp_kernel_auth_type_t));
        if (new_atype == NULL) {
            return srtp_err_status_alloc_fail;
        }

        new_atype->next = crypto_kernel.auth_type_list;
        /* set head of list to new auth type */
        crypto_kernel.auth_type_list = new_atype;
    }

    /* set fields */
    new_atype->auth_type = new_at;
    new_atype->id = id;

    /* load debug module, if there is one present */
    if (new_at->debug != NULL) {
        srtp_crypto_kernel_load_debug_module(new_at->debug);
    }
    /* we could check for errors here */

    return srtp_err_status_ok;

}