Commit f1efbf5b authored by Pascal Bühler's avatar Pascal Bühler

clang-format remaining files

These are the remain files that require format changes as detected
by the format.sh.
parent 11fdc671
......@@ -125,17 +125,17 @@ static srtp_err_status_t srtp_null_cipher_encrypt(void *cv,
static const char srtp_null_cipher_description[] = "null cipher";
static const srtp_cipher_test_case_t srtp_null_cipher_test_0 = {
0, /* octets in key */
NULL, /* key */
0, /* packet index */
0, /* octets in plaintext */
NULL, /* plaintext */
0, /* octets in plaintext */
NULL, /* ciphertext */
0, /* */
NULL, /* */
0, /* */
NULL /* pointer to next testcase */
0, /* octets in key */
NULL, /* key */
0, /* packet index */
0, /* octets in plaintext */
NULL, /* plaintext */
0, /* octets in plaintext */
NULL, /* ciphertext */
0, /* */
NULL, /* */
0, /* */
NULL /* pointer to next testcase */
};
/*
......
This diff is collapsed.
......@@ -525,8 +525,8 @@ srtp_err_status_t srtp_stream_clone(const srtp_stream_ctx_t *stream_template,
*str_ptr = NULL;
return srtp_err_status_alloc_fail;
}
memset(str->session_keys, 0x0, sizeof(srtp_session_keys_t) *
str->num_master_keys);
memset(str->session_keys, 0x0,
sizeof(srtp_session_keys_t) * str->num_master_keys);
for (i = 0; i < stream_template->num_master_keys; i++) {
session_keys = &str->session_keys[i];
......@@ -649,8 +649,10 @@ typedef struct {
const EVP_CIPHER *evp;
} srtp_kdf_t;
static srtp_err_status_t
srtp_kdf_init(srtp_kdf_t *kdf, const uint8_t *key, int key_len, int salt_len)
static srtp_err_status_t srtp_kdf_init(srtp_kdf_t *kdf,
const uint8_t *key,
int key_len,
int salt_len)
{
memset(kdf, 0x0, sizeof(srtp_kdf_t));
......@@ -725,8 +727,9 @@ typedef struct {
srtp_cipher_t *cipher; /* cipher used for key derivation */
} srtp_kdf_t;
static srtp_err_status_t
srtp_kdf_init(srtp_kdf_t *kdf, const uint8_t *key, int key_len)
static srtp_err_status_t srtp_kdf_init(srtp_kdf_t *kdf,
const uint8_t *key,
int key_len)
{
srtp_cipher_type_id_t cipher_id;
switch (key_len) {
......@@ -846,10 +849,10 @@ unsigned int srtp_validate_policy_master_keys(const srtp_policy_t *policy)
return 1;
}
srtp_session_keys_t *
srtp_get_session_keys_with_mki_index(srtp_stream_ctx_t *stream,
unsigned int use_mki,
unsigned int mki_index)
srtp_session_keys_t *srtp_get_session_keys_with_mki_index(
srtp_stream_ctx_t *stream,
unsigned int use_mki,
unsigned int mki_index)
{
if (use_mki) {
if (mki_index < stream->num_master_keys) {
......@@ -878,11 +881,11 @@ unsigned int srtp_inject_mki(uint8_t *mki_tag_location,
return mki_size;
}
srtp_err_status_t
srtp_stream_init_all_master_keys(srtp_stream_ctx_t *srtp,
unsigned char *key,
srtp_master_key_t **keys,
const unsigned int max_master_keys)
srtp_err_status_t srtp_stream_init_all_master_keys(
srtp_stream_ctx_t *srtp,
unsigned char *key,
srtp_master_key_t **keys,
const unsigned int max_master_keys)
{
int i = 0;
srtp_err_status_t status = srtp_err_status_ok;
......@@ -1425,10 +1428,10 @@ static int srtp_protect_extension_header(srtp_stream_ctx_t *stream, int id)
/*
* extensions header encryption RFC 6904
*/
static srtp_err_status_t
srtp_process_header_encryption(srtp_stream_ctx_t *stream,
srtp_hdr_xtnd_t *xtn_hdr,
srtp_session_keys_t *session_keys)
static srtp_err_status_t srtp_process_header_encryption(
srtp_stream_ctx_t *stream,
srtp_hdr_xtnd_t *xtn_hdr,
srtp_session_keys_t *session_keys)
{
srtp_err_status_t status;
uint8_t keystream[257]; /* Maximum 2 bytes header + 255 bytes data. */
......@@ -2082,8 +2085,9 @@ static srtp_err_status_t srtp_unprotect_aead(srtp_ctx_t *ctx,
return srtp_err_status_ok;
}
srtp_err_status_t
srtp_protect(srtp_ctx_t *ctx, void *rtp_hdr, int *pkt_octet_len)
srtp_err_status_t srtp_protect(srtp_ctx_t *ctx,
void *rtp_hdr,
int *pkt_octet_len)
{
return srtp_protect_mki(ctx, rtp_hdr, pkt_octet_len, 0, 0);
}
......@@ -2407,8 +2411,9 @@ srtp_err_status_t srtp_protect_mki(srtp_ctx_t *ctx,
return srtp_err_status_ok;
}
srtp_err_status_t
srtp_unprotect(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len)
srtp_err_status_t srtp_unprotect(srtp_ctx_t *ctx,
void *srtp_hdr,
int *pkt_octet_len)
{
return srtp_unprotect_mki(ctx, srtp_hdr, pkt_octet_len, 0);
}
......@@ -3489,11 +3494,11 @@ void srtp_crypto_policy_set_aes_gcm_256_16_auth(srtp_crypto_policy_t *p)
* if seq_num is invalid
*
*/
static srtp_err_status_t
srtp_calc_aead_iv_srtcp(srtp_session_keys_t *session_keys,
v128_t *iv,
uint32_t seq_num,
srtcp_hdr_t *hdr)
static srtp_err_status_t srtp_calc_aead_iv_srtcp(
srtp_session_keys_t *session_keys,
v128_t *iv,
uint32_t seq_num,
srtcp_hdr_t *hdr)
{
v128_t in;
v128_t salt;
......@@ -3534,13 +3539,13 @@ srtp_calc_aead_iv_srtcp(srtp_session_keys_t *session_keys,
* This code handles AEAD ciphers for outgoing RTCP. We currently support
* AES-GCM mode with 128 or 256 bit keys.
*/
static srtp_err_status_t
srtp_protect_rtcp_aead(srtp_t ctx,
srtp_stream_ctx_t *stream,
void *rtcp_hdr,
unsigned int *pkt_octet_len,
srtp_session_keys_t *session_keys,
unsigned int use_mki)
static srtp_err_status_t srtp_protect_rtcp_aead(
srtp_t ctx,
srtp_stream_ctx_t *stream,
void *rtcp_hdr,
unsigned int *pkt_octet_len,
srtp_session_keys_t *session_keys,
unsigned int use_mki)
{
srtcp_hdr_t *hdr = (srtcp_hdr_t *)rtcp_hdr;
uint32_t *enc_start; /* pointer to start of encrypted portion */
......@@ -3705,13 +3710,13 @@ srtp_protect_rtcp_aead(srtp_t ctx,
* at the end of the packet stream and is automatically checked by GCM
* when decrypting the payload.
*/
static srtp_err_status_t
srtp_unprotect_rtcp_aead(srtp_t ctx,
srtp_stream_ctx_t *stream,
void *srtcp_hdr,
unsigned int *pkt_octet_len,
srtp_session_keys_t *session_keys,
unsigned int use_mki)
static srtp_err_status_t srtp_unprotect_rtcp_aead(
srtp_t ctx,
srtp_stream_ctx_t *stream,
void *srtcp_hdr,
unsigned int *pkt_octet_len,
srtp_session_keys_t *session_keys,
unsigned int use_mki)
{
srtcp_hdr_t *hdr = (srtcp_hdr_t *)srtcp_hdr;
uint32_t *enc_start; /* pointer to start of encrypted portion */
......@@ -3898,8 +3903,9 @@ srtp_unprotect_rtcp_aead(srtp_t ctx,
return srtp_err_status_ok;
}
srtp_err_status_t
srtp_protect_rtcp(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len)
srtp_err_status_t srtp_protect_rtcp(srtp_t ctx,
void *rtcp_hdr,
int *pkt_octet_len)
{
return srtp_protect_rtcp_mki(ctx, rtcp_hdr, pkt_octet_len, 0, 0);
}
......@@ -4126,8 +4132,9 @@ srtp_err_status_t srtp_protect_rtcp_mki(srtp_t ctx,
return srtp_err_status_ok;
}
srtp_err_status_t
srtp_unprotect_rtcp(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len)
srtp_err_status_t srtp_unprotect_rtcp(srtp_t ctx,
void *srtcp_hdr,
int *pkt_octet_len)
{
return srtp_unprotect_rtcp_mki(ctx, srtcp_hdr, pkt_octet_len, 0);
}
......@@ -4461,9 +4468,9 @@ void *srtp_get_user_data(srtp_t ctx)
* dtls keying for srtp
*/
srtp_err_status_t
srtp_crypto_policy_set_from_profile_for_rtp(srtp_crypto_policy_t *policy,
srtp_profile_t profile)
srtp_err_status_t srtp_crypto_policy_set_from_profile_for_rtp(
srtp_crypto_policy_t *policy,
srtp_profile_t profile)
{
/* set SRTP policy from the SRTP profile in the key set */
switch (profile) {
......@@ -4493,9 +4500,9 @@ srtp_crypto_policy_set_from_profile_for_rtp(srtp_crypto_policy_t *policy,
return srtp_err_status_ok;
}
srtp_err_status_t
srtp_crypto_policy_set_from_profile_for_rtcp(srtp_crypto_policy_t *policy,
srtp_profile_t profile)
srtp_err_status_t srtp_crypto_policy_set_from_profile_for_rtcp(
srtp_crypto_policy_t *policy,
srtp_profile_t profile)
{
/* set SRTP policy from the SRTP profile in the key set */
switch (profile) {
......@@ -4728,8 +4735,9 @@ srtp_err_status_t srtp_install_log_handler(srtp_log_handler_func_t func,
return srtp_err_status_ok;
}
srtp_err_status_t
srtp_set_stream_roc(srtp_t session, uint32_t ssrc, uint32_t roc)
srtp_err_status_t srtp_set_stream_roc(srtp_t session,
uint32_t ssrc,
uint32_t roc)
{
srtp_stream_t stream;
......@@ -4742,8 +4750,9 @@ srtp_set_stream_roc(srtp_t session, uint32_t ssrc, uint32_t roc)
return srtp_err_status_ok;
}
srtp_err_status_t
srtp_get_stream_roc(srtp_t session, uint32_t ssrc, uint32_t *roc)
srtp_err_status_t srtp_get_stream_roc(srtp_t session,
uint32_t ssrc,
uint32_t *roc)
{
srtp_stream_t stream;
......
This diff is collapsed.
......@@ -3,30 +3,30 @@
*
* a minimal implementation of the getopt() function, written so that
* test applications that use that function can run on non-POSIX
* platforms
* platforms
*
*/
/*
*
*
* 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,71 +42,67 @@
*
*/
#include <stdlib.h> /* for NULL */
#include <stdlib.h> /* for NULL */
int optind_s = 0;
char *optarg_s;
#define GETOPT_FOUND_WITHOUT_ARGUMENT 2
#define GETOPT_FOUND_WITH_ARGUMENT 1
#define GETOPT_NOT_FOUND 0
#define GETOPT_FOUND_WITHOUT_ARGUMENT 2
#define GETOPT_FOUND_WITH_ARGUMENT 1
#define GETOPT_NOT_FOUND 0
static int
getopt_check_character(char c, const char *string) {
unsigned int max_string_len = 128;
static int getopt_check_character(char c, const char *string)
{
unsigned int max_string_len = 128;
while (*string != 0) {
if (max_string_len == 0) {
return '?';
while (*string != 0) {
if (max_string_len == 0) {
return '?';
}
if (*string++ == c) {
if (*string == ':') {
return GETOPT_FOUND_WITH_ARGUMENT;
} else {
return GETOPT_FOUND_WITHOUT_ARGUMENT;
}
}
}
if (*string++ == c) {
if (*string == ':') {
return GETOPT_FOUND_WITH_ARGUMENT;
} else {
return GETOPT_FOUND_WITHOUT_ARGUMENT;
}
}
}
return GETOPT_NOT_FOUND;
return GETOPT_NOT_FOUND;
}
int
getopt_s(int argc,
char * const argv[],
const char *optstring) {
int getopt_s(int argc, char *const argv[], const char *optstring)
{
while (optind_s + 1 < argc) {
char *string;
while (optind_s + 1 < argc) {
char *string;
/* move 'string' on to next argument */
optind_s++;
string = argv[optind_s];
/* move 'string' on to next argument */
optind_s++;
string = argv[optind_s];
if (string == NULL)
return '?'; /* NULL argument string */
if (string == NULL)
return '?'; /* NULL argument string */
if (string[0] != '-')
return -1; /* found an unexpected character */
if (string[0] != '-')
return -1; /* found an unexpected character */
switch(getopt_check_character(string[1], optstring)) {
case GETOPT_FOUND_WITH_ARGUMENT:
if (optind_s + 1 < argc) {
optind_s++;
optarg_s = argv[optind_s];
return string[1];
} else {
return '?'; /* argument missing */
}
case GETOPT_FOUND_WITHOUT_ARGUMENT:
return string[1];
case GETOPT_NOT_FOUND:
default:
return '?'; /* didn't find expected character */
break;
switch (getopt_check_character(string[1], optstring)) {
case GETOPT_FOUND_WITH_ARGUMENT:
if (optind_s + 1 < argc) {
optind_s++;
optarg_s = argv[optind_s];
return string[1];
} else {
return '?'; /* argument missing */
}
case GETOPT_FOUND_WITHOUT_ARGUMENT:
return string[1];
case GETOPT_NOT_FOUND:
default:
return '?'; /* didn't find expected character */
break;
}
}
}
return -1;
return -1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment