srtp.h 2.68 KB
Newer Older
1 2
/*
 * Secure RTP with libgcrypt
3
 * Copyright (C) 2007  Rémi Denis-Courmont
4 5
 *
 * This library is free software; you can redistribute it and/or
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
6 7 8
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
9 10 11
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
12 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
14 15 16 17
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
18
 ****************************************************************************/
19 20 21 22 23 24 25 26

#ifndef LIBVLC_SRTP_H
# define LIBVLC_SRTP_H 1

typedef struct srtp_session_t srtp_session_t;

enum
{
27 28 29
    SRTP_UNENCRYPTED=0x1,   //< do not encrypt SRTP packets
    SRTCP_UNENCRYPTED=0x2,  //< do not encrypt SRTCP packets
    SRTP_UNAUTHENTICATED=0x4, //< authenticate only SRTCP packets
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
30

31 32 33
    SRTP_RCC_MODE1=0x10,    //< use Roll-over-Counter Carry mode 1
    SRTP_RCC_MODE2=0x20,    //< use Roll-over-Counter Carry mode 2
    SRTP_RCC_MODE3=0x30,    //< use Roll-over-Counter Carry mode 3 (insecure)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
34

35
    SRTP_FLAGS_MASK=0x37    //< mask for valid flags
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
36 37
};

38
/** SRTP encryption algorithms (ciphers); same values as MIKEY */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
39 40
enum
{
41 42 43
    SRTP_ENCR_NULL=0,   //< no encryption
    SRTP_ENCR_AES_CM=1, //< AES counter mode
    SRTP_ENCR_AES_F8=2, //< AES F8 mode (not implemented)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
44 45
};

46
/** SRTP authenticaton algorithms; same values as MIKEY */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
47 48
enum
{
49 50
    SRTP_AUTH_NULL=0,      //< no authentication code
    SRTP_AUTH_HMAC_SHA1=1, //< HMAC-SHA1
51 52
};

53
/** SRTP pseudo random function; same values as MIKEY */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
54 55
enum
{
56
    SRTP_PRF_AES_CM=0, //< AES counter mode
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
57
};
58 59 60 61 62

# ifdef __cplusplus
extern "C" {
# endif

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
63 64
srtp_session_t *srtp_create (int encr, int auth, unsigned tag_len, int prf,
                             unsigned flags);
65
void srtp_destroy (srtp_session_t *s);
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
66

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
67 68
int srtp_setkey (srtp_session_t *s, const void *key, size_t keylen,
                 const void *salt, size_t saltlen);
69 70
int srtp_setkeystring (srtp_session_t *s, const char *key, const char *salt);

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
71
void srtp_setrcc_rate (srtp_session_t *s, uint16_t rate);
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
72

73 74
int srtp_send (srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t maxsize);
int srtp_recv (srtp_session_t *s, uint8_t *buf, size_t *lenp);
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
75 76
int srtcp_send (srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t maxsiz);
int srtcp_recv (srtp_session_t *s, uint8_t *buf, size_t *lenp);
77 78 79 80 81 82

# ifdef __cplusplus
}
# endif
#endif