rtmpcrypt.h 2.2 KB

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