File: Ap4AesBlockCipher.h

package info (click to toggle)
kodi-inputstream-adaptive 2.6.14%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,036 kB
  • sloc: cpp: 53,019; ansic: 492; makefile: 10
file content (58 lines) | stat: -rw-r--r-- 1,858 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * AES Block cipher
 * (c) 2005-2010 Axiomatic Systems, LLC
 */

#ifndef _AP4_AES_BLOCK_CIPHER_H_
#define _AP4_AES_BLOCK_CIPHER_H_

/*----------------------------------------------------------------------
|   includes
+---------------------------------------------------------------------*/
#include "Ap4Types.h"
#include "Ap4Config.h"
#include "Ap4Protection.h"

/*----------------------------------------------------------------------
|   class references
+---------------------------------------------------------------------*/
struct aes_ctx;

/*----------------------------------------------------------------------
|   AES constants
+---------------------------------------------------------------------*/
#define AP4_AES_BLOCK_SIZE  16
#define AP4_AES_KEY_LENGTH  16

/*----------------------------------------------------------------------
|   AP4_AesBlockCipher class
+---------------------------------------------------------------------*/
class AP4_AesBlockCipher : public AP4_BlockCipher
{
public:
    // constructor and destructor
    static AP4_Result Create(const AP4_UI08*      key, 
                             CipherDirection      direction,
                             CipherMode           mode,
                             const void*          mode_params,
                             AP4_AesBlockCipher*& cipher);
    virtual ~AP4_AesBlockCipher();

    virtual CipherDirection GetDirection() { return m_Direction; }
    
protected:
    // constructor
    AP4_AesBlockCipher(CipherDirection direction, 
                       CipherMode      mode,
                       aes_ctx*        context) :
        m_Direction(direction),
        m_Mode(mode),
        m_Context(context) {}

    // members
    CipherDirection m_Direction;
    CipherMode      m_Mode;
    aes_ctx*        m_Context;
};

#endif // _AP4_AES_BLOCK_CIPHER_H_