#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "null_auth.h"
#include "err.h"
#include "alloc.h"
#include "cipher_types.h"
static srtp_err_status_t srtp_null_auth_alloc(srtp_auth_t **a,
int key_len,
int out_len)
{
extern const srtp_auth_type_t srtp_null_auth;
uint8_t *pointer;
debug_print(srtp_mod_auth, "allocating auth func with key length %d",
key_len);
debug_print(srtp_mod_auth, " tag length %d",
out_len);
pointer = (uint8_t *)srtp_crypto_alloc(sizeof(srtp_null_auth_ctx_t) +
sizeof(srtp_auth_t));
if (pointer == NULL) {
return srtp_err_status_alloc_fail;
}
*a = (srtp_auth_t *)pointer;
(*a)->type = &srtp_null_auth;
(*a)->state = pointer + sizeof(srtp_auth_t);
(*a)->out_len = out_len;
(*a)->prefix_len = out_len;
(*a)->key_len = key_len;
return srtp_err_status_ok;
}
static srtp_err_status_t srtp_null_auth_dealloc(srtp_auth_t *a)
{
extern const srtp_auth_type_t srtp_null_auth;
octet_string_set_to_zero(a, sizeof(srtp_null_auth_ctx_t) +
sizeof(srtp_auth_t));
srtp_crypto_free(a);
return srtp_err_status_ok;
}
static srtp_err_status_t srtp_null_auth_init(void *statev,
const uint8_t *key,
int key_len)
{
return srtp_err_status_ok;
}
static srtp_err_status_t srtp_null_auth_compute(void *statev,
const uint8_t *message,
int msg_octets,
int tag_len,
uint8_t *result)
{
return srtp_err_status_ok;
}
static srtp_err_status_t srtp_null_auth_update(void *statev,
const uint8_t *message,
int msg_octets)
{
return srtp_err_status_ok;
}
static srtp_err_status_t srtp_null_auth_start(void *statev)
{
return srtp_err_status_ok;
}
static const srtp_auth_test_case_t srtp_null_auth_test_case_0 = {
0,
NULL,
0,
NULL,
0,
NULL,
NULL
};
static const char srtp_null_auth_description[] = "null authentication function";
const srtp_auth_type_t srtp_null_auth = {
srtp_null_auth_alloc,
srtp_null_auth_dealloc,
srtp_null_auth_init,
srtp_null_auth_compute,
srtp_null_auth_update,
srtp_null_auth_start,
srtp_null_auth_description,
&srtp_null_auth_test_case_0,
SRTP_NULL_AUTH
};