diff options
author | Samuel Pitoiset <samuel.pitoiset@gmail.com> | 2012-07-19 14:13:58 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-07-23 16:32:07 +0300 |
commit | acd554c103459ae7a5d89caa611e91bbc9bf695f (patch) | |
tree | 7e591295c7f7057bc6e8c3da4ef7d825611c868b /libavformat/rtmpcrypt.h | |
parent | 0e31088b6c57e7d495deda0abaf5de5adb2c18fa (diff) | |
download | ffmpeg-acd554c103459ae7a5d89caa611e91bbc9bf695f.tar.gz |
RTMPE protocol support
This adds two protocols, but one of them is an internal implementation
detail just used as an abstraction layer/generalization in the code. The
RTMPE protocol implementation uses ffrtmpcrypt:// as an alternative to the
tcp:// protocol. This allows moving most of the lower level logic out
from the higher level generic rtmp code.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtmpcrypt.h')
-rw-r--r-- | libavformat/rtmpcrypt.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/libavformat/rtmpcrypt.h b/libavformat/rtmpcrypt.h new file mode 100644 index 0000000000..27994333df --- /dev/null +++ b/libavformat/rtmpcrypt.h @@ -0,0 +1,69 @@ +/* + * RTMPE encryption utilities + * Copyright (c) 2012 Samuel Pitoiset + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * 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. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_RTMPCRYPT_H +#define AVFORMAT_RTMPCRYPT_H + +#include <stdint.h> + +#include "url.h" + +/** + * Initialize the Diffie-Hellmann context and generate the public key. + * + * @param h an URLContext + * @param buf handshake data (1536 bytes) + * @return zero on success, negative value otherwise + */ +int ff_rtmpe_gen_pub_key(URLContext *h, uint8_t *buf); + +/** + * Compute the shared secret key and initialize the RC4 encryption. + * + * @param h an URLContext + * @param serverdata server data (1536 bytes) + * @param clientdata client data (1536 bytes) + * @param type the position of the server digest + * @return zero on success, negative value otherwise + */ +int ff_rtmpe_compute_secret_key(URLContext *h, const uint8_t *serverdata, + const uint8_t *clientdata, int type); + +/** + * Encrypt the signature. + * + * @param h an URLContext + * @param signature the signature to encrypt + * @param digest the digest used for finding the encryption key + * @param type type of encryption (8 for XTEA, 9 for Blowfish) + */ +void ff_rtmpe_encrypt_sig(URLContext *h, uint8_t *signature, + const uint8_t *digest, int type); + +/** + * Update the keystream and set RC4 keys for encryption. + * + * @param h an URLContext + * @return zero on success, negative value otherwise + */ +int ff_rtmpe_update_keystream(URLContext *h); + +#endif /* AVFORMAT_RTMPCRYPT_H */ |