Ap4StreamCipher.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:1k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.  * Copyright (c) 2005 Gilles Boccon-Gibod
  3.  */
  4. #ifndef _AP4_STREAM_CIPHER_H_
  5. #define _AP4_STREAM_CIPHER_H_
  6. /*----------------------------------------------------------------------
  7. |       includes
  8. +---------------------------------------------------------------------*/
  9. #include "Ap4AesBlockCipher.h"
  10. #include "Ap4Results.h"
  11. #include "Ap4Types.h"
  12. /*----------------------------------------------------------------------
  13. |       AP4_StreamCipher class
  14. +---------------------------------------------------------------------*/
  15. class AP4_StreamCipher
  16. {
  17.  public:
  18.     // methods
  19.     AP4_StreamCipher(const AP4_UI08* key = NULL, 
  20.                      const AP4_UI08* salt = NULL,
  21.                      AP4_Size        iv_size = 4);
  22.     ~AP4_StreamCipher();
  23.     AP4_Result SetStreamOffset(AP4_Offset offset);
  24.     AP4_Result Reset(const AP4_UI08* key, const AP4_UI08* salt);
  25.     AP4_Result ProcessBuffer(const AP4_UI08* in, 
  26.                              AP4_UI08*       out,
  27.                              AP4_Size        size);
  28.     AP4_Offset GeStreamOffset() { return m_StreamOffset; }
  29.  private:
  30.     // members
  31.     AP4_Offset          m_StreamOffset;
  32.     AP4_Size            m_IvSize;
  33.     AP4_UI08            m_CBlock[AP4_AES_BLOCK_SIZE];
  34.     AP4_UI08            m_XBlock[AP4_AES_BLOCK_SIZE];
  35.     AP4_AesBlockCipher* m_BlockCipher;
  36.     // methods
  37.     void SetCounter(AP4_Offset block_offset);
  38.     AP4_Result UpdateKeyStream(AP4_Offset block_offset);
  39. };
  40. #endif // _AP4_STREAM_CIPHER_H_