update to cvs head srtp

This commit is contained in:
Anthony Minessale
2013-01-17 17:59:53 -06:00
parent aad4da5b71
commit 72e2d183c1
100 changed files with 4732 additions and 1509 deletions

View File

@@ -8,7 +8,7 @@
*/
/*
*
* Copyright(c) 2001-2005 Cisco Systems, Inc.
* Copyright(c) 2001-2006 Cisco Systems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -151,10 +151,10 @@ crypto_kernel_init() {
status = crypto_kernel_load_cipher_type(&null_cipher, NULL_CIPHER);
if (status)
return status;
status = crypto_kernel_load_cipher_type(&aes_icm, AES_128_ICM);
status = crypto_kernel_load_cipher_type(&aes_icm, AES_ICM);
if (status)
return status;
status = crypto_kernel_load_cipher_type(&aes_cbc, AES_128_CBC);
status = crypto_kernel_load_cipher_type(&aes_cbc, AES_CBC);
if (status)
return status;
@@ -297,15 +297,19 @@ crypto_kernel_shutdown() {
return err_status_ok;
}
err_status_t
crypto_kernel_load_cipher_type(cipher_type_t *new_ct, cipher_type_id_t id) {
kernel_cipher_type_t *ctype, *new;
static inline err_status_t
crypto_kernel_do_load_cipher_type(cipher_type_t *new_ct, cipher_type_id_t id,
int replace) {
kernel_cipher_type_t *ctype, *new_ctype;
err_status_t status;
/* defensive coding */
if (new_ct == NULL)
return err_status_bad_param;
if (new_ct->id != id)
return err_status_bad_param;
/* check cipher type by running self-test */
status = cipher_type_self_test(new_ct);
if (status) {
@@ -315,24 +319,35 @@ crypto_kernel_load_cipher_type(cipher_type_t *new_ct, cipher_type_id_t id) {
/* walk down list, checking if this type is in the list already */
ctype = crypto_kernel.cipher_type_list;
while (ctype != NULL) {
if ((new_ct == ctype->cipher_type) || (id == ctype->id))
if (id == ctype->id) {
if (!replace)
return err_status_bad_param;
status = cipher_type_test(new_ct, ctype->cipher_type->test_data);
if (status)
return status;
new_ctype = ctype;
break;
}
else if (new_ct == ctype->cipher_type)
return err_status_bad_param;
ctype = ctype->next;
}
/* put new_ct at the head of the list */
/* if not found, put new_ct at the head of the list */
if (ctype == NULL) {
/* allocate memory */
new = (kernel_cipher_type_t *) crypto_alloc(sizeof(kernel_cipher_type_t));
if (new == NULL)
return err_status_alloc_fail;
new_ctype = (kernel_cipher_type_t *) crypto_alloc(sizeof(kernel_cipher_type_t));
if (new_ctype == NULL)
return err_status_alloc_fail;
new_ctype->next = crypto_kernel.cipher_type_list;
/* set head of list to new cipher type */
crypto_kernel.cipher_type_list = new_ctype;
}
/* set fields */
new->cipher_type = new_ct;
new->id = id;
new->next = crypto_kernel.cipher_type_list;
/* set head of list to new cipher type */
crypto_kernel.cipher_type_list = new;
new_ctype->cipher_type = new_ct;
new_ctype->id = id;
/* load debug module, if there is one present */
if (new_ct->debug != NULL)
@@ -343,14 +358,28 @@ crypto_kernel_load_cipher_type(cipher_type_t *new_ct, cipher_type_id_t id) {
}
err_status_t
crypto_kernel_load_auth_type(auth_type_t *new_at, auth_type_id_t id) {
kernel_auth_type_t *atype, *new;
crypto_kernel_load_cipher_type(cipher_type_t *new_ct, cipher_type_id_t id) {
return crypto_kernel_do_load_cipher_type(new_ct, id, 0);
}
err_status_t
crypto_kernel_replace_cipher_type(cipher_type_t *new_ct, cipher_type_id_t id) {
return crypto_kernel_do_load_cipher_type(new_ct, id, 1);
}
err_status_t
crypto_kernel_do_load_auth_type(auth_type_t *new_at, auth_type_id_t id,
int replace) {
kernel_auth_type_t *atype, *new_atype;
err_status_t status;
/* defensive coding */
if (new_at == NULL)
return err_status_bad_param;
if (new_at->id != id)
return err_status_bad_param;
/* check auth type by running self-test */
status = auth_type_self_test(new_at);
if (status) {
@@ -360,24 +389,35 @@ crypto_kernel_load_auth_type(auth_type_t *new_at, auth_type_id_t id) {
/* walk down list, checking if this type is in the list already */
atype = crypto_kernel.auth_type_list;
while (atype != NULL) {
if ((new_at == atype->auth_type) || (id == atype->id))
if (id == atype->id) {
if (!replace)
return err_status_bad_param;
status = 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 err_status_bad_param;
atype = atype->next;
}
/* put new_at at the head of the list */
/* allocate memory */
new = (kernel_auth_type_t *)crypto_alloc(sizeof(kernel_auth_type_t));
if (new == NULL)
return err_status_alloc_fail;
/* if not found, put new_at at the head of the list */
if (atype == NULL) {
/* allocate memory */
new_atype = (kernel_auth_type_t *)crypto_alloc(sizeof(kernel_auth_type_t));
if (new_atype == NULL)
return 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->auth_type = new_at;
new->id = id;
new->next = crypto_kernel.auth_type_list;
/* set head of list to new auth type */
crypto_kernel.auth_type_list = new;
new_atype->auth_type = new_at;
new_atype->id = id;
/* load debug module, if there is one present */
if (new_at->debug != NULL)
@@ -388,6 +428,16 @@ crypto_kernel_load_auth_type(auth_type_t *new_at, auth_type_id_t id) {
}
err_status_t
crypto_kernel_load_auth_type(auth_type_t *new_at, auth_type_id_t id) {
return crypto_kernel_do_load_auth_type(new_at, id, 0);
}
err_status_t
crypto_kernel_replace_auth_type(auth_type_t *new_at, auth_type_id_t id) {
return crypto_kernel_do_load_auth_type(new_at, id, 1);
}
cipher_type_t *
crypto_kernel_get_cipher_type(cipher_type_id_t id) {