1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747 |
- extern "C" {
- (SRTP_AEAD_SALT_LEN + SRTP_AES_128_KEY_LEN)
- (SRTP_AEAD_SALT_LEN + SRTP_AES_192_KEY_LEN)
- (SRTP_AEAD_SALT_LEN + SRTP_AES_256_KEY_LEN)
- typedef uint32_t srtp_cipher_type_id_t;
- typedef uint32_t srtp_auth_type_id_t;
- typedef enum {
- srtp_err_status_ok = 0,
- srtp_err_status_fail = 1,
- srtp_err_status_bad_param = 2,
- srtp_err_status_alloc_fail = 3,
- srtp_err_status_dealloc_fail = 4,
- srtp_err_status_init_fail = 5,
- srtp_err_status_terminus = 6,
-
- srtp_err_status_auth_fail = 7,
- srtp_err_status_cipher_fail = 8,
- srtp_err_status_replay_fail = 9,
- srtp_err_status_replay_old = 10,
-
- srtp_err_status_algo_fail = 11,
- srtp_err_status_no_such_op = 12,
- srtp_err_status_no_ctx = 13,
- srtp_err_status_cant_check = 14,
-
- srtp_err_status_key_expired = 15,
- srtp_err_status_socket_err = 16,
- srtp_err_status_signal_err = 17,
- srtp_err_status_nonce_bad = 18,
- srtp_err_status_read_fail = 19,
- srtp_err_status_write_fail = 20,
- srtp_err_status_parse_err = 21,
- srtp_err_status_encode_err = 22,
- srtp_err_status_semaphore_err = 23,
- srtp_err_status_pfkey_err = 24,
- srtp_err_status_bad_mki = 25,
-
- srtp_err_status_pkt_idx_old = 26,
-
- srtp_err_status_pkt_idx_adv = 27
-
- } srtp_err_status_t;
- typedef struct srtp_ctx_t_ srtp_ctx_t;
- typedef enum {
- sec_serv_none = 0,
- sec_serv_conf = 1,
- sec_serv_auth = 2,
- sec_serv_conf_and_auth = 3
- } srtp_sec_serv_t;
- typedef struct srtp_crypto_policy_t {
- srtp_cipher_type_id_t cipher_type;
-
- int cipher_key_len;
-
- srtp_auth_type_id_t auth_type;
-
- int auth_key_len;
-
- int auth_tag_len;
-
- srtp_sec_serv_t sec_serv;
-
- } srtp_crypto_policy_t;
- typedef enum {
- ssrc_undefined = 0,
- ssrc_specific = 1,
- ssrc_any_inbound = 2,
-
-
- ssrc_any_outbound = 3
-
-
- } srtp_ssrc_type_t;
- typedef struct {
- srtp_ssrc_type_t type;
- unsigned int value;
-
- } srtp_ssrc_t;
- typedef struct srtp_master_key_t {
- unsigned char *key;
- unsigned char *mki_id;
- unsigned int mki_size;
- } srtp_master_key_t;
- typedef struct srtp_policy_t {
- srtp_ssrc_t ssrc;
-
-
-
- srtp_crypto_policy_t rtp;
- srtp_crypto_policy_t rtcp;
- unsigned char *key;
-
- srtp_master_key_t **keys;
- unsigned long num_master_keys;
- void *deprecated_ekt;
-
- unsigned long window_size;
-
- int allow_repeat_tx;
-
-
-
-
-
-
- int *enc_xtn_hdr;
- int enc_xtn_hdr_count;
-
- struct srtp_policy_t *next;
- } srtp_policy_t;
- typedef srtp_ctx_t *srtp_t;
- srtp_err_status_t srtp_init(void);
- srtp_err_status_t srtp_shutdown(void);
- srtp_err_status_t srtp_protect(srtp_t ctx, void *rtp_hdr, int *len_ptr);
- srtp_err_status_t srtp_protect_mki(srtp_ctx_t *ctx,
- void *rtp_hdr,
- int *pkt_octet_len,
- unsigned int use_mki,
- unsigned int mki_index);
- srtp_err_status_t srtp_unprotect(srtp_t ctx, void *srtp_hdr, int *len_ptr);
- srtp_err_status_t srtp_unprotect_mki(srtp_t ctx,
- void *srtp_hdr,
- int *len_ptr,
- unsigned int use_mki);
- srtp_err_status_t srtp_create(srtp_t *session, const srtp_policy_t *policy);
- srtp_err_status_t srtp_add_stream(srtp_t session, const srtp_policy_t *policy);
- srtp_err_status_t srtp_remove_stream(srtp_t session, unsigned int ssrc);
- srtp_err_status_t srtp_update(srtp_t session, const srtp_policy_t *policy);
- srtp_err_status_t srtp_update_stream(srtp_t session,
- const srtp_policy_t *policy);
- void srtp_crypto_policy_set_rtp_default(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_rtcp_default(srtp_crypto_policy_t *p);
- srtp_crypto_policy_set_rtp_default(p)
- void srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_cm_128_null_auth(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_null_cipher_hmac_sha1_80(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_null_cipher_hmac_null(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_cm_256_null_auth(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_cm_192_hmac_sha1_80(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_cm_192_hmac_sha1_32(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_cm_192_null_auth(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_gcm_128_8_auth(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_gcm_256_8_auth(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_gcm_128_8_only_auth(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_gcm_256_8_only_auth(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_gcm_128_16_auth(srtp_crypto_policy_t *p);
- void srtp_crypto_policy_set_aes_gcm_256_16_auth(srtp_crypto_policy_t *p);
- srtp_err_status_t srtp_dealloc(srtp_t s);
- typedef enum {
- srtp_profile_reserved = 0,
- srtp_profile_aes128_cm_sha1_80 = 1,
- srtp_profile_aes128_cm_sha1_32 = 2,
- srtp_profile_null_sha1_80 = 5,
- srtp_profile_null_sha1_32 = 6,
- srtp_profile_aead_aes_128_gcm = 7,
- srtp_profile_aead_aes_256_gcm = 8,
- } srtp_profile_t;
- 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_rtcp(
- srtp_crypto_policy_t *policy,
- srtp_profile_t profile);
- unsigned int srtp_profile_get_master_key_length(srtp_profile_t profile);
- unsigned int srtp_profile_get_master_salt_length(srtp_profile_t profile);
- void srtp_append_salt_to_key(unsigned char *key,
- unsigned int bytes_in_key,
- unsigned char *salt,
- unsigned int bytes_in_salt);
- srtp_err_status_t srtp_protect_rtcp(srtp_t ctx,
- void *rtcp_hdr,
- int *pkt_octet_len);
- srtp_err_status_t srtp_protect_rtcp_mki(srtp_t ctx,
- void *rtcp_hdr,
- int *pkt_octet_len,
- unsigned int use_mki,
- unsigned int mki_index);
- srtp_err_status_t srtp_unprotect_rtcp(srtp_t ctx,
- void *srtcp_hdr,
- int *pkt_octet_len);
- srtp_err_status_t srtp_unprotect_rtcp_mki(srtp_t ctx,
- void *srtcp_hdr,
- int *pkt_octet_len,
- unsigned int use_mki);
- void srtp_set_user_data(srtp_t ctx, void *data);
- void *srtp_get_user_data(srtp_t ctx);
- typedef enum {
- event_ssrc_collision,
- event_key_soft_limit,
-
- event_key_hard_limit,
-
- event_packet_index_limit
-
- } srtp_event_t;
- typedef struct srtp_event_data_t {
- srtp_t session;
- uint32_t ssrc;
-
- srtp_event_t event;
- } srtp_event_data_t;
- typedef void(srtp_event_handler_func_t)(srtp_event_data_t *data);
- srtp_err_status_t srtp_install_event_handler(srtp_event_handler_func_t func);
- const char *srtp_get_version_string(void);
- unsigned int srtp_get_version(void);
- srtp_err_status_t srtp_set_debug_module(const char *mod_name, int v);
- srtp_err_status_t srtp_list_debug_modules(void);
- typedef enum {
- srtp_log_level_error,
- srtp_log_level_warning,
- srtp_log_level_info,
- srtp_log_level_debug
- } srtp_log_level_t;
- typedef void(srtp_log_handler_func_t)(srtp_log_level_t level,
- const char *msg,
- void *data);
- srtp_err_status_t srtp_install_log_handler(srtp_log_handler_func_t func,
- void *data);
- srtp_err_status_t srtp_get_protect_trailer_length(srtp_t session,
- uint32_t use_mki,
- uint32_t mki_index,
- uint32_t *length);
- srtp_err_status_t srtp_get_protect_rtcp_trailer_length(srtp_t session,
- uint32_t use_mki,
- uint32_t mki_index,
- uint32_t *length);
- srtp_err_status_t srtp_set_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);
- }
|