mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-14 05:18:31 +00:00
FS-11816: [Build-System] Update libsrtp to 2.2.0
This commit is contained in:
1 parent
239bf913f4
commit
f82321ee0c
93 files changed
+11420
-11604
No files matched your search
@@ -70,9 +70,11 @@ srtp_err_status_t srtp_aes_expand_decryption_key(
|
||||
int key_len,
|
||||
srtp_aes_expanded_key_t *expanded_key);
|
||||
|
||||
void srtp_aes_encrypt(v128_t *plaintext, const srtp_aes_expanded_key_t *exp_key);
|
||||
void srtp_aes_encrypt(v128_t *plaintext,
|
||||
const srtp_aes_expanded_key_t *exp_key);
|
||||
|
||||
void srtp_aes_decrypt(v128_t *plaintext, const srtp_aes_expanded_key_t *exp_key);
|
||||
void srtp_aes_decrypt(v128_t *plaintext,
|
||||
const srtp_aes_expanded_key_t *exp_key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -55,9 +55,8 @@
|
||||
typedef struct {
|
||||
int key_size;
|
||||
int tag_len;
|
||||
EVP_CIPHER_CTX* ctx;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
srtp_cipher_direction_t dir;
|
||||
} srtp_aes_gcm_ctx_t;
|
||||
|
||||
#endif /* AES_GCM_OSSL_H */
|
||||
|
||||
@@ -9,26 +9,26 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2001-2017, Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -60,4 +60,3 @@ typedef struct {
|
||||
} srtp_aes_icm_ctx_t;
|
||||
|
||||
#endif /* AES_ICM_H */
|
||||
|
||||
@@ -52,11 +52,10 @@
|
||||
#include <openssl/aes.h>
|
||||
|
||||
typedef struct {
|
||||
v128_t counter; /* holds the counter value */
|
||||
v128_t offset; /* initial offset value */
|
||||
v128_t counter; /* holds the counter value */
|
||||
v128_t offset; /* initial offset value */
|
||||
int key_size;
|
||||
EVP_CIPHER_CTX* ctx;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
} srtp_aes_icm_ctx_t;
|
||||
|
||||
#endif /* AES_ICM_H */
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
/*
|
||||
* alloc.h
|
||||
*
|
||||
* interface to memory allocation and deallocation, with optional debugging
|
||||
* interface to memory allocation and deallocation, with optional debugging
|
||||
*
|
||||
* David A. McGrew
|
||||
* Cisco Systems, Inc.
|
||||
*/
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2001-2017 Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -42,7 +42,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYPTO_ALLOC_H
|
||||
#define CRYPTO_ALLOC_H
|
||||
|
||||
@@ -52,8 +51,22 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void * srtp_crypto_alloc(size_t size);
|
||||
/*
|
||||
* srtp_crypto_alloc
|
||||
*
|
||||
* Allocates a block of memory of given size. The memory will be
|
||||
* initialized to zero's. Free the memory with a call to srtp_crypto_free.
|
||||
*
|
||||
* returns pointer to memory on success or else NULL
|
||||
*/
|
||||
void *srtp_crypto_alloc(size_t size);
|
||||
|
||||
/*
|
||||
* srtp_crypto_free
|
||||
*
|
||||
* Frees the block of memory ptr previously allocated with
|
||||
* srtp_crypto_alloc
|
||||
*/
|
||||
void srtp_crypto_free(void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -47,46 +47,51 @@
|
||||
#define SRTP_AUTH_H
|
||||
|
||||
#include "srtp.h"
|
||||
#include "crypto_types.h" /* for values of auth_type_id_t */
|
||||
#include "crypto_types.h" /* for values of auth_type_id_t */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef const struct srtp_auth_type_t *srtp_auth_type_pointer;
|
||||
typedef struct srtp_auth_t *srtp_auth_pointer_t;
|
||||
typedef struct srtp_auth_t *srtp_auth_pointer_t;
|
||||
|
||||
typedef srtp_err_status_t (*srtp_auth_alloc_func)
|
||||
(srtp_auth_pointer_t *ap, int key_len, int out_len);
|
||||
typedef srtp_err_status_t (*srtp_auth_alloc_func)(srtp_auth_pointer_t *ap,
|
||||
int key_len,
|
||||
int out_len);
|
||||
|
||||
typedef srtp_err_status_t (*srtp_auth_init_func)
|
||||
(void *state, const uint8_t *key, int key_len);
|
||||
typedef srtp_err_status_t (*srtp_auth_init_func)(void *state,
|
||||
const uint8_t *key,
|
||||
int key_len);
|
||||
|
||||
typedef srtp_err_status_t (*srtp_auth_dealloc_func)(srtp_auth_pointer_t ap);
|
||||
|
||||
typedef srtp_err_status_t (*srtp_auth_compute_func)
|
||||
(void *state, const uint8_t *buffer, int octets_to_auth,
|
||||
int tag_len, uint8_t *tag);
|
||||
typedef srtp_err_status_t (*srtp_auth_compute_func)(void *state,
|
||||
const uint8_t *buffer,
|
||||
int octets_to_auth,
|
||||
int tag_len,
|
||||
uint8_t *tag);
|
||||
|
||||
typedef srtp_err_status_t (*srtp_auth_update_func)
|
||||
(void *state, const uint8_t *buffer, int octets_to_auth);
|
||||
typedef srtp_err_status_t (*srtp_auth_update_func)(void *state,
|
||||
const uint8_t *buffer,
|
||||
int octets_to_auth);
|
||||
|
||||
typedef srtp_err_status_t (*srtp_auth_start_func)(void *state);
|
||||
|
||||
/* some syntactic sugar on these function types */
|
||||
#define srtp_auth_type_alloc(at, a, klen, outlen) \
|
||||
#define srtp_auth_type_alloc(at, a, klen, outlen) \
|
||||
((at)->alloc((a), (klen), (outlen)))
|
||||
|
||||
#define srtp_auth_init(a, key) \
|
||||
#define srtp_auth_init(a, key) \
|
||||
(((a)->type)->init((a)->state, (key), ((a)->key_len)))
|
||||
|
||||
#define srtp_auth_compute(a, buf, len, res) \
|
||||
#define srtp_auth_compute(a, buf, len, res) \
|
||||
(((a)->type)->compute((a)->state, (buf), (len), (a)->out_len, (res)))
|
||||
|
||||
#define srtp_auth_update(a, buf, len) \
|
||||
#define srtp_auth_update(a, buf, len) \
|
||||
(((a)->type)->update((a)->state, (buf), (len)))
|
||||
|
||||
#define srtp_auth_start(a)(((a)->type)->start((a)->state))
|
||||
#define srtp_auth_start(a) (((a)->type)->start((a)->state))
|
||||
|
||||
#define srtp_auth_dealloc(c) (((c)->type)->dealloc(c))
|
||||
|
||||
@@ -105,13 +110,14 @@ int srtp_auth_get_prefix_length(const struct srtp_auth_t *a);
|
||||
* function below)
|
||||
*/
|
||||
typedef struct srtp_auth_test_case_t {
|
||||
int key_length_octets; /* octets in key */
|
||||
const uint8_t *key; /* key */
|
||||
int data_length_octets; /* octets in data */
|
||||
const uint8_t *data; /* data */
|
||||
int tag_length_octets; /* octets in tag */
|
||||
const uint8_t *tag; /* tag */
|
||||
const struct srtp_auth_test_case_t *next_test_case; /* pointer to next testcase */
|
||||
int key_length_octets; /* octets in key */
|
||||
const uint8_t *key; /* key */
|
||||
int data_length_octets; /* octets in data */
|
||||
const uint8_t *data; /* data */
|
||||
int tag_length_octets; /* octets in tag */
|
||||
const uint8_t *tag; /* tag */
|
||||
const struct srtp_auth_test_case_t
|
||||
*next_test_case; /* pointer to next testcase */
|
||||
} srtp_auth_test_case_t;
|
||||
|
||||
/* srtp_auth_type_t */
|
||||
@@ -122,17 +128,17 @@ typedef struct srtp_auth_type_t {
|
||||
srtp_auth_compute_func compute;
|
||||
srtp_auth_update_func update;
|
||||
srtp_auth_start_func start;
|
||||
const char *description;
|
||||
const srtp_auth_test_case_t *test_data;
|
||||
const char *description;
|
||||
const srtp_auth_test_case_t *test_data;
|
||||
srtp_auth_type_id_t id;
|
||||
} srtp_auth_type_t;
|
||||
|
||||
typedef struct srtp_auth_t {
|
||||
const srtp_auth_type_t *type;
|
||||
void *state;
|
||||
int out_len; /* length of output tag in octets */
|
||||
int key_len; /* length of key in octets */
|
||||
int prefix_len; /* length of keystream prefix */
|
||||
void *state;
|
||||
int out_len; /* length of output tag in octets */
|
||||
int key_len; /* length of key in octets */
|
||||
int prefix_len; /* length of keystream prefix */
|
||||
} srtp_auth_t;
|
||||
|
||||
/*
|
||||
@@ -147,8 +153,8 @@ srtp_err_status_t srtp_auth_type_self_test(const srtp_auth_type_t *at);
|
||||
* provided in an array of values of key/message/tag that is known to
|
||||
* be good
|
||||
*/
|
||||
srtp_err_status_t srtp_auth_type_test(const srtp_auth_type_t *at,
|
||||
const srtp_auth_test_case_t *test_data);
|
||||
srtp_err_status_t srtp_auth_type_test(const srtp_auth_type_t *at,
|
||||
const srtp_auth_test_case_t *test_data);
|
||||
|
||||
/*
|
||||
* srtp_replace_auth_type(ct, id)
|
||||
@@ -157,7 +163,8 @@ srtp_err_status_t srtp_auth_type_test(const srtp_auth_type_t *at,
|
||||
* with a new one passed in externally. The new auth type must pass all the
|
||||
* existing auth_type's self tests as well as its own.
|
||||
*/
|
||||
srtp_err_status_t srtp_replace_auth_type(const srtp_auth_type_t *ct, srtp_auth_type_id_t id);
|
||||
srtp_err_status_t srtp_replace_auth_type(const srtp_auth_type_t *ct,
|
||||
srtp_auth_type_id_t id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -42,13 +42,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SRTP_CIPHER_H
|
||||
#define SRTP_CIPHER_H
|
||||
|
||||
#include "srtp.h"
|
||||
#include "crypto_types.h" /* for values of cipher_type_id_t */
|
||||
|
||||
#include "crypto_types.h" /* for values of cipher_type_id_t */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -71,51 +69,60 @@ typedef enum {
|
||||
* the srtp_cipher_pointer_t definition is needed
|
||||
* as srtp_cipher_t is not yet defined
|
||||
*/
|
||||
typedef struct srtp_cipher_t *srtp_cipher_pointer_t;
|
||||
typedef struct srtp_cipher_t *srtp_cipher_pointer_t;
|
||||
|
||||
/*
|
||||
* a srtp_cipher_alloc_func_t allocates (but does not initialize) a srtp_cipher_t
|
||||
* a srtp_cipher_alloc_func_t allocates (but does not initialize) a
|
||||
* srtp_cipher_t
|
||||
*/
|
||||
typedef srtp_err_status_t (*srtp_cipher_alloc_func_t)
|
||||
(srtp_cipher_pointer_t *cp, int key_len, int tag_len);
|
||||
typedef srtp_err_status_t (*srtp_cipher_alloc_func_t)(srtp_cipher_pointer_t *cp,
|
||||
int key_len,
|
||||
int tag_len);
|
||||
|
||||
/*
|
||||
* a srtp_cipher_init_func_t [re-]initializes a cipher_t with a given key
|
||||
*/
|
||||
typedef srtp_err_status_t (*srtp_cipher_init_func_t)
|
||||
(void *state, const uint8_t *key);
|
||||
typedef srtp_err_status_t (*srtp_cipher_init_func_t)(void *state,
|
||||
const uint8_t *key);
|
||||
|
||||
/* a srtp_cipher_dealloc_func_t de-allocates a cipher_t */
|
||||
typedef srtp_err_status_t (*srtp_cipher_dealloc_func_t)(srtp_cipher_pointer_t cp);
|
||||
typedef srtp_err_status_t (*srtp_cipher_dealloc_func_t)(
|
||||
srtp_cipher_pointer_t cp);
|
||||
|
||||
/*
|
||||
* a srtp_cipher_set_aad_func_t processes the AAD data for AEAD ciphers
|
||||
*/
|
||||
typedef srtp_err_status_t (*srtp_cipher_set_aad_func_t)
|
||||
(void *state, const uint8_t *aad, uint32_t aad_len);
|
||||
|
||||
typedef srtp_err_status_t (*srtp_cipher_set_aad_func_t)(void *state,
|
||||
const uint8_t *aad,
|
||||
uint32_t aad_len);
|
||||
|
||||
/* a srtp_cipher_encrypt_func_t encrypts data in-place */
|
||||
typedef srtp_err_status_t (*srtp_cipher_encrypt_func_t)
|
||||
(void *state, uint8_t *buffer, unsigned int *octets_to_encrypt);
|
||||
typedef srtp_err_status_t (*srtp_cipher_encrypt_func_t)(
|
||||
void *state,
|
||||
uint8_t *buffer,
|
||||
unsigned int *octets_to_encrypt);
|
||||
|
||||
/* a srtp_cipher_decrypt_func_t decrypts data in-place */
|
||||
typedef srtp_err_status_t (*srtp_cipher_decrypt_func_t)
|
||||
(void *state, uint8_t *buffer, unsigned int *octets_to_decrypt);
|
||||
typedef srtp_err_status_t (*srtp_cipher_decrypt_func_t)(
|
||||
void *state,
|
||||
uint8_t *buffer,
|
||||
unsigned int *octets_to_decrypt);
|
||||
|
||||
/*
|
||||
* a srtp_cipher_set_iv_func_t function sets the current initialization vector
|
||||
*/
|
||||
typedef srtp_err_status_t (*srtp_cipher_set_iv_func_t)
|
||||
(void *state, uint8_t *iv, srtp_cipher_direction_t direction);
|
||||
typedef srtp_err_status_t (*srtp_cipher_set_iv_func_t)(
|
||||
void *state,
|
||||
uint8_t *iv,
|
||||
srtp_cipher_direction_t direction);
|
||||
|
||||
/*
|
||||
* a cipher_get_tag_func_t function is used to get the authentication
|
||||
* tag that was calculated by an AEAD cipher.
|
||||
*/
|
||||
typedef srtp_err_status_t (*srtp_cipher_get_tag_func_t)
|
||||
(void *state, uint8_t *tag, uint32_t *len);
|
||||
|
||||
typedef srtp_err_status_t (*srtp_cipher_get_tag_func_t)(void *state,
|
||||
uint8_t *tag,
|
||||
uint32_t *len);
|
||||
|
||||
/*
|
||||
* srtp_cipher_test_case_t is a (list of) key, salt, plaintext, ciphertext,
|
||||
@@ -125,17 +132,18 @@ typedef srtp_err_status_t (*srtp_cipher_get_tag_func_t)
|
||||
* (see the srtp_cipher_type_self_test() function below)
|
||||
*/
|
||||
typedef struct srtp_cipher_test_case_t {
|
||||
int key_length_octets; /* octets in key */
|
||||
const uint8_t *key; /* key */
|
||||
uint8_t *idx; /* packet index */
|
||||
int plaintext_length_octets; /* octets in plaintext */
|
||||
const uint8_t *plaintext; /* plaintext */
|
||||
int ciphertext_length_octets; /* octets in plaintext */
|
||||
const uint8_t *ciphertext; /* ciphertext */
|
||||
int aad_length_octets; /* octets in AAD */
|
||||
const uint8_t *aad; /* AAD */
|
||||
int tag_length_octets; /* Length of AEAD tag */
|
||||
const struct srtp_cipher_test_case_t *next_test_case; /* pointer to next testcase */
|
||||
int key_length_octets; /* octets in key */
|
||||
const uint8_t *key; /* key */
|
||||
uint8_t *idx; /* packet index */
|
||||
unsigned int plaintext_length_octets; /* octets in plaintext */
|
||||
const uint8_t *plaintext; /* plaintext */
|
||||
unsigned int ciphertext_length_octets; /* octets in plaintext */
|
||||
const uint8_t *ciphertext; /* ciphertext */
|
||||
int aad_length_octets; /* octets in AAD */
|
||||
const uint8_t *aad; /* AAD */
|
||||
int tag_length_octets; /* Length of AEAD tag */
|
||||
const struct srtp_cipher_test_case_t
|
||||
*next_test_case; /* pointer to next testcase */
|
||||
} srtp_cipher_test_case_t;
|
||||
|
||||
/* srtp_cipher_type_t defines the 'metadata' for a particular cipher type */
|
||||
@@ -148,8 +156,8 @@ typedef struct srtp_cipher_type_t {
|
||||
srtp_cipher_encrypt_func_t decrypt;
|
||||
srtp_cipher_set_iv_func_t set_iv;
|
||||
srtp_cipher_get_tag_func_t get_tag;
|
||||
const char *description;
|
||||
const srtp_cipher_test_case_t *test_data;
|
||||
const char *description;
|
||||
const srtp_cipher_test_case_t *test_data;
|
||||
srtp_cipher_type_id_t id;
|
||||
} srtp_cipher_type_t;
|
||||
|
||||
@@ -159,7 +167,7 @@ typedef struct srtp_cipher_type_t {
|
||||
*/
|
||||
typedef struct srtp_cipher_t {
|
||||
const srtp_cipher_type_t *type;
|
||||
void *state;
|
||||
void *state;
|
||||
int key_len;
|
||||
int algorithm;
|
||||
} srtp_cipher_t;
|
||||
@@ -167,7 +175,6 @@ typedef struct srtp_cipher_t {
|
||||
/* some bookkeeping functions */
|
||||
int srtp_cipher_get_key_length(const srtp_cipher_t *c);
|
||||
|
||||
|
||||
/*
|
||||
* srtp_cipher_type_self_test() tests a cipher against test cases provided in
|
||||
* an array of values of key/srtp_xtd_seq_num_t/plaintext/ciphertext
|
||||
@@ -175,14 +182,15 @@ int srtp_cipher_get_key_length(const srtp_cipher_t *c);
|
||||
*/
|
||||
srtp_err_status_t srtp_cipher_type_self_test(const srtp_cipher_type_t *ct);
|
||||
|
||||
|
||||
/*
|
||||
* srtp_cipher_type_test() tests a cipher against external test cases provided in
|
||||
* srtp_cipher_type_test() tests a cipher against external test cases provided
|
||||
* in
|
||||
* an array of values of key/srtp_xtd_seq_num_t/plaintext/ciphertext
|
||||
* that is known to be good
|
||||
*/
|
||||
srtp_err_status_t srtp_cipher_type_test(const srtp_cipher_type_t *ct, const srtp_cipher_test_case_t *test_data);
|
||||
|
||||
srtp_err_status_t srtp_cipher_type_test(
|
||||
const srtp_cipher_type_t *ct,
|
||||
const srtp_cipher_test_case_t *test_data);
|
||||
|
||||
/*
|
||||
* srtp_cipher_bits_per_second(c, l, t) computes (an estimate of) the
|
||||
@@ -194,17 +202,34 @@ srtp_err_status_t srtp_cipher_type_test(const srtp_cipher_type_t *ct, const srtp
|
||||
*
|
||||
* if an error is encountered, then the value 0 is returned
|
||||
*/
|
||||
uint64_t srtp_cipher_bits_per_second(srtp_cipher_t *c, int octets_in_buffer, int num_trials);
|
||||
uint64_t srtp_cipher_bits_per_second(srtp_cipher_t *c,
|
||||
int octets_in_buffer,
|
||||
int num_trials);
|
||||
|
||||
srtp_err_status_t srtp_cipher_type_alloc(const srtp_cipher_type_t *ct, srtp_cipher_t **c, int key_len, int tlen);
|
||||
srtp_err_status_t srtp_cipher_type_alloc(const srtp_cipher_type_t *ct,
|
||||
srtp_cipher_t **c,
|
||||
int key_len,
|
||||
int tlen);
|
||||
srtp_err_status_t srtp_cipher_dealloc(srtp_cipher_t *c);
|
||||
srtp_err_status_t srtp_cipher_init(srtp_cipher_t *c, const uint8_t *key);
|
||||
srtp_err_status_t srtp_cipher_set_iv(srtp_cipher_t *c, uint8_t *iv, int direction);
|
||||
srtp_err_status_t srtp_cipher_output(srtp_cipher_t *c, uint8_t *buffer, uint32_t *num_octets_to_output);
|
||||
srtp_err_status_t srtp_cipher_encrypt(srtp_cipher_t *c, uint8_t *buffer, uint32_t *num_octets_to_output);
|
||||
srtp_err_status_t srtp_cipher_decrypt(srtp_cipher_t *c, uint8_t *buffer, uint32_t *num_octets_to_output);
|
||||
srtp_err_status_t srtp_cipher_get_tag(srtp_cipher_t *c, uint8_t *buffer, uint32_t *tag_len);
|
||||
srtp_err_status_t srtp_cipher_set_aad(srtp_cipher_t *c, const uint8_t *aad, uint32_t aad_len);
|
||||
srtp_err_status_t srtp_cipher_set_iv(srtp_cipher_t *c,
|
||||
uint8_t *iv,
|
||||
int direction);
|
||||
srtp_err_status_t srtp_cipher_output(srtp_cipher_t *c,
|
||||
uint8_t *buffer,
|
||||
uint32_t *num_octets_to_output);
|
||||
srtp_err_status_t srtp_cipher_encrypt(srtp_cipher_t *c,
|
||||
uint8_t *buffer,
|
||||
uint32_t *num_octets_to_output);
|
||||
srtp_err_status_t srtp_cipher_decrypt(srtp_cipher_t *c,
|
||||
uint8_t *buffer,
|
||||
uint32_t *num_octets_to_output);
|
||||
srtp_err_status_t srtp_cipher_get_tag(srtp_cipher_t *c,
|
||||
uint8_t *buffer,
|
||||
uint32_t *tag_len);
|
||||
srtp_err_status_t srtp_cipher_set_aad(srtp_cipher_t *c,
|
||||
const uint8_t *aad,
|
||||
uint32_t aad_len);
|
||||
|
||||
/*
|
||||
* srtp_replace_cipher_type(ct, id)
|
||||
@@ -213,7 +238,8 @@ srtp_err_status_t srtp_cipher_set_aad(srtp_cipher_t *c, const uint8_t *aad, uint
|
||||
* with a new one passed in externally. The new cipher must pass all the
|
||||
* existing cipher_type's self tests as well as its own.
|
||||
*/
|
||||
srtp_err_status_t srtp_replace_cipher_type(const srtp_cipher_type_t *ct, srtp_cipher_type_id_t id);
|
||||
srtp_err_status_t srtp_replace_cipher_type(const srtp_cipher_type_t *ct,
|
||||
srtp_cipher_type_id_t id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
*
|
||||
* Copyright(c) 2001-2017 Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CIHPER_TYPES_H
|
||||
#define CIHPER_TYPES_H
|
||||
|
||||
#include "cipher.h"
|
||||
#include "auth.h"
|
||||
|
||||
/*
|
||||
* cipher types that can be included in the kernel
|
||||
*/
|
||||
|
||||
extern const srtp_cipher_type_t srtp_null_cipher;
|
||||
extern const srtp_cipher_type_t srtp_aes_icm_128;
|
||||
extern const srtp_cipher_type_t srtp_aes_icm_256;
|
||||
#ifdef OPENSSL
|
||||
extern const srtp_cipher_type_t srtp_aes_icm_192;
|
||||
extern const srtp_cipher_type_t srtp_aes_gcm_128_openssl;
|
||||
extern const srtp_cipher_type_t srtp_aes_gcm_256_openssl;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* auth func types that can be included in the kernel
|
||||
*/
|
||||
|
||||
extern const srtp_auth_type_t srtp_null_auth;
|
||||
extern const srtp_auth_type_t srtp_hmac;
|
||||
|
||||
/*
|
||||
* other generic debug modules that can be included in the kernel
|
||||
*/
|
||||
|
||||
extern srtp_debug_module_t srtp_mod_auth;
|
||||
extern srtp_debug_module_t srtp_mod_cipher;
|
||||
extern srtp_debug_module_t srtp_mod_stat;
|
||||
extern srtp_debug_module_t srtp_mod_alloc;
|
||||
|
||||
/* debug modules for cipher types */
|
||||
extern srtp_debug_module_t srtp_mod_aes_icm;
|
||||
#ifdef OPENSSL
|
||||
extern srtp_debug_module_t srtp_mod_aes_gcm;
|
||||
#endif
|
||||
|
||||
/* debug modules for auth types */
|
||||
extern srtp_debug_module_t srtp_mod_hmac;
|
||||
|
||||
#endif
|
||||
@@ -42,7 +42,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYPTO_KERNEL
|
||||
#define CRYPTO_KERNEL
|
||||
|
||||
@@ -72,7 +71,7 @@ typedef enum {
|
||||
*/
|
||||
typedef struct srtp_kernel_cipher_type {
|
||||
srtp_cipher_type_id_t id;
|
||||
const srtp_cipher_type_t *cipher_type;
|
||||
const srtp_cipher_type_t *cipher_type;
|
||||
struct srtp_kernel_cipher_type *next;
|
||||
} srtp_kernel_cipher_type_t;
|
||||
|
||||
@@ -81,7 +80,7 @@ typedef struct srtp_kernel_cipher_type {
|
||||
*/
|
||||
typedef struct srtp_kernel_auth_type {
|
||||
srtp_auth_type_id_t id;
|
||||
const srtp_auth_type_t *auth_type;
|
||||
const srtp_auth_type_t *auth_type;
|
||||
struct srtp_kernel_auth_type *next;
|
||||
} srtp_kernel_auth_type_t;
|
||||
|
||||
@@ -93,7 +92,6 @@ typedef struct srtp_kernel_debug_module {
|
||||
struct srtp_kernel_debug_module *next;
|
||||
} srtp_kernel_debug_module_t;
|
||||
|
||||
|
||||
/*
|
||||
* crypto_kernel_t is the data structure for the crypto kernel
|
||||
*
|
||||
@@ -101,18 +99,17 @@ typedef struct srtp_kernel_debug_module {
|
||||
* a global variable defined in crypto_kernel.c
|
||||
*/
|
||||
typedef struct {
|
||||
srtp_crypto_kernel_state_t state; /* current state of kernel */
|
||||
srtp_kernel_cipher_type_t *cipher_type_list; /* list of all cipher types */
|
||||
srtp_kernel_auth_type_t *auth_type_list; /* list of all auth func types */
|
||||
srtp_kernel_debug_module_t *debug_module_list; /* list of all debug modules */
|
||||
srtp_crypto_kernel_state_t state; /* current state of kernel */
|
||||
srtp_kernel_cipher_type_t *cipher_type_list; /* list of all cipher types */
|
||||
srtp_kernel_auth_type_t *auth_type_list; /* list of all auth func types */
|
||||
srtp_kernel_debug_module_t
|
||||
*debug_module_list; /* list of all debug modules */
|
||||
} srtp_crypto_kernel_t;
|
||||
|
||||
|
||||
/*
|
||||
* srtp_crypto_kernel_t external api
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The function srtp_crypto_kernel_init() initialized the crypto kernel and
|
||||
* runs the self-test operations on the random number generators and
|
||||
@@ -126,7 +123,6 @@ typedef struct {
|
||||
*/
|
||||
srtp_err_status_t srtp_crypto_kernel_init(void);
|
||||
|
||||
|
||||
/*
|
||||
* The function srtp_crypto_kernel_shutdown() de-initializes the
|
||||
* crypto_kernel, zeroizes keys and other cryptographic material, and
|
||||
@@ -150,7 +146,6 @@ srtp_err_status_t srtp_crypto_kernel_shutdown(void);
|
||||
*/
|
||||
srtp_err_status_t srtp_crypto_kernel_status(void);
|
||||
|
||||
|
||||
/*
|
||||
* srtp_crypto_kernel_list_debug_modules() outputs a list of debugging modules
|
||||
*
|
||||
@@ -161,11 +156,15 @@ srtp_err_status_t srtp_crypto_kernel_list_debug_modules(void);
|
||||
* srtp_crypto_kernel_load_cipher_type()
|
||||
*
|
||||
*/
|
||||
srtp_err_status_t srtp_crypto_kernel_load_cipher_type(const srtp_cipher_type_t *ct, srtp_cipher_type_id_t id);
|
||||
srtp_err_status_t srtp_crypto_kernel_load_cipher_type(
|
||||
const srtp_cipher_type_t *ct,
|
||||
srtp_cipher_type_id_t id);
|
||||
|
||||
srtp_err_status_t srtp_crypto_kernel_load_auth_type(const srtp_auth_type_t *ct, srtp_auth_type_id_t id);
|
||||
srtp_err_status_t srtp_crypto_kernel_load_auth_type(const srtp_auth_type_t *ct,
|
||||
srtp_auth_type_id_t id);
|
||||
|
||||
srtp_err_status_t srtp_crypto_kernel_load_debug_module(srtp_debug_module_t *new_dm);
|
||||
srtp_err_status_t srtp_crypto_kernel_load_debug_module(
|
||||
srtp_debug_module_t *new_dm);
|
||||
|
||||
/*
|
||||
* srtp_crypto_kernel_alloc_cipher(id, cp, key_len);
|
||||
@@ -177,7 +176,10 @@ srtp_err_status_t srtp_crypto_kernel_load_debug_module(srtp_debug_module_t *new_
|
||||
* srtp_err_status_alloc_fail an allocation failure occured
|
||||
* srtp_err_status_fail couldn't find cipher with identifier 'id'
|
||||
*/
|
||||
srtp_err_status_t srtp_crypto_kernel_alloc_cipher(srtp_cipher_type_id_t id, srtp_cipher_pointer_t *cp, int key_len, int tag_len);
|
||||
srtp_err_status_t srtp_crypto_kernel_alloc_cipher(srtp_cipher_type_id_t id,
|
||||
srtp_cipher_pointer_t *cp,
|
||||
int key_len,
|
||||
int tag_len);
|
||||
|
||||
/*
|
||||
* srtp_crypto_kernel_alloc_auth(id, ap, key_len, tag_len);
|
||||
@@ -190,8 +192,10 @@ srtp_err_status_t srtp_crypto_kernel_alloc_cipher(srtp_cipher_type_id_t id, srtp
|
||||
* srtp_err_status_alloc_fail an allocation failure occured
|
||||
* srtp_err_status_fail couldn't find auth with identifier 'id'
|
||||
*/
|
||||
srtp_err_status_t srtp_crypto_kernel_alloc_auth(srtp_auth_type_id_t id, srtp_auth_pointer_t *ap, int key_len, int tag_len);
|
||||
|
||||
srtp_err_status_t srtp_crypto_kernel_alloc_auth(srtp_auth_type_id_t id,
|
||||
srtp_auth_pointer_t *ap,
|
||||
int key_len,
|
||||
int tag_len);
|
||||
|
||||
/*
|
||||
* srtp_crypto_kernel_set_debug_module(mod_name, v)
|
||||
@@ -201,7 +205,8 @@ srtp_err_status_t srtp_crypto_kernel_alloc_auth(srtp_auth_type_id_t id, srtp_aut
|
||||
*
|
||||
* returns srtp_err_status_ok on success, srtp_err_status_fail otherwise
|
||||
*/
|
||||
srtp_err_status_t srtp_crypto_kernel_set_debug_module(const char *mod_name, int v);
|
||||
srtp_err_status_t srtp_crypto_kernel_set_debug_module(const char *mod_name,
|
||||
int v);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -7,26 +7,26 @@
|
||||
* Cisco Systems, Inc.
|
||||
*/
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright(c) 2001-2017 Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -48,62 +48,62 @@
|
||||
/*
|
||||
* The null cipher performs no encryption.
|
||||
*
|
||||
* The SRTP_NULL_CIPHER leaves its inputs unaltered, during both the
|
||||
* The SRTP_NULL_CIPHER leaves its inputs unaltered, during both the
|
||||
* encryption and decryption operations. This cipher can be chosen
|
||||
* to indicate that no encryption is to be performed.
|
||||
*/
|
||||
#define SRTP_NULL_CIPHER 0
|
||||
#define SRTP_NULL_CIPHER 0
|
||||
|
||||
/*
|
||||
/*
|
||||
* AES-128 Integer Counter Mode (AES ICM)
|
||||
*
|
||||
* AES-128 ICM is the variant of counter mode that is used by
|
||||
* Secure RTP. This cipher uses a 16-octet key concatenated with a
|
||||
* 14-octet offset (or salt) value.
|
||||
*/
|
||||
#define SRTP_AES_ICM_128 1
|
||||
#define SRTP_AES_ICM_128 1
|
||||
|
||||
/*
|
||||
/*
|
||||
* AES-192 Integer Counter Mode (AES ICM)
|
||||
*
|
||||
* AES-128 ICM is the variant of counter mode that is used by
|
||||
* Secure RTP. This cipher uses a 24-octet key concatenated with a
|
||||
* 14-octet offset (or salt) value.
|
||||
*/
|
||||
#define SRTP_AES_ICM_192 4
|
||||
#define SRTP_AES_ICM_192 4
|
||||
|
||||
/*
|
||||
/*
|
||||
* AES-256 Integer Counter Mode (AES ICM)
|
||||
*
|
||||
* AES-128 ICM is the variant of counter mode that is used by
|
||||
* Secure RTP. This cipher uses a 32-octet key concatenated with a
|
||||
* 14-octet offset (or salt) value.
|
||||
*/
|
||||
#define SRTP_AES_ICM_256 5
|
||||
#define SRTP_AES_ICM_256 5
|
||||
|
||||
/*
|
||||
* AES-128_GCM Galois Counter Mode (AES GCM)
|
||||
/*
|
||||
* AES-128_GCM Galois Counter Mode (AES GCM)
|
||||
*
|
||||
* AES-128 GCM is the variant of galois counter mode that is used by
|
||||
* AES-128 GCM is the variant of galois counter mode that is used by
|
||||
* Secure RTP. This cipher uses a 16-octet key.
|
||||
*/
|
||||
#define SRTP_AES_GCM_128 6
|
||||
#define SRTP_AES_GCM_128 6
|
||||
|
||||
/*
|
||||
* AES-256_GCM Galois Counter Mode (AES GCM)
|
||||
/*
|
||||
* AES-256_GCM Galois Counter Mode (AES GCM)
|
||||
*
|
||||
* AES-256 GCM is the variant of galois counter mode that is used by
|
||||
* AES-256 GCM is the variant of galois counter mode that is used by
|
||||
* Secure RTP. This cipher uses a 32-octet key.
|
||||
*/
|
||||
#define SRTP_AES_GCM_256 7
|
||||
#define SRTP_AES_GCM_256 7
|
||||
|
||||
/*
|
||||
* The null authentication function performs no authentication.
|
||||
*
|
||||
* The NULL_AUTH function does nothing, and can be selected to indicate
|
||||
* that authentication should not be performed.
|
||||
*/
|
||||
#define SRTP_NULL_AUTH 0
|
||||
*/
|
||||
#define SRTP_NULL_AUTH 0
|
||||
|
||||
/*
|
||||
* HMAC-SHA1
|
||||
@@ -111,6 +111,6 @@
|
||||
* SRTP_HMAC_SHA1 implements the Hash-based MAC using the NIST Secure
|
||||
* Hash Algorithm version 1 (SHA1).
|
||||
*/
|
||||
#define SRTP_HMAC_SHA1 3
|
||||
#define SRTP_HMAC_SHA1 3
|
||||
|
||||
#endif /* SRTP_CRYPTO_TYPES_H */
|
||||
#endif /* SRTP_CRYPTO_TYPES_H */
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* datatypes.h
|
||||
*
|
||||
*
|
||||
* data types for bit vectors and finite fields
|
||||
*
|
||||
* David A. McGrew
|
||||
@@ -8,26 +8,26 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2001-2017, Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -43,11 +43,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DATATYPES_H
|
||||
#define DATATYPES_H
|
||||
|
||||
#include "integers.h" /* definitions of uint32_t, et cetera */
|
||||
#include "integers.h" /* definitions of uint32_t, et cetera */
|
||||
#include "alloc.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
@@ -56,42 +55,43 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#include <netinet/in.h>
|
||||
#elif defined HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#error "Platform not recognized"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* if DATATYPES_USE_MACROS is defined, then little functions are macros */
|
||||
#define DATATYPES_USE_MACROS
|
||||
#define DATATYPES_USE_MACROS
|
||||
|
||||
typedef union {
|
||||
uint8_t v8[2];
|
||||
uint16_t value;
|
||||
uint8_t v8[2];
|
||||
uint16_t value;
|
||||
} v16_t;
|
||||
|
||||
typedef union {
|
||||
uint8_t v8[4];
|
||||
uint16_t v16[2];
|
||||
uint32_t value;
|
||||
uint8_t v8[4];
|
||||
uint16_t v16[2];
|
||||
uint32_t value;
|
||||
} v32_t;
|
||||
|
||||
typedef union {
|
||||
uint8_t v8[8];
|
||||
uint16_t v16[4];
|
||||
uint32_t v32[2];
|
||||
uint64_t value;
|
||||
uint8_t v8[8];
|
||||
uint16_t v16[4];
|
||||
uint32_t v32[2];
|
||||
uint64_t value;
|
||||
} v64_t;
|
||||
|
||||
typedef union {
|
||||
uint8_t v8[16];
|
||||
uint16_t v16[8];
|
||||
uint32_t v32[4];
|
||||
uint64_t v64[2];
|
||||
uint8_t v8[16];
|
||||
uint16_t v16[8];
|
||||
uint32_t v32[4];
|
||||
uint64_t v64[2];
|
||||
} v128_t;
|
||||
|
||||
typedef union {
|
||||
@@ -101,118 +101,82 @@ typedef union {
|
||||
uint64_t v64[4];
|
||||
} v256_t;
|
||||
|
||||
|
||||
/* some useful and simple math functions */
|
||||
|
||||
#define pow_2(X) ( (unsigned int)1 << (X) ) /* 2^X */
|
||||
|
||||
#define pow_minus_one(X) ( (X) ? -1 : 1 ) /* (-1)^X */
|
||||
#define pow_2(X) ((unsigned int)1 << (X)) /* 2^X */
|
||||
|
||||
#define pow_minus_one(X) ((X) ? -1 : 1) /* (-1)^X */
|
||||
|
||||
/*
|
||||
* octet_get_weight(x) returns the hamming weight (number of bits equal to
|
||||
* one) in the octet x
|
||||
*/
|
||||
|
||||
int
|
||||
octet_get_weight(uint8_t octet);
|
||||
int octet_get_weight(uint8_t octet);
|
||||
|
||||
#define MAX_PRINT_STRING_LEN 1024
|
||||
|
||||
char *
|
||||
srtp_octet_string_hex_string(const void *str, int length);
|
||||
char *srtp_octet_string_hex_string(const void *str, int length);
|
||||
|
||||
char *
|
||||
v128_bit_string(v128_t *x);
|
||||
char *v128_bit_string(v128_t *x);
|
||||
|
||||
char *
|
||||
v128_hex_string(v128_t *x);
|
||||
char *v128_hex_string(v128_t *x);
|
||||
|
||||
void
|
||||
v128_copy_octet_string(v128_t *x, const uint8_t s[16]);
|
||||
void v128_copy_octet_string(v128_t *x, const uint8_t s[16]);
|
||||
|
||||
void
|
||||
v128_left_shift(v128_t *x, int shift_index);
|
||||
void v128_left_shift(v128_t *x, int shift_index);
|
||||
|
||||
void
|
||||
v128_right_shift(v128_t *x, int shift_index);
|
||||
void v128_right_shift(v128_t *x, int shift_index);
|
||||
|
||||
/*
|
||||
* the following macros define the data manipulation functions
|
||||
*
|
||||
*
|
||||
* If DATATYPES_USE_MACROS is defined, then these macros are used
|
||||
* directly (and function call overhead is avoided). Otherwise,
|
||||
* the macros are used through the functions defined in datatypes.c
|
||||
* (and the compiler provides better warnings).
|
||||
*/
|
||||
|
||||
#define _v128_set_to_zero(x) \
|
||||
( \
|
||||
(x)->v32[0] = 0, \
|
||||
(x)->v32[1] = 0, \
|
||||
(x)->v32[2] = 0, \
|
||||
(x)->v32[3] = 0 \
|
||||
)
|
||||
#define _v128_set_to_zero(x) \
|
||||
((x)->v32[0] = 0, (x)->v32[1] = 0, (x)->v32[2] = 0, (x)->v32[3] = 0)
|
||||
|
||||
#define _v128_copy(x, y) \
|
||||
( \
|
||||
(x)->v32[0] = (y)->v32[0], \
|
||||
(x)->v32[1] = (y)->v32[1], \
|
||||
(x)->v32[2] = (y)->v32[2], \
|
||||
(x)->v32[3] = (y)->v32[3] \
|
||||
)
|
||||
#define _v128_copy(x, y) \
|
||||
((x)->v32[0] = (y)->v32[0], (x)->v32[1] = (y)->v32[1], \
|
||||
(x)->v32[2] = (y)->v32[2], (x)->v32[3] = (y)->v32[3])
|
||||
|
||||
#define _v128_xor(z, x, y) \
|
||||
( \
|
||||
(z)->v32[0] = (x)->v32[0] ^ (y)->v32[0], \
|
||||
(z)->v32[1] = (x)->v32[1] ^ (y)->v32[1], \
|
||||
(z)->v32[2] = (x)->v32[2] ^ (y)->v32[2], \
|
||||
(z)->v32[3] = (x)->v32[3] ^ (y)->v32[3] \
|
||||
)
|
||||
#define _v128_xor(z, x, y) \
|
||||
((z)->v32[0] = (x)->v32[0] ^ (y)->v32[0], \
|
||||
(z)->v32[1] = (x)->v32[1] ^ (y)->v32[1], \
|
||||
(z)->v32[2] = (x)->v32[2] ^ (y)->v32[2], \
|
||||
(z)->v32[3] = (x)->v32[3] ^ (y)->v32[3])
|
||||
|
||||
#define _v128_and(z, x, y) \
|
||||
( \
|
||||
(z)->v32[0] = (x)->v32[0] & (y)->v32[0], \
|
||||
(z)->v32[1] = (x)->v32[1] & (y)->v32[1], \
|
||||
(z)->v32[2] = (x)->v32[2] & (y)->v32[2], \
|
||||
(z)->v32[3] = (x)->v32[3] & (y)->v32[3] \
|
||||
)
|
||||
#define _v128_and(z, x, y) \
|
||||
((z)->v32[0] = (x)->v32[0] & (y)->v32[0], \
|
||||
(z)->v32[1] = (x)->v32[1] & (y)->v32[1], \
|
||||
(z)->v32[2] = (x)->v32[2] & (y)->v32[2], \
|
||||
(z)->v32[3] = (x)->v32[3] & (y)->v32[3])
|
||||
|
||||
#define _v128_or(z, x, y) \
|
||||
( \
|
||||
(z)->v32[0] = (x)->v32[0] | (y)->v32[0], \
|
||||
(z)->v32[1] = (x)->v32[1] | (y)->v32[1], \
|
||||
(z)->v32[2] = (x)->v32[2] | (y)->v32[2], \
|
||||
(z)->v32[3] = (x)->v32[3] | (y)->v32[3] \
|
||||
)
|
||||
#define _v128_or(z, x, y) \
|
||||
((z)->v32[0] = (x)->v32[0] | (y)->v32[0], \
|
||||
(z)->v32[1] = (x)->v32[1] | (y)->v32[1], \
|
||||
(z)->v32[2] = (x)->v32[2] | (y)->v32[2], \
|
||||
(z)->v32[3] = (x)->v32[3] | (y)->v32[3])
|
||||
|
||||
#define _v128_complement(x) \
|
||||
( \
|
||||
(x)->v32[0] = ~(x)->v32[0], \
|
||||
(x)->v32[1] = ~(x)->v32[1], \
|
||||
(x)->v32[2] = ~(x)->v32[2], \
|
||||
(x)->v32[3] = ~(x)->v32[3] \
|
||||
)
|
||||
#define _v128_complement(x) \
|
||||
((x)->v32[0] = ~(x)->v32[0], (x)->v32[1] = ~(x)->v32[1], \
|
||||
(x)->v32[2] = ~(x)->v32[2], (x)->v32[3] = ~(x)->v32[3])
|
||||
|
||||
/* ok for NO_64BIT_MATH if it can compare uint64_t's (even as structures) */
|
||||
#define _v128_is_eq(x, y) \
|
||||
(((x)->v64[0] == (y)->v64[0]) && ((x)->v64[1] == (y)->v64[1]))
|
||||
|
||||
#define _v128_is_eq(x, y) \
|
||||
(((x)->v64[0] == (y)->v64[0]) && ((x)->v64[1] == (y)->v64[1]))
|
||||
|
||||
#ifdef NO_64BIT_MATH
|
||||
#define _v128_xor_eq(z, x) \
|
||||
( \
|
||||
(z)->v32[0] ^= (x)->v32[0], \
|
||||
(z)->v32[1] ^= (x)->v32[1], \
|
||||
(z)->v32[2] ^= (x)->v32[2], \
|
||||
(z)->v32[3] ^= (x)->v32[3] \
|
||||
)
|
||||
#define _v128_xor_eq(z, x) \
|
||||
((z)->v32[0] ^= (x)->v32[0], (z)->v32[1] ^= (x)->v32[1], \
|
||||
(z)->v32[2] ^= (x)->v32[2], (z)->v32[3] ^= (x)->v32[3])
|
||||
#else
|
||||
#define _v128_xor_eq(z, x) \
|
||||
( \
|
||||
(z)->v64[0] ^= (x)->v64[0], \
|
||||
(z)->v64[1] ^= (x)->v64[1] \
|
||||
)
|
||||
#define _v128_xor_eq(z, x) \
|
||||
((z)->v64[0] ^= (x)->v64[0], (z)->v64[1] ^= (x)->v64[1])
|
||||
#endif
|
||||
|
||||
/* NOTE! This assumes an odd ordering! */
|
||||
@@ -224,76 +188,55 @@ v128_right_shift(v128_t *x, int shift_index);
|
||||
really care which bit is which. AES does care which bit is which, but
|
||||
doesn't use the 128-bit get/set or 128-bit shifts */
|
||||
|
||||
#define _v128_get_bit(x, bit) \
|
||||
( \
|
||||
((((x)->v32[(bit) >> 5]) >> ((bit) & 31)) & 1) \
|
||||
)
|
||||
#define _v128_get_bit(x, bit) (((((x)->v32[(bit) >> 5]) >> ((bit)&31)) & 1))
|
||||
|
||||
#define _v128_set_bit(x, bit) \
|
||||
( \
|
||||
(((x)->v32[(bit) >> 5]) |= ((uint32_t)1 << ((bit) & 31))) \
|
||||
)
|
||||
#define _v128_set_bit(x, bit) \
|
||||
((((x)->v32[(bit) >> 5]) |= ((uint32_t)1 << ((bit)&31))))
|
||||
|
||||
#define _v128_clear_bit(x, bit) \
|
||||
( \
|
||||
(((x)->v32[(bit) >> 5]) &= ~((uint32_t)1 << ((bit) & 31))) \
|
||||
)
|
||||
#define _v128_clear_bit(x, bit) \
|
||||
((((x)->v32[(bit) >> 5]) &= ~((uint32_t)1 << ((bit)&31))))
|
||||
|
||||
#define _v128_set_bit_to(x, bit, value) \
|
||||
( \
|
||||
(value) ? _v128_set_bit(x, bit) : \
|
||||
_v128_clear_bit(x, bit) \
|
||||
)
|
||||
#define _v128_set_bit_to(x, bit, value) \
|
||||
((value) ? _v128_set_bit(x, bit) : _v128_clear_bit(x, bit))
|
||||
|
||||
#ifdef DATATYPES_USE_MACROS /* little functions are really macros */
|
||||
|
||||
#define v128_set_to_zero(z) _v128_set_to_zero(z)
|
||||
#define v128_copy(z, x) _v128_copy(z, x)
|
||||
#define v128_xor(z, x, y) _v128_xor(z, x, y)
|
||||
#define v128_and(z, x, y) _v128_and(z, x, y)
|
||||
#define v128_or(z, x, y) _v128_or(z, x, y)
|
||||
#define v128_complement(x) _v128_complement(x)
|
||||
#define v128_is_eq(x, y) _v128_is_eq(x, y)
|
||||
#define v128_xor_eq(x, y) _v128_xor_eq(x, y)
|
||||
#define v128_get_bit(x, i) _v128_get_bit(x, i)
|
||||
#define v128_set_bit(x, i) _v128_set_bit(x, i)
|
||||
#define v128_clear_bit(x, i) _v128_clear_bit(x, i)
|
||||
#define v128_set_bit_to(x, i, y) _v128_set_bit_to(x, i, y)
|
||||
#ifdef DATATYPES_USE_MACROS /* little functions are really macros */
|
||||
|
||||
#define v128_set_to_zero(z) _v128_set_to_zero(z)
|
||||
#define v128_copy(z, x) _v128_copy(z, x)
|
||||
#define v128_xor(z, x, y) _v128_xor(z, x, y)
|
||||
#define v128_and(z, x, y) _v128_and(z, x, y)
|
||||
#define v128_or(z, x, y) _v128_or(z, x, y)
|
||||
#define v128_complement(x) _v128_complement(x)
|
||||
#define v128_is_eq(x, y) _v128_is_eq(x, y)
|
||||
#define v128_xor_eq(x, y) _v128_xor_eq(x, y)
|
||||
#define v128_get_bit(x, i) _v128_get_bit(x, i)
|
||||
#define v128_set_bit(x, i) _v128_set_bit(x, i)
|
||||
#define v128_clear_bit(x, i) _v128_clear_bit(x, i)
|
||||
#define v128_set_bit_to(x, i, y) _v128_set_bit_to(x, i, y)
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
v128_set_to_zero(v128_t *x);
|
||||
void v128_set_to_zero(v128_t *x);
|
||||
|
||||
int
|
||||
v128_is_eq(const v128_t *x, const v128_t *y);
|
||||
int v128_is_eq(const v128_t *x, const v128_t *y);
|
||||
|
||||
void
|
||||
v128_copy(v128_t *x, const v128_t *y);
|
||||
void v128_copy(v128_t *x, const v128_t *y);
|
||||
|
||||
void
|
||||
v128_xor(v128_t *z, v128_t *x, v128_t *y);
|
||||
void v128_xor(v128_t *z, v128_t *x, v128_t *y);
|
||||
|
||||
void
|
||||
v128_and(v128_t *z, v128_t *x, v128_t *y);
|
||||
void v128_and(v128_t *z, v128_t *x, v128_t *y);
|
||||
|
||||
void
|
||||
v128_or(v128_t *z, v128_t *x, v128_t *y);
|
||||
void v128_or(v128_t *z, v128_t *x, v128_t *y);
|
||||
|
||||
void
|
||||
v128_complement(v128_t *x);
|
||||
void v128_complement(v128_t *x);
|
||||
|
||||
int
|
||||
v128_get_bit(const v128_t *x, int i);
|
||||
int v128_get_bit(const v128_t *x, int i);
|
||||
|
||||
void
|
||||
v128_set_bit(v128_t *x, int i) ;
|
||||
void v128_set_bit(v128_t *x, int i);
|
||||
|
||||
void
|
||||
v128_clear_bit(v128_t *x, int i);
|
||||
void v128_clear_bit(v128_t *x, int i);
|
||||
|
||||
void
|
||||
v128_set_bit_to(v128_t *x, int i, int y);
|
||||
void v128_set_bit_to(v128_t *x, int i, int y);
|
||||
|
||||
#endif /* DATATYPES_USE_MACROS */
|
||||
|
||||
@@ -304,113 +247,102 @@ v128_set_bit_to(v128_t *x, int i, int y);
|
||||
* verifying authentication tags.
|
||||
*/
|
||||
|
||||
int
|
||||
octet_string_is_eq(uint8_t *a, uint8_t *b, int len);
|
||||
int octet_string_is_eq(uint8_t *a, uint8_t *b, int len);
|
||||
|
||||
/*
|
||||
* A portable way to zero out memory as recommended by
|
||||
* https://cryptocoding.net/index.php/Coding_rules#Clean_memory_of_secret_data
|
||||
* This is used to zero memory when OPENSSL_cleanse() is not available.
|
||||
*/
|
||||
void
|
||||
srtp_cleanse(void *s, size_t len);
|
||||
void srtp_cleanse(void *s, size_t len);
|
||||
|
||||
/*
|
||||
* Functions as a wrapper that delegates to either srtp_cleanse() or
|
||||
* OPENSSL_cleanse() if available to zero memory.
|
||||
*/
|
||||
void
|
||||
octet_string_set_to_zero(void *s, size_t len);
|
||||
void octet_string_set_to_zero(void *s, size_t len);
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
|
||||
/*
|
||||
/*
|
||||
* Convert big endian integers to CPU byte order.
|
||||
*/
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
/* Nothing to do. */
|
||||
# define be32_to_cpu(x) (x)
|
||||
# define be64_to_cpu(x) (x)
|
||||
#define be32_to_cpu(x) (x)
|
||||
#define be64_to_cpu(x) (x)
|
||||
#elif defined(HAVE_BYTESWAP_H)
|
||||
/* We have (hopefully) optimized versions in byteswap.h */
|
||||
# include <byteswap.h>
|
||||
# define be32_to_cpu(x) bswap_32((x))
|
||||
# define be64_to_cpu(x) bswap_64((x))
|
||||
#else
|
||||
#include <byteswap.h>
|
||||
#define be32_to_cpu(x) bswap_32((x))
|
||||
#define be64_to_cpu(x) bswap_64((x))
|
||||
#else /* WORDS_BIGENDIAN */
|
||||
|
||||
#if defined(__GNUC__) && defined(HAVE_X86)
|
||||
/* Fall back. */
|
||||
static inline uint32_t be32_to_cpu(uint32_t v) {
|
||||
/* optimized for x86. */
|
||||
__asm__("bswap %0" : "=r" (v) : "0" (v));
|
||||
return v;
|
||||
static inline uint32_t be32_to_cpu(uint32_t v)
|
||||
{
|
||||
/* optimized for x86. */
|
||||
asm("bswap %0" : "=r"(v) : "0"(v));
|
||||
return v;
|
||||
}
|
||||
# else /* HAVE_X86 */
|
||||
# ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
# elif defined HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
# endif
|
||||
# define be32_to_cpu(x) ntohl((x))
|
||||
# endif /* HAVE_X86 */
|
||||
#else /* HAVE_X86 */
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#elif defined HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif /* HAVE_NETINET_IN_H */
|
||||
#define be32_to_cpu(x) ntohl((x))
|
||||
#endif /* HAVE_X86 */
|
||||
|
||||
static inline uint64_t be64_to_cpu(uint64_t v) {
|
||||
# ifdef NO_64BIT_MATH
|
||||
/* use the make64 functions to do 64-bit math */
|
||||
v = make64(htonl(low32(v)),htonl(high32(v)));
|
||||
# else
|
||||
/* use the native 64-bit math */
|
||||
v= (uint64_t)((be32_to_cpu((uint32_t)(v >> 32))) | (((uint64_t)be32_to_cpu((uint32_t)v)) << 32));
|
||||
# endif
|
||||
return v;
|
||||
static inline uint64_t be64_to_cpu(uint64_t v)
|
||||
{
|
||||
#ifdef NO_64BIT_MATH
|
||||
/* use the make64 functions to do 64-bit math */
|
||||
v = make64(htonl(low32(v)), htonl(high32(v)));
|
||||
#else /* NO_64BIT_MATH */
|
||||
/* use the native 64-bit math */
|
||||
v = (uint64_t)((be32_to_cpu((uint32_t)(v >> 32))) |
|
||||
(((uint64_t)be32_to_cpu((uint32_t)v)) << 32));
|
||||
#endif /* NO_64BIT_MATH */
|
||||
return v;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
/*
|
||||
* functions manipulating bitvector_t
|
||||
* functions manipulating bitvector_t
|
||||
*
|
||||
* A bitvector_t consists of an array of words and an integer
|
||||
* representing the number of significant bits stored in the array.
|
||||
* The bits are packed as follows: the least significant bit is that
|
||||
* of word[0], while the most significant bit is the nth most
|
||||
* significant bit of word[m], where length = bits_per_word * m + n.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#define bits_per_word 32
|
||||
#define bits_per_word 32
|
||||
#define bytes_per_word 4
|
||||
|
||||
typedef struct {
|
||||
uint32_t length;
|
||||
uint32_t *word;
|
||||
uint32_t length;
|
||||
uint32_t *word;
|
||||
} bitvector_t;
|
||||
|
||||
#define _bitvector_get_bit(v, bit_index) \
|
||||
(((((v)->word[((bit_index) >> 5)]) >> ((bit_index)&31)) & 1))
|
||||
|
||||
#define _bitvector_get_bit(v, bit_index) \
|
||||
( \
|
||||
((((v)->word[((bit_index) >> 5)]) >> ((bit_index) & 31)) & 1) \
|
||||
)
|
||||
#define _bitvector_set_bit(v, bit_index) \
|
||||
((((v)->word[((bit_index) >> 5)] |= ((uint32_t)1 << ((bit_index)&31)))))
|
||||
|
||||
#define _bitvector_clear_bit(v, bit_index) \
|
||||
((((v)->word[((bit_index) >> 5)] &= ~((uint32_t)1 << ((bit_index)&31)))))
|
||||
|
||||
#define _bitvector_set_bit(v, bit_index) \
|
||||
( \
|
||||
(((v)->word[((bit_index) >> 5)] |= ((uint32_t)1 << ((bit_index) & 31)))) \
|
||||
)
|
||||
#define _bitvector_get_length(v) (((v)->length))
|
||||
|
||||
#define _bitvector_clear_bit(v, bit_index) \
|
||||
( \
|
||||
(((v)->word[((bit_index) >> 5)] &= ~((uint32_t)1 << ((bit_index) & 31)))) \
|
||||
)
|
||||
|
||||
#define _bitvector_get_length(v) \
|
||||
( \
|
||||
((v)->length) \
|
||||
)
|
||||
|
||||
#ifdef DATATYPES_USE_MACROS /* little functions are really macros */
|
||||
#ifdef DATATYPES_USE_MACROS /* little functions are really macros */
|
||||
|
||||
#define bitvector_get_bit(v, bit_index) _bitvector_get_bit(v, bit_index)
|
||||
#define bitvector_set_bit(v, bit_index) _bitvector_set_bit(v, bit_index)
|
||||
@@ -419,34 +351,25 @@ typedef struct {
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
bitvector_get_bit(const bitvector_t *v, int bit_index);
|
||||
int bitvector_get_bit(const bitvector_t *v, int bit_index);
|
||||
|
||||
void
|
||||
bitvector_set_bit(bitvector_t *v, int bit_index);
|
||||
void bitvector_set_bit(bitvector_t *v, int bit_index);
|
||||
|
||||
void
|
||||
bitvector_clear_bit(bitvector_t *v, int bit_index);
|
||||
void bitvector_clear_bit(bitvector_t *v, int bit_index);
|
||||
|
||||
unsigned long
|
||||
bitvector_get_length(const bitvector_t *v);
|
||||
unsigned long bitvector_get_length(const bitvector_t *v);
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
bitvector_alloc(bitvector_t *v, unsigned long length);
|
||||
int bitvector_alloc(bitvector_t *v, unsigned long length);
|
||||
|
||||
void
|
||||
bitvector_dealloc(bitvector_t *v);
|
||||
void bitvector_dealloc(bitvector_t *v);
|
||||
|
||||
void
|
||||
bitvector_set_to_zero(bitvector_t *x);
|
||||
void bitvector_set_to_zero(bitvector_t *x);
|
||||
|
||||
void
|
||||
bitvector_left_shift(bitvector_t *x, int index);
|
||||
void bitvector_left_shift(bitvector_t *x, int index);
|
||||
|
||||
char *
|
||||
bitvector_bit_string(bitvector_t *x, char* buf, int len);
|
||||
char *bitvector_bit_string(bitvector_t *x, char *buf, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ERR_H
|
||||
#define ERR_H
|
||||
|
||||
@@ -62,7 +61,6 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -82,9 +80,11 @@ typedef enum {
|
||||
|
||||
srtp_err_status_t srtp_err_reporting_init(void);
|
||||
|
||||
typedef void (srtp_err_report_handler_func_t)(srtp_err_reporting_level_t level, const char * msg);
|
||||
typedef void(srtp_err_report_handler_func_t)(srtp_err_reporting_level_t level,
|
||||
const char *msg);
|
||||
|
||||
srtp_err_status_t srtp_install_err_report_handler(srtp_err_report_handler_func_t func);
|
||||
srtp_err_status_t srtp_install_err_report_handler(
|
||||
srtp_err_report_handler_func_t func);
|
||||
|
||||
/*
|
||||
* srtp_err_report reports a 'printf' formatted error
|
||||
@@ -96,9 +96,7 @@ srtp_err_status_t srtp_install_err_report_handler(srtp_err_report_handler_func_t
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
srtp_err_report(srtp_err_reporting_level_t level, const char *format, ...);
|
||||
|
||||
void srtp_err_report(srtp_err_reporting_level_t level, const char *format, ...);
|
||||
|
||||
/*
|
||||
* debug_module_t defines a debug module
|
||||
@@ -111,17 +109,21 @@ typedef struct {
|
||||
|
||||
#ifdef ENABLE_DEBUG_LOGGING
|
||||
|
||||
#define debug_print(mod, format, arg) \
|
||||
#define debug_print(mod, format, arg) \
|
||||
srtp_err_report(srtp_err_level_debug, ("%s: " format "\n"), mod.name, arg)
|
||||
#define debug_print2(mod, format, arg1, arg2) \
|
||||
srtp_err_report(srtp_err_level_debug, ("%s: " format "\n"), mod.name, arg1, arg2)
|
||||
#define debug_print2(mod, format, arg1, arg2) \
|
||||
srtp_err_report(srtp_err_level_debug, ("%s: " format "\n"), mod.name, \
|
||||
arg1, arg2)
|
||||
|
||||
#else
|
||||
|
||||
#define debug_print(mod, format, arg) \
|
||||
if (mod.on) srtp_err_report(srtp_err_level_debug, ("%s: " format "\n"), mod.name, arg)
|
||||
#define debug_print2(mod, format, arg1, arg2) \
|
||||
if (mod.on) srtp_err_report(srtp_err_level_debug, ("%s: " format "\n"), mod.name, arg1, arg2)
|
||||
#define debug_print(mod, format, arg) \
|
||||
if (mod.on) \
|
||||
srtp_err_report(srtp_err_level_debug, ("%s: " format "\n"), mod.name, arg)
|
||||
#define debug_print2(mod, format, arg1, arg2) \
|
||||
if (mod.on) \
|
||||
srtp_err_report(srtp_err_level_debug, ("%s: " format "\n"), mod.name, \
|
||||
arg1, arg2)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,26 +8,26 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2001-2017, Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -43,29 +43,27 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INTEGERS_H
|
||||
#define INTEGERS_H
|
||||
|
||||
|
||||
/* use standard integer definitions, if they're available */
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_INT_TYPES_H
|
||||
# include <sys/int_types.h> /* this exists on Sun OS */
|
||||
#include <sys/int_types.h> /* this exists on Sun OS */
|
||||
#endif
|
||||
#ifdef HAVE_MACHINE_TYPES_H
|
||||
# include <machine/types.h>
|
||||
#include <machine/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -74,31 +72,30 @@ extern "C" {
|
||||
|
||||
/* Can we do 64 bit integers? */
|
||||
#if !defined(HAVE_UINT64_T)
|
||||
# if SIZEOF_UNSIGNED_LONG == 8
|
||||
typedef unsigned long uint64_t;
|
||||
# elif SIZEOF_UNSIGNED_LONG_LONG == 8
|
||||
typedef unsigned long long uint64_t;
|
||||
# else
|
||||
# define NO_64BIT_MATH 1
|
||||
# endif
|
||||
#if SIZEOF_UNSIGNED_LONG == 8
|
||||
typedef unsigned long uint64_t;
|
||||
#elif SIZEOF_UNSIGNED_LONG_LONG == 8
|
||||
typedef unsigned long long uint64_t;
|
||||
#else
|
||||
#define NO_64BIT_MATH 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Reasonable defaults for 32 bit machines - you may need to
|
||||
* edit these definitions for your own machine. */
|
||||
#ifndef HAVE_UINT8_T
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
#endif
|
||||
#ifndef HAVE_UINT16_T
|
||||
typedef unsigned short int uint16_t;
|
||||
typedef unsigned short int uint16_t;
|
||||
#endif
|
||||
#ifndef HAVE_UINT32_T
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#endif
|
||||
#ifndef HAVE_INT32_T
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(NO_64BIT_MATH) && defined(HAVE_CONFIG_H)
|
||||
typedef double uint64_t;
|
||||
/* assert that sizeof(double) == 8 */
|
||||
@@ -107,39 +104,38 @@ extern uint32_t high32(uint64_t value);
|
||||
extern uint32_t low32(uint64_t value);
|
||||
#endif
|
||||
|
||||
|
||||
/* These macros are to load and store 32-bit values from un-aligned
|
||||
addresses. This is required for processors that do not allow unaligned
|
||||
loads. */
|
||||
#ifdef ALIGNMENT_32BIT_REQUIRED
|
||||
/* Note that if it's in a variable, you can memcpy it */
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define PUT_32(addr,value) \
|
||||
{ \
|
||||
((unsigned char *) (addr))[0] = (value >> 24); \
|
||||
((unsigned char *) (addr))[1] = (value >> 16) & 0xff; \
|
||||
((unsigned char *) (addr))[2] = (value >> 8) & 0xff; \
|
||||
((unsigned char *) (addr))[3] = (value) & 0xff; \
|
||||
#define PUT_32(addr, value) \
|
||||
{ \
|
||||
((unsigned char *)(addr))[0] = (value >> 24); \
|
||||
((unsigned char *)(addr))[1] = (value >> 16) & 0xff; \
|
||||
((unsigned char *)(addr))[2] = (value >> 8) & 0xff; \
|
||||
((unsigned char *)(addr))[3] = (value)&0xff; \
|
||||
}
|
||||
#define GET_32(addr) ((((unsigned char *) (addr))[0] << 24) | \
|
||||
(((unsigned char *) (addr))[1] << 16) | \
|
||||
(((unsigned char *) (addr))[2] << 8) | \
|
||||
(((unsigned char *) (addr))[3]))
|
||||
#define GET_32(addr) \
|
||||
((((unsigned char *)(addr))[0] << 24) | \
|
||||
(((unsigned char *)(addr))[1] << 16) | \
|
||||
(((unsigned char *)(addr))[2] << 8) | (((unsigned char *)(addr))[3]))
|
||||
#else
|
||||
#define PUT_32(addr,value) \
|
||||
{ \
|
||||
((unsigned char *) (addr))[3] = (value >> 24); \
|
||||
((unsigned char *) (addr))[2] = (value >> 16) & 0xff; \
|
||||
((unsigned char *) (addr))[1] = (value >> 8) & 0xff; \
|
||||
((unsigned char *) (addr))[0] = (value) & 0xff; \
|
||||
#define PUT_32(addr, value) \
|
||||
{ \
|
||||
((unsigned char *)(addr))[3] = (value >> 24); \
|
||||
((unsigned char *)(addr))[2] = (value >> 16) & 0xff; \
|
||||
((unsigned char *)(addr))[1] = (value >> 8) & 0xff; \
|
||||
((unsigned char *)(addr))[0] = (value)&0xff; \
|
||||
}
|
||||
#define GET_32(addr) ((((unsigned char *) (addr))[3] << 24) | \
|
||||
(((unsigned char *) (addr))[2] << 16) | \
|
||||
(((unsigned char *) (addr))[1] << 8) | \
|
||||
(((unsigned char *) (addr))[0]))
|
||||
#define GET_32(addr) \
|
||||
((((unsigned char *)(addr))[3] << 24) | \
|
||||
(((unsigned char *)(addr))[2] << 16) | \
|
||||
(((unsigned char *)(addr))[1] << 8) | (((unsigned char *)(addr))[0]))
|
||||
#endif // WORDS_BIGENDIAN
|
||||
#else
|
||||
#define PUT_32(addr,value) *(((uint32_t *) (addr)) = (value)
|
||||
#define PUT_32(addr, value) *(((uint32_t *) (addr)) = (value)
|
||||
#define GET_32(addr) (*(((uint32_t *) (addr)))
|
||||
#endif
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#ifndef KEY_H
|
||||
#define KEY_H
|
||||
|
||||
#include "rdbx.h" /* for srtp_xtd_seq_num_t */
|
||||
#include "rdbx.h" /* for srtp_xtd_seq_num_t */
|
||||
#include "err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -60,9 +60,11 @@ typedef enum {
|
||||
srtp_key_event_hard_limit
|
||||
} srtp_key_event_t;
|
||||
|
||||
srtp_err_status_t srtp_key_limit_set(srtp_key_limit_t key, const srtp_xtd_seq_num_t s);
|
||||
srtp_err_status_t srtp_key_limit_set(srtp_key_limit_t key,
|
||||
const srtp_xtd_seq_num_t s);
|
||||
|
||||
srtp_err_status_t srtp_key_limit_clone(srtp_key_limit_t original, srtp_key_limit_t *new_key);
|
||||
srtp_err_status_t srtp_key_limit_clone(srtp_key_limit_t original,
|
||||
srtp_key_limit_t *new_key);
|
||||
|
||||
srtp_err_status_t srtp_key_limit_check(const srtp_key_limit_t key);
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NULL_CIPHER_H
|
||||
#define NULL_CIPHER_H
|
||||
|
||||
|
||||
@@ -7,28 +7,27 @@
|
||||
* Cisco Systems, Inc.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2001-2017, Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -47,9 +46,9 @@
|
||||
#ifndef REPLAY_DB_H
|
||||
#define REPLAY_DB_H
|
||||
|
||||
#include "integers.h" /* for uint32_t */
|
||||
#include "datatypes.h" /* for v128_t */
|
||||
#include "err.h" /* for srtp_err_status_t */
|
||||
#include "integers.h" /* for uint32_t */
|
||||
#include "datatypes.h" /* for v128_t */
|
||||
#include "err.h" /* for srtp_err_status_t */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -76,7 +75,6 @@ typedef struct {
|
||||
*/
|
||||
srtp_err_status_t srtp_rdb_init(srtp_rdb_t *rdb);
|
||||
|
||||
|
||||
/*
|
||||
* srtp_rdb_check
|
||||
*
|
||||
@@ -103,7 +101,6 @@ srtp_err_status_t srtp_rdb_add_index(srtp_rdb_t *rdb, uint32_t rdb_index);
|
||||
* srtp_rdb_t upon which srtp_rdb_add_index is used!
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* srtp_rdb_increment(db) increments the sequence number in db, if it is
|
||||
* not too high
|
||||
@@ -121,7 +118,6 @@ srtp_err_status_t srtp_rdb_increment(srtp_rdb_t *rdb);
|
||||
*/
|
||||
uint32_t srtp_rdb_get_value(const srtp_rdb_t *rdb);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,26 +9,26 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2001-2017, Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -58,10 +58,10 @@ extern "C" {
|
||||
|
||||
#ifndef ROC_TEST
|
||||
|
||||
typedef uint16_t srtp_sequence_number_t; /* 16 bit sequence number */
|
||||
typedef uint32_t srtp_rollover_counter_t; /* 32 bit rollover counter */
|
||||
typedef uint16_t srtp_sequence_number_t; /* 16 bit sequence number */
|
||||
typedef uint32_t srtp_rollover_counter_t; /* 32 bit rollover counter */
|
||||
|
||||
#else /* use small seq_num and roc datatypes for testing purposes */
|
||||
#else /* use small seq_num and roc datatypes for testing purposes */
|
||||
|
||||
typedef unsigned char srtp_sequence_number_t; /* 8 bit sequence number */
|
||||
typedef uint16_t srtp_rollover_counter_t; /* 16 bit rollover counter */
|
||||
@@ -69,7 +69,7 @@ typedef uint16_t srtp_rollover_counter_t; /* 16 bit rollover counter */
|
||||
#endif
|
||||
|
||||
#define seq_num_median (1 << (8 * sizeof(srtp_sequence_number_t) - 1))
|
||||
#define seq_num_max (1 << (8 * sizeof(srtp_sequence_number_t)))
|
||||
#define seq_num_max (1 << (8 * sizeof(srtp_sequence_number_t)))
|
||||
|
||||
/*
|
||||
* An rtp_xtd_seq_num_t is a 64-bit unsigned integer used as an 'extended'
|
||||
@@ -77,7 +77,6 @@ typedef uint16_t srtp_rollover_counter_t; /* 16 bit rollover counter */
|
||||
*/
|
||||
typedef uint64_t srtp_xtd_seq_num_t;
|
||||
|
||||
|
||||
/*
|
||||
* An srtp_rdbx_t is a replay database with extended range; it uses an
|
||||
* xtd_seq_num_t and a bitmask of recently received indices.
|
||||
@@ -87,7 +86,6 @@ typedef struct {
|
||||
bitvector_t bitmask;
|
||||
} srtp_rdbx_t;
|
||||
|
||||
|
||||
/*
|
||||
* srtp_rdbx_init(rdbx_ptr, ws)
|
||||
*
|
||||
@@ -96,7 +94,6 @@ typedef struct {
|
||||
*/
|
||||
srtp_err_status_t srtp_rdbx_init(srtp_rdbx_t *rdbx, unsigned long ws);
|
||||
|
||||
|
||||
/*
|
||||
* srtp_rdbx_dealloc(rdbx_ptr)
|
||||
*
|
||||
@@ -104,7 +101,6 @@ srtp_err_status_t srtp_rdbx_init(srtp_rdbx_t *rdbx, unsigned long ws);
|
||||
*/
|
||||
srtp_err_status_t srtp_rdbx_dealloc(srtp_rdbx_t *rdbx);
|
||||
|
||||
|
||||
/*
|
||||
* srtp_rdbx_estimate_index(rdbx, guess, s)
|
||||
*
|
||||
@@ -113,7 +109,9 @@ srtp_err_status_t srtp_rdbx_dealloc(srtp_rdbx_t *rdbx);
|
||||
* index to which s corresponds, and returns the difference between
|
||||
* *guess and the locally stored synch info
|
||||
*/
|
||||
int32_t srtp_rdbx_estimate_index(const srtp_rdbx_t *rdbx, srtp_xtd_seq_num_t *guess, srtp_sequence_number_t s);
|
||||
int32_t srtp_rdbx_estimate_index(const srtp_rdbx_t *rdbx,
|
||||
srtp_xtd_seq_num_t *guess,
|
||||
srtp_sequence_number_t s);
|
||||
|
||||
/*
|
||||
* srtp_rdbx_check(rdbx, delta);
|
||||
@@ -136,7 +134,6 @@ srtp_err_status_t srtp_rdbx_check(const srtp_rdbx_t *rdbx, int difference);
|
||||
*/
|
||||
srtp_err_status_t srtp_rdbx_add_index(srtp_rdbx_t *rdbx, int delta);
|
||||
|
||||
|
||||
/*
|
||||
* srtp_rdbx_set_roc(rdbx, roc) initalizes the srtp_rdbx_t at the location rdbx
|
||||
* to have the rollover counter value roc. If that value is less than
|
||||
@@ -147,7 +144,8 @@ srtp_err_status_t srtp_rdbx_add_index(srtp_rdbx_t *rdbx, int delta);
|
||||
srtp_err_status_t srtp_rdbx_set_roc(srtp_rdbx_t *rdbx, uint32_t roc);
|
||||
|
||||
/*
|
||||
* srtp_rdbx_get_packet_index(rdbx) returns the value of the rollover counter for
|
||||
* srtp_rdbx_get_packet_index(rdbx) returns the value of the rollover counter
|
||||
* for
|
||||
* the srtp_rdbx_t pointed to by rdbx
|
||||
*
|
||||
*/
|
||||
@@ -166,14 +164,12 @@ srtp_xtd_seq_num_t srtp_rdbx_get_packet_index(const srtp_rdbx_t *rdbx);
|
||||
*/
|
||||
unsigned long srtp_rdbx_get_window_size(const srtp_rdbx_t *rdbx);
|
||||
|
||||
|
||||
/* index_init(&pi) initializes a packet index pi (sets it to zero) */
|
||||
void srtp_index_init(srtp_xtd_seq_num_t *pi);
|
||||
|
||||
/* index_advance(&pi, s) advances a xtd_seq_num_t forward by s */
|
||||
void srtp_index_advance(srtp_xtd_seq_num_t *pi, srtp_sequence_number_t s);
|
||||
|
||||
|
||||
/*
|
||||
* srtp_index_guess(local, guess, s)
|
||||
*
|
||||
@@ -183,7 +179,9 @@ void srtp_index_advance(srtp_xtd_seq_num_t *pi, srtp_sequence_number_t s);
|
||||
* guess of the packet index to which s corresponds, and returns the
|
||||
* difference between *guess and *local
|
||||
*/
|
||||
int32_t srtp_index_guess(const srtp_xtd_seq_num_t *local, srtp_xtd_seq_num_t *guess, srtp_sequence_number_t s);
|
||||
int32_t srtp_index_guess(const srtp_xtd_seq_num_t *local,
|
||||
srtp_xtd_seq_num_t *guess,
|
||||
srtp_sequence_number_t s);
|
||||
|
||||
/*
|
||||
* srtp_rdbx_get_roc(rdbx)
|
||||
@@ -200,9 +198,9 @@ uint32_t srtp_rdbx_get_roc(const srtp_rdbx_t *rdbx);
|
||||
* rollover counter value, then the function returns
|
||||
* srtp_err_status_replay_old, otherwise, srtp_err_status_ok is returned.
|
||||
*/
|
||||
srtp_err_status_t srtp_rdbx_set_roc_seq (srtp_rdbx_t *rdbx,
|
||||
uint32_t roc,
|
||||
uint16_t seq);
|
||||
srtp_err_status_t srtp_rdbx_set_roc_seq(srtp_rdbx_t *rdbx,
|
||||
uint32_t roc,
|
||||
uint16_t seq);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#define SHA1_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "err.h"
|
||||
@@ -81,49 +81,53 @@ extern "C" {
|
||||
|
||||
/* OpenSSL 1.1.0 made EVP_MD_CTX an opaque structure, which must be allocated
|
||||
using EVP_MD_CTX_new. But this function doesn't exist in OpenSSL 1.0.x. */
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER
|
||||
|
||||
typedef EVP_MD_CTX srtp_sha1_ctx_t;
|
||||
|
||||
static inline void srtp_sha1_init (srtp_sha1_ctx_t *ctx)
|
||||
static inline void srtp_sha1_init(srtp_sha1_ctx_t *ctx)
|
||||
{
|
||||
EVP_MD_CTX_init(ctx);
|
||||
EVP_DigestInit(ctx, EVP_sha1());
|
||||
}
|
||||
|
||||
static inline void srtp_sha1_update (srtp_sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg)
|
||||
static inline void srtp_sha1_update(srtp_sha1_ctx_t *ctx,
|
||||
const uint8_t *M,
|
||||
int octets_in_msg)
|
||||
{
|
||||
EVP_DigestUpdate(ctx, M, octets_in_msg);
|
||||
}
|
||||
|
||||
static inline void srtp_sha1_final (srtp_sha1_ctx_t *ctx, uint32_t *output)
|
||||
static inline void srtp_sha1_final(srtp_sha1_ctx_t *ctx, uint32_t *output)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
|
||||
EVP_DigestFinal(ctx, (unsigned char*)output, &len);
|
||||
EVP_DigestFinal(ctx, (unsigned char *)output, &len);
|
||||
EVP_MD_CTX_cleanup(ctx);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
typedef EVP_MD_CTX* srtp_sha1_ctx_t;
|
||||
typedef EVP_MD_CTX *srtp_sha1_ctx_t;
|
||||
|
||||
static inline void srtp_sha1_init (srtp_sha1_ctx_t *ctx)
|
||||
static inline void srtp_sha1_init(srtp_sha1_ctx_t *ctx)
|
||||
{
|
||||
*ctx = EVP_MD_CTX_new();
|
||||
EVP_DigestInit(*ctx, EVP_sha1());
|
||||
}
|
||||
|
||||
static inline void srtp_sha1_update (srtp_sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg)
|
||||
static inline void srtp_sha1_update(srtp_sha1_ctx_t *ctx,
|
||||
const uint8_t *M,
|
||||
int octets_in_msg)
|
||||
{
|
||||
EVP_DigestUpdate(*ctx, M, octets_in_msg);
|
||||
}
|
||||
|
||||
static inline void srtp_sha1_final (srtp_sha1_ctx_t *ctx, uint32_t *output)
|
||||
static inline void srtp_sha1_final(srtp_sha1_ctx_t *ctx, uint32_t *output)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
|
||||
EVP_DigestFinal(*ctx, (unsigned char*)output, &len);
|
||||
EVP_DigestFinal(*ctx, (unsigned char *)output, &len);
|
||||
EVP_MD_CTX_free(*ctx);
|
||||
}
|
||||
#endif
|
||||
@@ -137,7 +141,6 @@ typedef struct {
|
||||
uint32_t num_bits_in_msg; /* total number of bits in message */
|
||||
} srtp_sha1_ctx_t;
|
||||
|
||||
|
||||
/*
|
||||
* srtp_sha1_init(&ctx) initializes the SHA1 context ctx
|
||||
*
|
||||
@@ -150,9 +153,11 @@ typedef struct {
|
||||
*/
|
||||
void srtp_sha1_init(srtp_sha1_ctx_t *ctx);
|
||||
|
||||
void srtp_sha1_update(srtp_sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg);
|
||||
void srtp_sha1_update(srtp_sha1_ctx_t *ctx,
|
||||
const uint8_t *M,
|
||||
int octets_in_msg);
|
||||
|
||||
void srtp_sha1_final(srtp_sha1_ctx_t * ctx, uint32_t output[5]);
|
||||
void srtp_sha1_final(srtp_sha1_ctx_t *ctx, uint32_t output[5]);
|
||||
|
||||
/*
|
||||
* The srtp_sha1_core function is INTERNAL to SHA-1, but it is declared
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* stats.h
|
||||
*
|
||||
*
|
||||
* interface to statistical test functions
|
||||
*
|
||||
* David A. McGrew
|
||||
@@ -8,26 +8,26 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright(c) 2001-2017, Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -43,12 +43,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef STAT_H
|
||||
#define STAT_H
|
||||
|
||||
#include "datatypes.h" /* for uint8_t */
|
||||
#include "err.h" /* for srtp_err_status_t */
|
||||
#include "datatypes.h" /* for uint8_t */
|
||||
#include "err.h" /* for srtp_err_status_t */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
Reference in new issue
Block a user