亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? srtp.c

?? mediastreamer2是開源的網絡傳輸媒體流的庫
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* * srtp.c * * the secure real-time transport protocol * * David A. McGrew * Cisco Systems, Inc. *//* *	 * Copyright (c) 2001-2006, 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. * */#include "srtp_priv.h"#include "aes_icm.h"         /* aes_icm is used in the KDF  */#include "alloc.h"           /* for crypto_alloc()          */#ifndef SRTP_KERNEL# include <limits.h># ifdef HAVE_NETINET_IN_H#  include <netinet/in.h># elif defined(HAVE_WINSOCK2_H)#  include <winsock2.h># endif#endif /* ! SRTP_KERNEL */extern cipher_type_t aes_icm;extern auth_type_t   tmmhv2;/* the debug module for srtp */debug_module_t mod_srtp = {  0,                  /* debugging is off by default */  "srtp"              /* printable name for module   */};#define octets_in_rtp_header   12#define uint32s_in_rtp_header  3#define octets_in_rtcp_header  8#define uint32s_in_rtcp_header 2err_status_tsrtp_stream_alloc(srtp_stream_ctx_t **str_ptr,		  const srtp_policy_t *p) {  srtp_stream_ctx_t *str;  err_status_t stat;  /*   * This function allocates the stream context, rtp and rtcp ciphers   * and auth functions, and key limit structure.  If there is a   * failure during allocation, we free all previously allocated   * memory and return a failure code.  The code could probably    * be improved, but it works and should be clear.   */  /* allocate srtp stream and set str_ptr */  str = (srtp_stream_ctx_t *) crypto_alloc(sizeof(srtp_stream_ctx_t));  if (str == NULL)    return err_status_alloc_fail;  *str_ptr = str;      /* allocate cipher */  stat = crypto_kernel_alloc_cipher(p->rtp.cipher_type, 				    &str->rtp_cipher, 				    p->rtp.cipher_key_len);   if (stat) {    crypto_free(str);    return stat;  }  /* allocate auth function */  stat = crypto_kernel_alloc_auth(p->rtp.auth_type, 				  &str->rtp_auth,				  p->rtp.auth_key_len, 				  p->rtp.auth_tag_len);   if (stat) {    cipher_dealloc(str->rtp_cipher);    crypto_free(str);    return stat;  }    /* allocate key limit structure */  str->limit = (key_limit_ctx_t*) crypto_alloc(sizeof(key_limit_ctx_t));  if (str->limit == NULL) {    auth_dealloc(str->rtp_auth);    cipher_dealloc(str->rtp_cipher);    crypto_free(str);     return err_status_alloc_fail;  }  /*   * ...and now the RTCP-specific initialization - first, allocate   * the cipher    */  stat = crypto_kernel_alloc_cipher(p->rtcp.cipher_type, 				    &str->rtcp_cipher, 				    p->rtcp.cipher_key_len);   if (stat) {    auth_dealloc(str->rtp_auth);    cipher_dealloc(str->rtp_cipher);    crypto_free(str->limit);    crypto_free(str);    return stat;  }  /* allocate auth function */  stat = crypto_kernel_alloc_auth(p->rtcp.auth_type, 				  &str->rtcp_auth,				  p->rtcp.auth_key_len, 				  p->rtcp.auth_tag_len);   if (stat) {    cipher_dealloc(str->rtcp_cipher);    auth_dealloc(str->rtp_auth);    cipher_dealloc(str->rtp_cipher);    crypto_free(str->limit);    crypto_free(str);   return stat;  }    return err_status_ok;}err_status_tsrtp_stream_dealloc(srtp_t session, srtp_stream_ctx_t *stream) {   err_status_t status;    /*   * we use a conservative deallocation strategy - if any deallocation   * fails, then we report that fact without trying to deallocate   * anything else   */  /* deallocate cipher, if it is not the same as that in template */  if (session->stream_template      && stream->rtp_cipher == session->stream_template->rtp_cipher) {    /* do nothing */  } else {    status = cipher_dealloc(stream->rtp_cipher);     if (status)       return status;  }  /* deallocate auth function, if it is not the same as that in template */  if (session->stream_template      && stream->rtp_auth == session->stream_template->rtp_auth) {    /* do nothing */  } else {    status = auth_dealloc(stream->rtp_auth);    if (status)      return status;  }  /* deallocate key usage limit, if it is not the same as that in template */  if (session->stream_template      && stream->limit == session->stream_template->limit) {    /* do nothing */  } else {    crypto_free(stream->limit);  }     /*    * deallocate rtcp cipher, if it is not the same as that in   * template    */  if (session->stream_template      && stream->rtcp_cipher == session->stream_template->rtcp_cipher) {    /* do nothing */  } else {    status = cipher_dealloc(stream->rtcp_cipher);     if (status)       return status;  }  /*   * deallocate rtcp auth function, if it is not the same as that in   * template    */  if (session->stream_template      && stream->rtcp_auth == session->stream_template->rtcp_auth) {    /* do nothing */  } else {    status = auth_dealloc(stream->rtcp_auth);    if (status)      return status;  }    /* deallocate srtp stream context */  crypto_free(stream);  return err_status_ok;}/* * srtp_stream_clone(stream_template, new) allocates a new stream and * initializes it using the cipher and auth of the stream_template *  * the only unique data in a cloned stream is the replay database and * the SSRC */err_status_tsrtp_stream_clone(const srtp_stream_ctx_t *stream_template, 		  uint32_t ssrc, 		  srtp_stream_ctx_t **str_ptr) {  err_status_t status;  srtp_stream_ctx_t *str;  debug_print(mod_srtp, "cloning stream (SSRC: 0x%08x)", ssrc);  /* allocate srtp stream and set str_ptr */  str = (srtp_stream_ctx_t *) crypto_alloc(sizeof(srtp_stream_ctx_t));  if (str == NULL)    return err_status_alloc_fail;  *str_ptr = str;    /* set cipher and auth pointers to those of the template */  str->rtp_cipher  = stream_template->rtp_cipher;  str->rtp_auth    = stream_template->rtp_auth;  str->rtcp_cipher = stream_template->rtcp_cipher;  str->rtcp_auth   = stream_template->rtcp_auth;  /* set key limit to point to that of the template */  status = key_limit_clone(stream_template->limit, &str->limit);  if (status)     return status;  /* initialize replay databases */  rdbx_init(&str->rtp_rdbx);  rdb_init(&str->rtcp_rdb);    /* set ssrc to that provided */  str->ssrc = ssrc;  /* set direction and security services */  str->direction     = stream_template->direction;  str->rtp_services  = stream_template->rtp_services;  str->rtcp_services = stream_template->rtcp_services;  /* defensive coding */  str->next = NULL;  return err_status_ok;}/* * key derivation functions, internal to libSRTP * * srtp_kdf_t is a key derivation context * * srtp_kdf_init(&kdf, k) initializes kdf with the key k *  * srtp_kdf_generate(&kdf, l, kl, keylen) derives the key * corresponding to label l and puts it into kl; the length * of the key in octets is provided as keylen.  this function * should be called once for each subkey that is derived. * * srtp_kdf_clear(&kdf) zeroizes the kdf state */typedef enum {  label_rtp_encryption  = 0x00,  label_rtp_msg_auth    = 0x01,  label_rtp_salt        = 0x02,  label_rtcp_encryption = 0x03,  label_rtcp_msg_auth   = 0x04,  label_rtcp_salt       = 0x05} srtp_prf_label;/* * srtp_kdf_t represents a key derivation function.  The SRTP * default KDF is the only one implemented at present. */typedef struct {   aes_icm_ctx_t c;    /* cipher used for key derivation  */  } srtp_kdf_t;err_status_tsrtp_kdf_init(srtp_kdf_t *kdf, const uint8_t key[30]) {  aes_icm_context_init(&kdf->c, key);  return err_status_ok;}err_status_tsrtp_kdf_generate(srtp_kdf_t *kdf, srtp_prf_label label,		  uint8_t *key, int length) {  v128_t nonce;    /* set eigth octet of nonce to <label>, set the rest of it to zero */  v128_set_to_zero(&nonce);  nonce.v8[7] = label;   aes_icm_set_iv(&kdf->c, &nonce);      /* generate keystream output */  aes_icm_output(&kdf->c, key, length);  return err_status_ok;}err_status_tsrtp_kdf_clear(srtp_kdf_t *kdf) {    /* zeroize aes context */  octet_string_set_to_zero((uint8_t *)kdf, sizeof(srtp_kdf_t));  return err_status_ok;  }/* *  end of key derivation functions  */#define MAX_SRTP_KEY_LEN 256err_status_tsrtp_stream_init_keys(srtp_stream_ctx_t *srtp, const void *key) {  err_status_t stat;  srtp_kdf_t kdf;  uint8_t tmp_key[MAX_SRTP_KEY_LEN];    /* initialize KDF state     */  srtp_kdf_init(&kdf, (const uint8_t *)key);    /* generate encryption key  */  srtp_kdf_generate(&kdf, label_rtp_encryption, 		    tmp_key, cipher_get_key_length(srtp->rtp_cipher));  /*    * if the cipher in the srtp context is aes_icm, then we need   * to generate the salt value   */  if (srtp->rtp_cipher->type == &aes_icm) {    /* FIX!!! this is really the cipher key length; rest is salt */    int base_key_len = 16;    int salt_len = cipher_get_key_length(srtp->rtp_cipher) - base_key_len;        debug_print(mod_srtp, "found aes_icm, generating salt", NULL);    /* generate encryption salt, put after encryption key */    srtp_kdf_generate(&kdf, label_rtp_salt, 		      tmp_key + base_key_len, salt_len);  }  debug_print(mod_srtp, "cipher key: %s", 	      octet_string_hex_string(tmp_key, 		      cipher_get_key_length(srtp->rtp_cipher)));    /* initialize cipher */  stat = cipher_init(srtp->rtp_cipher, tmp_key, direction_any);  if (stat) {    /* zeroize temp buffer */    octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN);    return err_status_init_fail;  }  /* generate authentication key */  srtp_kdf_generate(&kdf, label_rtp_msg_auth,		    tmp_key, auth_get_key_length(srtp->rtp_auth));  debug_print(mod_srtp, "auth key:   %s",	      octet_string_hex_string(tmp_key, 				      auth_get_key_length(srtp->rtp_auth)));   /* initialize auth function */  stat = auth_init(srtp->rtp_auth, tmp_key);  if (stat) {    /* zeroize temp buffer */    octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN);    return err_status_init_fail;  }  /*   * ...now initialize SRTCP keys   */  /* generate encryption key  */  srtp_kdf_generate(&kdf, label_rtcp_encryption, 		    tmp_key, cipher_get_key_length(srtp->rtcp_cipher));  /*    * if the cipher in the srtp context is aes_icm, then we need   * to generate the salt value   */  if (srtp->rtcp_cipher->type == &aes_icm) {    /* FIX!!! this is really the cipher key length; rest is salt */    int base_key_len = 16;    int salt_len = cipher_get_key_length(srtp->rtcp_cipher) - base_key_len;    debug_print(mod_srtp, "found aes_icm, generating rtcp salt", NULL);    /* generate encryption salt, put after encryption key */    srtp_kdf_generate(&kdf, label_rtcp_salt, 		      tmp_key + base_key_len, salt_len);  }  debug_print(mod_srtp, "rtcp cipher key: %s", 	      octet_string_hex_string(tmp_key, 		   cipher_get_key_length(srtp->rtcp_cipher)));    /* initialize cipher */  stat = cipher_init(srtp->rtcp_cipher, tmp_key, direction_any);  if (stat) {    /* zeroize temp buffer */    octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN);    return err_status_init_fail;  }  /* generate authentication key */  srtp_kdf_generate(&kdf, label_rtcp_msg_auth,		    tmp_key, auth_get_key_length(srtp->rtcp_auth));  debug_print(mod_srtp, "rtcp auth key:   %s",	      octet_string_hex_string(tmp_key, 		     auth_get_key_length(srtp->rtcp_auth)));   /* initialize auth function */  stat = auth_init(srtp->rtcp_auth, tmp_key);  if (stat) {    /* zeroize temp buffer */    octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN);    return err_status_init_fail;  }  /* clear memory then return */  srtp_kdf_clear(&kdf);  octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN);    return err_status_ok;}err_status_tsrtp_stream_init(srtp_stream_ctx_t *srtp, 		  const srtp_policy_t *p) {  err_status_t err;   debug_print(mod_srtp, "initializing stream (SSRC: 0x%08x)", 	       p->ssrc.value);   /* initialize replay database */   rdbx_init(&srtp->rtp_rdbx);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美二区三区| 中文字幕中文乱码欧美一区二区| 久久久久久久久久看片| 国产精品美女久久久久久久久 | 狠狠色狠狠色综合| 972aa.com艺术欧美| 26uuu久久综合| 天天色图综合网| 99精品欧美一区| 久久精品视频网| 久久成人羞羞网站| 欧美久久久一区| 亚洲三级在线看| 国v精品久久久网| 精品国产乱码久久久久久闺蜜 | 一区二区高清视频在线观看| 国产精品亚洲а∨天堂免在线| 欧美裸体一区二区三区| 亚洲激情校园春色| 91毛片在线观看| 一区在线中文字幕| 国产成人一级电影| 国产欧美精品国产国产专区| 另类综合日韩欧美亚洲| 欧美福利一区二区| 日本成人在线网站| 777久久久精品| 午夜精品久久久久久久久久久| 色婷婷久久综合| 日韩毛片视频在线看| 99久久99久久精品免费观看| 国产精品麻豆视频| 成人精品国产一区二区4080| 国产精品亲子伦对白| 成人免费视频caoporn| 欧美国产1区2区| 不卡一区中文字幕| 亚洲免费观看高清完整版在线 | 91在线观看美女| 国产精品久久久久久久裸模| 不卡在线观看av| 日韩一区中文字幕| 欧美日韩亚洲不卡| 男男gaygay亚洲| 国产视频一区在线播放| 成人免费高清在线观看| 亚洲精品国久久99热| 欧美日韩不卡一区二区| 奇米精品一区二区三区在线观看| 欧美va在线播放| 高清不卡在线观看av| 亚洲人成影院在线观看| 欧美日韩电影一区| 国产在线麻豆精品观看| 中文幕一区二区三区久久蜜桃| 99久久国产综合精品女不卡| 天堂蜜桃91精品| 久久综合九色综合97_久久久| 成人动漫中文字幕| 亚洲v精品v日韩v欧美v专区| 精品国产电影一区二区| www.亚洲色图.com| 午夜激情一区二区| 欧美激情在线看| 欧美妇女性影城| 成人免费视频一区| 日本成人在线网站| 亚洲欧美区自拍先锋| 欧美大片在线观看一区| jlzzjlzz国产精品久久| 日韩综合一区二区| 亚洲欧洲成人自拍| 日韩久久精品一区| 色综合天天狠狠| 国产美女精品人人做人人爽| 亚洲男人天堂一区| 久久婷婷久久一区二区三区| 欧美特级限制片免费在线观看| 国产一区二区三区四| 一区二区三区在线播| 久久久久97国产精华液好用吗| 欧美三级在线播放| 成人不卡免费av| 精油按摩中文字幕久久| 亚洲一级片在线观看| 国产婷婷色一区二区三区在线| 欧美一区二区性放荡片| 91福利国产成人精品照片| 成人教育av在线| 国产一区二区三区最好精华液| 亚洲成人午夜电影| 亚洲欧美国产高清| 亚洲国产精品成人综合| 日韩女优电影在线观看| 欧美精品色综合| 欧美在线一二三| bt欧美亚洲午夜电影天堂| 精品写真视频在线观看| 日本中文一区二区三区| 亚洲成人激情社区| 亚洲欧美另类小说视频| 中文字幕在线免费不卡| 亚洲国产精品国自产拍av| 国产亚洲成年网址在线观看| 精品久久人人做人人爽| 日韩一区二区在线看| 91精品视频网| 91精品国产综合久久福利软件| 精品视频免费在线| 日本韩国欧美在线| 欧美伊人久久久久久久久影院| 色婷婷精品久久二区二区蜜臂av| 99精品欧美一区二区蜜桃免费| 99久久精品国产精品久久| 99精品视频一区二区| 99久久精品费精品国产一区二区| 91尤物视频在线观看| 99热精品一区二区| 一本到不卡精品视频在线观看| 一本高清dvd不卡在线观看| 色伊人久久综合中文字幕| 91麻豆精品一区二区三区| 日本高清不卡在线观看| 欧美日韩一区小说| 欧美一级高清大全免费观看| 精品日韩在线观看| 国产精品你懂的在线欣赏| 亚洲三级免费观看| 亚洲v日本v欧美v久久精品| 日韩 欧美一区二区三区| 久久99精品久久久久久国产越南| 国产曰批免费观看久久久| 国产91富婆露脸刺激对白| 99视频在线精品| 在线成人小视频| 精品久久久久久久久久久久久久久久久 | 精品久久久久99| 国产色产综合产在线视频| 国产精品国产成人国产三级 | 亚洲欧美怡红院| 午夜在线电影亚洲一区| 精一区二区三区| 99久久久久久| 7777精品伊人久久久大香线蕉完整版| 日韩精品一区二区三区在线观看| 欧美极品少妇xxxxⅹ高跟鞋| 一区二区三区资源| 久久精品国产第一区二区三区| 国产不卡视频在线观看| 在线观看亚洲成人| 久久这里都是精品| 亚洲精品乱码久久久久久日本蜜臀| 免费高清成人在线| 成人午夜电影小说| 日韩一级片在线观看| 国产精品福利电影一区二区三区四区 | 最新欧美精品一区二区三区| 日韩电影一二三区| 成人av先锋影音| 日韩一区二区免费在线观看| 成人欧美一区二区三区1314| 美女www一区二区| 91无套直看片红桃| 久久无码av三级| 日韩中文字幕1| 色偷偷成人一区二区三区91| www国产精品av| 日日夜夜免费精品视频| 91丨porny丨户外露出| 久久久久久久电影| 另类人妖一区二区av| 欧美网站一区二区| 国产精品欧美一区喷水| 国内精品在线播放| 88在线观看91蜜桃国自产| 亚洲色图在线视频| 国产乱子伦视频一区二区三区| 欧美精品aⅴ在线视频| 亚洲免费色视频| 99九九99九九九视频精品| 国产欧美一区二区在线| 久久99国产精品成人| 欧美精品久久久久久久多人混战 | 日韩理论片一区二区| 麻豆国产精品一区二区三区| 欧美日韩国产综合一区二区| 亚洲欧美区自拍先锋| av网站一区二区三区| 欧美国产精品一区二区三区| 国产电影一区在线| 久久久久久影视| 国产一区二区影院| 久久精品亚洲一区二区三区浴池| 久久精品av麻豆的观看方式| 欧美一区二区三区的| 日韩电影在线观看一区| 91精品国产日韩91久久久久久| 日本视频一区二区三区| 欧美一级在线免费| 久久成人久久鬼色|