Changeset 5261 for pjproject/trunk/third_party/srtp/include/srtp.h
- Timestamp:
- Mar 15, 2016 3:57:39 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/third_party/srtp/include/srtp.h
r4537 r5261 51 51 #endif 52 52 53 #ifdef _MSC_VER 54 # ifdef WIN64 55 # pragma pack(8) 56 # else 57 # pragma pack(4) 58 # endif 59 #endif 60 61 #include "crypto_kernel.h" 53 #include <stdint.h> 54 #include "crypto.h" 55 #include "crypto_types.h" 56 #include "err.h" 62 57 63 58 /** … … 85 80 */ 86 81 87 #define SRTP_MAX_TAG_LEN 1 282 #define SRTP_MAX_TAG_LEN 16 88 83 89 84 /** … … 96 91 */ 97 92 #define SRTP_MAX_TRAILER_LEN SRTP_MAX_TAG_LEN 93 94 /* 95 * SRTP_AEAD_SALT_LEN is the length of the SALT values used with 96 * GCM mode. GCM mode requires an IV. The SALT value is used 97 * as part of the IV formation logic applied to each RTP packet. 98 */ 99 #define SRTP_AEAD_SALT_LEN 12 100 #define AES_128_GCM_KEYSIZE_WSALT SRTP_AEAD_SALT_LEN + 16 101 #define AES_192_GCM_KEYSIZE_WSALT SRTP_AEAD_SALT_LEN + 24 102 #define AES_256_GCM_KEYSIZE_WSALT SRTP_AEAD_SALT_LEN + 32 103 104 98 105 99 106 /* … … 177 184 178 185 186 /** 187 * @brief points to an EKT policy 188 */ 189 typedef struct ekt_policy_ctx_t *ekt_policy_t; 190 191 192 /** 193 * @brief points to EKT stream data 194 */ 195 typedef struct ekt_stream_ctx_t *ekt_stream_t; 196 197 179 198 /** 180 199 * @brief represents the policy for an SRTP session. … … 214 233 unsigned char *key; /**< Pointer to the SRTP master key for 215 234 * this stream. */ 235 ekt_policy_t ekt; /**< Pointer to the EKT policy structure 236 * for this stream (if any) */ 237 unsigned long window_size; /**< The window size to use for replay 238 * protection. */ 239 int allow_repeat_tx; /**< Whether retransmissions of 240 * packets with the same sequence number 241 * are allowed. (Note that such repeated 242 * transmissions must have the same RTP 243 * payload, or a severe security weakness 244 * is introduced!) */ 216 245 struct srtp_policy_t *next; /**< Pointer to next stream policy. */ 217 246 } srtp_policy_t; … … 263 292 264 293 /** 265 * @brief srtp_deinit() deinitializes the srtp library. 266 * 267 * @warning This function @b must be called on quitting application or 268 * after srtp is no longer used. 294 * @brief srtp_shutdown() de-initializes the srtp library. 295 * 296 * @warning No srtp functions may be called after calling this function. 269 297 */ 270 298 271 299 err_status_t 272 srtp_ deinit(void);300 srtp_shutdown(void); 273 301 274 302 /** … … 292 320 * boundary. 293 321 * 322 * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN 323 * into the location in memory immediately following the RTP packet. 324 * Callers MUST ensure that this much writable memory is available in 325 * the buffer that holds the RTP packet. 326 * 294 327 * @param ctx is the SRTP context to use in processing the packet. 295 328 * … … 330 363 * 32-bit boundary. 331 364 * 332 * @param ctx is a pointer to the srtp_t which applies to the 333 * particular packet. 365 * @param ctx is the SRTP session which applies to the particular packet. 334 366 * 335 367 * @param srtp_hdr is a pointer to the header of the SRTP packet … … 364 396 * key. 365 397 * 366 * @param session is the SRTP session to which the policy is to be added. 398 * @param session is a pointer to the SRTP session to which the policy is 399 * to be added. 367 400 * 368 401 * @param policy is the srtp_policy_t struct that describes the policy … … 479 512 * The function crypto_policy_set_aes_cm_128_hmac_sha1_80() is a 480 513 * synonym for crypto_policy_set_rtp_default(). It conforms to the 481 * naming convention used in 482 * http://www.ietf.org/internet-drafts/draft-ietf-mmusic-sdescriptions-12.txt514 * naming convention used in RFC 4568 (SDP Security Descriptions for 515 * Media Streams). 483 516 * 484 517 * @return void. … … 497 530 * The function call crypto_policy_set_aes_cm_128_hmac_sha1_32(&p) 498 531 * sets the crypto_policy_t at location p to use policy 499 * AES_CM_128_HMAC_SHA1_32 as defined in 500 * draft-ietf-mmusic-sdescriptions-12.txt.This policy uses AES-128532 * AES_CM_128_HMAC_SHA1_32 as defined in RFC 4568. 533 * This policy uses AES-128 501 534 * Counter Mode encryption and HMAC-SHA1 authentication, with an 502 535 * authentication tag that is only 32 bits long. This length is … … 582 615 void 583 616 crypto_policy_set_null_cipher_hmac_sha1_80(crypto_policy_t *p); 617 618 619 /** 620 * @brief crypto_policy_set_aes_cm_256_hmac_sha1_80() sets a crypto 621 * policy structure to a encryption and authentication policy using AES-256 622 * for RTP protection. 623 * 624 * @param p is a pointer to the policy structure to be set 625 * 626 * The function call crypto_policy_set_aes_cm_256_hmac_sha1_80(&p) 627 * sets the crypto_policy_t at location p to use policy 628 * AES_CM_256_HMAC_SHA1_80 as defined in 629 * draft-ietf-avt-srtp-big-aes-03.txt. This policy uses AES-256 630 * Counter Mode encryption and HMAC-SHA1 authentication, with an 80 bit 631 * authentication tag. 632 * 633 * This function is a convenience that helps to avoid dealing directly 634 * with the policy data structure. You are encouraged to initialize 635 * policy elements with this function call. Doing so may allow your 636 * code to be forward compatible with later versions of libSRTP that 637 * include more elements in the crypto_policy_t datatype. 638 * 639 * @return void. 640 * 641 */ 642 643 void crypto_policy_set_aes_cm_256_hmac_sha1_80(crypto_policy_t *p); 644 645 646 /** 647 * @brief crypto_policy_set_aes_cm_256_hmac_sha1_32() sets a crypto 648 * policy structure to a short-authentication tag policy using AES-256 649 * encryption. 650 * 651 * @param p is a pointer to the policy structure to be set 652 * 653 * The function call crypto_policy_set_aes_cm_256_hmac_sha1_32(&p) 654 * sets the crypto_policy_t at location p to use policy 655 * AES_CM_256_HMAC_SHA1_32 as defined in 656 * draft-ietf-avt-srtp-big-aes-03.txt. This policy uses AES-256 657 * Counter Mode encryption and HMAC-SHA1 authentication, with an 658 * authentication tag that is only 32 bits long. This length is 659 * considered adequate only for protecting audio and video media that 660 * use a stateless playback function. See Section 7.5 of RFC 3711 661 * (http://www.ietf.org/rfc/rfc3711.txt). 662 * 663 * This function is a convenience that helps to avoid dealing directly 664 * with the policy data structure. You are encouraged to initialize 665 * policy elements with this function call. Doing so may allow your 666 * code to be forward compatible with later versions of libSRTP that 667 * include more elements in the crypto_policy_t datatype. 668 * 669 * @warning This crypto policy is intended for use in SRTP, but not in 670 * SRTCP. It is recommended that a policy that uses longer 671 * authentication tags be used for SRTCP. See Section 7.5 of RFC 3711 672 * (http://www.ietf.org/rfc/rfc3711.txt). 673 * 674 * @return void. 675 * 676 */ 677 678 void 679 crypto_policy_set_aes_cm_256_hmac_sha1_32(crypto_policy_t *p); 680 681 /** 682 * @brief crypto_policy_set_aes_cm_256_null_auth() sets a crypto 683 * policy structure to an encryption-only policy 684 * 685 * @param p is a pointer to the policy structure to be set 686 * 687 * The function call crypto_policy_set_aes_cm_256_null_auth(&p) sets 688 * the crypto_policy_t at location p to use the SRTP default cipher 689 * (AES-256 Counter Mode), but to use no authentication method. This 690 * policy is NOT RECOMMENDED unless it is unavoidable; see Section 7.5 691 * of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). 692 * 693 * This function is a convenience that helps to avoid dealing directly 694 * with the policy data structure. You are encouraged to initialize 695 * policy elements with this function call. Doing so may allow your 696 * code to be forward compatible with later versions of libSRTP that 697 * include more elements in the crypto_policy_t datatype. 698 * 699 * @warning This policy is NOT RECOMMENDED for SRTP unless it is 700 * unavoidable, and it is NOT RECOMMENDED at all for SRTCP; see 701 * Section 7.5 of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). 702 * 703 * @return void. 704 * 705 */ 706 void 707 crypto_policy_set_aes_cm_256_null_auth(crypto_policy_t *p); 708 709 /** 710 * @brief crypto_policy_set_aes_gcm_128_8_auth() sets a crypto 711 * policy structure to an AEAD encryption policy. 712 * 713 * @param p is a pointer to the policy structure to be set 714 * 715 * The function call crypto_policy_set_aes_gcm_128_8_auth(&p) sets 716 * the crypto_policy_t at location p to use the SRTP default cipher 717 * (AES-128 Galois Counter Mode) with 8 octet auth tag. This 718 * policy applies confidentiality and authentication to both the 719 * RTP and RTCP packets. 720 * 721 * This function is a convenience that helps to avoid dealing directly 722 * with the policy data structure. You are encouraged to initialize 723 * policy elements with this function call. Doing so may allow your 724 * code to be forward compatible with later versions of libSRTP that 725 * include more elements in the crypto_policy_t datatype. 726 * 727 * @return void. 728 * 729 */ 730 void 731 crypto_policy_set_aes_gcm_128_8_auth(crypto_policy_t *p); 732 733 /** 734 * @brief crypto_policy_set_aes_gcm_256_8_auth() sets a crypto 735 * policy structure to an AEAD encryption policy 736 * 737 * @param p is a pointer to the policy structure to be set 738 * 739 * The function call crypto_policy_set_aes_gcm_256_8_auth(&p) sets 740 * the crypto_policy_t at location p to use the SRTP default cipher 741 * (AES-256 Galois Counter Mode) with 8 octet auth tag. This 742 * policy applies confidentiality and authentication to both the 743 * RTP and RTCP packets. 744 * 745 * This function is a convenience that helps to avoid dealing directly 746 * with the policy data structure. You are encouraged to initialize 747 * policy elements with this function call. Doing so may allow your 748 * code to be forward compatible with later versions of libSRTP that 749 * include more elements in the crypto_policy_t datatype. 750 * 751 * @return void. 752 * 753 */ 754 void 755 crypto_policy_set_aes_gcm_256_8_auth(crypto_policy_t *p); 756 757 /** 758 * @brief crypto_policy_set_aes_gcm_128_8_only_auth() sets a crypto 759 * policy structure to an AEAD authentication-only policy 760 * 761 * @param p is a pointer to the policy structure to be set 762 * 763 * The function call crypto_policy_set_aes_gcm_128_8_only_auth(&p) sets 764 * the crypto_policy_t at location p to use the SRTP default cipher 765 * (AES-128 Galois Counter Mode) with 8 octet auth tag. This policy 766 * applies confidentiality and authentication to the RTP packets, 767 * but only authentication to the RTCP packets. 768 * 769 * This function is a convenience that helps to avoid dealing directly 770 * with the policy data structure. You are encouraged to initialize 771 * policy elements with this function call. Doing so may allow your 772 * code to be forward compatible with later versions of libSRTP that 773 * include more elements in the crypto_policy_t datatype. 774 * 775 * @return void. 776 * 777 */ 778 void 779 crypto_policy_set_aes_gcm_128_8_only_auth(crypto_policy_t *p); 780 781 /** 782 * @brief crypto_policy_set_aes_gcm_256_8_only_auth() sets a crypto 783 * policy structure to an AEAD authentication-only policy 784 * 785 * @param p is a pointer to the policy structure to be set 786 * 787 * The function call crypto_policy_set_aes_gcm_256_8_only_auth(&p) sets 788 * the crypto_policy_t at location p to use the SRTP default cipher 789 * (AES-256 Galois Counter Mode) with 8 octet auth tag. This policy 790 * applies confidentiality and authentication to the RTP packets, 791 * but only authentication to the RTCP packets. 792 * 793 * This function is a convenience that helps to avoid dealing directly 794 * with the policy data structure. You are encouraged to initialize 795 * policy elements with this function call. Doing so may allow your 796 * code to be forward compatible with later versions of libSRTP that 797 * include more elements in the crypto_policy_t datatype. 798 * 799 * @return void. 800 * 801 */ 802 void 803 crypto_policy_set_aes_gcm_256_8_only_auth(crypto_policy_t *p); 804 805 /** 806 * @brief crypto_policy_set_aes_gcm_128_16_auth() sets a crypto 807 * policy structure to an AEAD encryption policy. 808 * 809 * @param p is a pointer to the policy structure to be set 810 * 811 * The function call crypto_policy_set_aes_gcm_128_16_auth(&p) sets 812 * the crypto_policy_t at location p to use the SRTP default cipher 813 * (AES-128 Galois Counter Mode) with 16 octet auth tag. This 814 * policy applies confidentiality and authentication to both the 815 * RTP and RTCP packets. 816 * 817 * This function is a convenience that helps to avoid dealing directly 818 * with the policy data structure. You are encouraged to initialize 819 * policy elements with this function call. Doing so may allow your 820 * code to be forward compatible with later versions of libSRTP that 821 * include more elements in the crypto_policy_t datatype. 822 * 823 * @return void. 824 * 825 */ 826 void 827 crypto_policy_set_aes_gcm_128_16_auth(crypto_policy_t *p); 828 829 /** 830 * @brief crypto_policy_set_aes_gcm_256_16_auth() sets a crypto 831 * policy structure to an AEAD encryption policy 832 * 833 * @param p is a pointer to the policy structure to be set 834 * 835 * The function call crypto_policy_set_aes_gcm_256_16_auth(&p) sets 836 * the crypto_policy_t at location p to use the SRTP default cipher 837 * (AES-256 Galois Counter Mode) with 16 octet auth tag. This 838 * policy applies confidentiality and authentication to both the 839 * RTP and RTCP packets. 840 * 841 * This function is a convenience that helps to avoid dealing directly 842 * with the policy data structure. You are encouraged to initialize 843 * policy elements with this function call. Doing so may allow your 844 * code to be forward compatible with later versions of libSRTP that 845 * include more elements in the crypto_policy_t datatype. 846 * 847 * @return void. 848 * 849 */ 850 void 851 crypto_policy_set_aes_gcm_256_16_auth(crypto_policy_t *p); 852 584 853 585 854 /** … … 747 1016 * boundary. 748 1017 * 1018 * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN+4 1019 * into the location in memory immediately following the RTCP packet. 1020 * Callers MUST ensure that this much writable memory is available in 1021 * the buffer that holds the RTCP packet. 1022 * 749 1023 * @param ctx is the SRTP context to use in processing the packet. 750 1024 * … … 813 1087 * @} 814 1088 */ 1089 1090 1091 /** 1092 * @defgroup User data associated to a SRTP session. 1093 * @ingroup SRTP 1094 * 1095 * @brief Store custom user data within a SRTP session. 1096 * 1097 * @{ 1098 */ 1099 1100 /** 1101 * @brief srtp_set_user_data() stores the given pointer into the SRTP 1102 * session for later retrieval. 1103 * 1104 * @param ctx is the srtp_t context in which the given data pointer is 1105 * stored. 1106 * 1107 * @param data is a pointer to the custom information (struct, function, 1108 * etc) associated with the SRTP session. 1109 * 1110 * @return void. 1111 * 1112 */ 1113 1114 void 1115 srtp_set_user_data(srtp_t ctx, void *data); 1116 1117 /** 1118 * @brief srtp_get_user_data() retrieves the pointer to the custom data 1119 * previously stored with srtp_set_user_data(). 1120 * 1121 * This function is mostly useful for retrieving data associated to a 1122 * SRTP session when an event fires. The user can then get such a custom 1123 * data by calling this function with the session field of the 1124 * srtp_event_data_t struct as argument. 1125 * 1126 * @param ctx is the srtp_t context in which the given data pointer was 1127 * stored. 1128 * 1129 * @return void* pointer to the user data. 1130 * 1131 */ 1132 1133 void* 1134 srtp_get_user_data(srtp_t ctx); 1135 1136 /** 1137 * @} 1138 */ 1139 815 1140 816 1141 /** … … 915 1240 916 1241 /** 1242 * @brief Returns the version string of the library. 1243 * 1244 */ 1245 const char *srtp_get_version_string(void); 1246 1247 /** 1248 * @brief Returns the numeric representation of the library version. 1249 * 1250 */ 1251 unsigned int srtp_get_version(void); 1252 1253 /** 917 1254 * @} 918 1255 */ … … 923 1260 #define SRTCP_INDEX_MASK 0x7fffffff 924 1261 925 #ifdef _MSC_VER926 #pragma pack()927 #endif928 929 1262 #ifdef __cplusplus 930 1263 }
Note: See TracChangeset
for help on using the changeset viewer.