yading@11: /* yading@11: * RTMPE encryption utilities yading@11: * Copyright (c) 2012 Samuel Pitoiset yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVFORMAT_RTMPCRYPT_H yading@11: #define AVFORMAT_RTMPCRYPT_H yading@11: yading@11: #include yading@11: yading@11: #include "url.h" yading@11: yading@11: /** yading@11: * Initialize the Diffie-Hellmann context and generate the public key. yading@11: * yading@11: * @param h an URLContext yading@11: * @param buf handshake data (1536 bytes) yading@11: * @return zero on success, negative value otherwise yading@11: */ yading@11: int ff_rtmpe_gen_pub_key(URLContext *h, uint8_t *buf); yading@11: yading@11: /** yading@11: * Compute the shared secret key and initialize the RC4 encryption. yading@11: * yading@11: * @param h an URLContext yading@11: * @param serverdata server data (1536 bytes) yading@11: * @param clientdata client data (1536 bytes) yading@11: * @param type the position of the server digest yading@11: * @return zero on success, negative value otherwise yading@11: */ yading@11: int ff_rtmpe_compute_secret_key(URLContext *h, const uint8_t *serverdata, yading@11: const uint8_t *clientdata, int type); yading@11: yading@11: /** yading@11: * Encrypt the signature. yading@11: * yading@11: * @param h an URLContext yading@11: * @param signature the signature to encrypt yading@11: * @param digest the digest used for finding the encryption key yading@11: * @param type type of encryption (8 for XTEA, 9 for Blowfish) yading@11: */ yading@11: void ff_rtmpe_encrypt_sig(URLContext *h, uint8_t *signature, yading@11: const uint8_t *digest, int type); yading@11: yading@11: /** yading@11: * Update the keystream and set RC4 keys for encryption. yading@11: * yading@11: * @param h an URLContext yading@11: * @return zero on success, negative value otherwise yading@11: */ yading@11: int ff_rtmpe_update_keystream(URLContext *h); yading@11: yading@11: #endif /* AVFORMAT_RTMPCRYPT_H */