• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __DRM_ISTREAM_H__
18 #define __DRM_ISTREAM_H__
19 
20 #include <Drm2CommonTypes.h>
21 #include <util/crypto/DrmCrypto.h>
22 #include <dcf/DrmDcfContainer.h>
23 #include <ustring.h>
24 
25 using namespace ustl;
26 
27 class DcfContainer;
28 
29 class DrmInStream
30 {
31 public:
32     /** default constructor of DrmInStream */
DrmInStream()33     DrmInStream():mDecryptPos(0){}
34 
35     /**
36      * constructor for DrmInStream, used to read DCF content
37      * \param encFile  DCF container data
38      * \param len   DCF container data len
39      * \param off   the offset from the start of DCF container
40      */
41     DrmInStream(const DcfContainer* container,uint8_t* Key);
42 
43     /**
44      * get the size of DRM Instream
45      * \param none
46      * \return
47      *   the size of DRM Instream
48      */
49     uint64_t size() const;
50 
51     /**
52      * read data from DRM Instream
53      * \param  data  the buffer to store read data
54      * \param  len   how much data need to read
55      * \return
56      *   the actual len of read data
57      */
58     uint64_t read(uint8_t* data,uint64_t len);
59 
60 PRIVATE:
61     static const uint32_t AES_IV_LEN = 16;
62     static const uint32_t AES_KEY_LEN = 16;
63     static const uint32_t AES_BLOCK_LEN = 16;
64 
65     const DcfContainer* mDcfCon;
66     uint64_t mDecryptPos;
67     uint8_t mAesKey[AES_KEY_LEN];
68 };
69 
70 
71 
72 #endif
73 
74 
75 
76 
77 
78