yading@11
|
1 /*
|
yading@11
|
2 * RTMPE encryption utilities
|
yading@11
|
3 * Copyright (c) 2012 Samuel Pitoiset
|
yading@11
|
4 *
|
yading@11
|
5 * This file is part of FFmpeg.
|
yading@11
|
6 *
|
yading@11
|
7 * FFmpeg is free software; you can redistribute it and/or
|
yading@11
|
8 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
9 * License as published by the Free Software Foundation; either
|
yading@11
|
10 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
11 *
|
yading@11
|
12 * FFmpeg is distributed in the hope that it will be useful,
|
yading@11
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
15 * Lesser General Public License for more details.
|
yading@11
|
16 *
|
yading@11
|
17 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
18 * License along with FFmpeg; if not, write to the Free Software
|
yading@11
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
20 */
|
yading@11
|
21
|
yading@11
|
22 #ifndef AVFORMAT_RTMPCRYPT_H
|
yading@11
|
23 #define AVFORMAT_RTMPCRYPT_H
|
yading@11
|
24
|
yading@11
|
25 #include <stdint.h>
|
yading@11
|
26
|
yading@11
|
27 #include "url.h"
|
yading@11
|
28
|
yading@11
|
29 /**
|
yading@11
|
30 * Initialize the Diffie-Hellmann context and generate the public key.
|
yading@11
|
31 *
|
yading@11
|
32 * @param h an URLContext
|
yading@11
|
33 * @param buf handshake data (1536 bytes)
|
yading@11
|
34 * @return zero on success, negative value otherwise
|
yading@11
|
35 */
|
yading@11
|
36 int ff_rtmpe_gen_pub_key(URLContext *h, uint8_t *buf);
|
yading@11
|
37
|
yading@11
|
38 /**
|
yading@11
|
39 * Compute the shared secret key and initialize the RC4 encryption.
|
yading@11
|
40 *
|
yading@11
|
41 * @param h an URLContext
|
yading@11
|
42 * @param serverdata server data (1536 bytes)
|
yading@11
|
43 * @param clientdata client data (1536 bytes)
|
yading@11
|
44 * @param type the position of the server digest
|
yading@11
|
45 * @return zero on success, negative value otherwise
|
yading@11
|
46 */
|
yading@11
|
47 int ff_rtmpe_compute_secret_key(URLContext *h, const uint8_t *serverdata,
|
yading@11
|
48 const uint8_t *clientdata, int type);
|
yading@11
|
49
|
yading@11
|
50 /**
|
yading@11
|
51 * Encrypt the signature.
|
yading@11
|
52 *
|
yading@11
|
53 * @param h an URLContext
|
yading@11
|
54 * @param signature the signature to encrypt
|
yading@11
|
55 * @param digest the digest used for finding the encryption key
|
yading@11
|
56 * @param type type of encryption (8 for XTEA, 9 for Blowfish)
|
yading@11
|
57 */
|
yading@11
|
58 void ff_rtmpe_encrypt_sig(URLContext *h, uint8_t *signature,
|
yading@11
|
59 const uint8_t *digest, int type);
|
yading@11
|
60
|
yading@11
|
61 /**
|
yading@11
|
62 * Update the keystream and set RC4 keys for encryption.
|
yading@11
|
63 *
|
yading@11
|
64 * @param h an URLContext
|
yading@11
|
65 * @return zero on success, negative value otherwise
|
yading@11
|
66 */
|
yading@11
|
67 int ff_rtmpe_update_keystream(URLContext *h);
|
yading@11
|
68
|
yading@11
|
69 #endif /* AVFORMAT_RTMPCRYPT_H */
|