Browse Source

MT#56126 New function: crypto_params_sdes_cmp()

A new function dedicated to SDES crypto suites comparison.
It compares the crypto suites using a name in 'str' format.

Recommended to be used in combination with:
g_queue_find_custom() or g_list_find_custom()

Change-Id: I08ff6d3304f74d29154110caa472618478ca1837
pull/1621/head
Donat Zenichev 3 years ago
parent
commit
bffd5c9354
2 changed files with 13 additions and 5 deletions
  1. +1
    -3
      daemon/crypto.c
  2. +12
    -2
      include/crypto.h

+ 1
- 3
daemon/crypto.c View File

@ -336,7 +336,7 @@ const unsigned int num_crypto_suites = G_N_ELEMENTS(__crypto_suites);
const struct crypto_suite *crypto_find_suite(const str *s) {
const struct crypto_suite * crypto_find_suite(const str *s) {
int i, l;
const struct crypto_suite *cs;
@ -358,8 +358,6 @@ const struct crypto_suite *crypto_find_suite(const str *s) {
return NULL;
}
/* rfc 3711 section 4.1 and 4.1.1
* "in" and "out" MAY point to the same buffer */
static void aes_ctr(unsigned char *out, str *in, EVP_CIPHER_CTX *ecc, const unsigned char *iv) {


+ 12
- 2
include/crypto.h View File

@ -9,7 +9,6 @@
#include "str.h"
#include "aux.h"
#define SRTP_MAX_MASTER_KEY_LEN 32
#define SRTP_MAX_MASTER_SALT_LEN 14
#define SRTP_MAX_SESSION_KEY_LEN 32
@ -107,11 +106,22 @@ extern __thread GString *crypto_debug_string;
void crypto_init_main(void);
const struct crypto_suite *crypto_find_suite(const str *);
const struct crypto_suite * crypto_find_suite(const str *);
int crypto_gen_session_key(struct crypto_context *, str *, unsigned char, int);
void crypto_dump_keys(struct crypto_context *in, struct crypto_context *out);
char *crypto_params_sdes_dump(const struct crypto_params_sdes *, char **);
/**
* A function which compares two crypto suite names in str format.
* Recommended to be used in combination with:
* g_queue_find_custom() or g_list_find_custom()
*/
INLINE int crypto_params_sdes_cmp(gconstpointer a, gconstpointer b)
{
const struct crypto_params_sdes * cs = a;
return str_cmp_str(&cs->params.crypto_suite->name_str, (str *) b);
}
INLINE int crypto_encrypt_rtp(struct crypto_context *c, struct rtp_header *rtp,


Loading…
Cancel
Save