Libgourou

Libgourou Git Source Tree

Root/utils/drmprocessorclientimpl.h

1/*
2 Copyright (c) 2021, Grégory Soutadé
3
4 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the copyright holder nor the
14 names of its contributors may be used to endorse or promote products
15 derived from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#ifndef _DRMPROCESSORCLIENTIMPL_H_
30#define _DRMPROCESSORCLIENTIMPL_H_
31
32#include <string>
33
34#include <drmprocessorclient.h>
35
36class DRMProcessorClientImpl : public gourou::DRMProcessorClient
37{
38 public:
39 /* Digest interface */
40 virtual void* createDigest(const std::string& digestName);
41 virtual int digestUpdate(void* handler, unsigned char* data, unsigned int length);
42 virtual int digestFinalize(void* handler,unsigned char* digestOut);
43 virtual int digest(const std::string& digestName, unsigned char* data, unsigned int length, unsigned char* digestOut);
44
45 /* Random interface */
46 virtual void randBytes(unsigned char* bytesOut, unsigned int length);
47
48 /* HTTP interface */
49 virtual std::string sendHTTPRequest(const std::string& URL, const std::string& POSTData=std::string(""), const std::string& contentType=std::string(""), std::map<std::string, std::string>* responseHeaders=0);
50
51 virtual void RSAPrivateEncrypt(const unsigned char* RSAKey, unsigned int RSAKeyLength,
52 const RSA_KEY_TYPE keyType, const std::string& password,
53 const unsigned char* data, unsigned dataLength,
54 unsigned char* res);
55
56 virtual void RSAPublicEncrypt(const unsigned char* RSAKey, unsigned int RSAKeyLength,
57 const RSA_KEY_TYPE keyType,
58 const unsigned char* data, unsigned dataLength,
59 unsigned char* res);
60
61 virtual void* generateRSAKey(int keyLengthBits);
62 virtual void destroyRSAHandler(void* handler);
63
64 virtual void extractRSAPublicKey(void* RSAKeyHandler, unsigned char** keyOut, unsigned int* keyOutLength);
65 virtual void extractRSAPrivateKey(void* RSAKeyHandler, unsigned char** keyOut, unsigned int* keyOutLength);
66 virtual void extractCertificate(const unsigned char* RSAKey, unsigned int RSAKeyLength,
67 const RSA_KEY_TYPE keyType, const std::string& password,
68 unsigned char** certOut, unsigned int* certOutLength);
69
70 /* Crypto interface */
71 virtual void AESEncrypt(CHAINING_MODE chaining,
72 const unsigned char* key, unsigned int keyLength,
73 const unsigned char* iv, unsigned int ivLength,
74 const unsigned char* dataIn, unsigned int dataInLength,
75 unsigned char* dataOut, unsigned int* dataOutLength);
76
77 virtual void* AESEncryptInit(CHAINING_MODE chaining,
78 const unsigned char* key, unsigned int keyLength,
79 const unsigned char* iv=0, unsigned int ivLength=0);
80
81
82 virtual void AESEncryptUpdate(void* handler, const unsigned char* dataIn, unsigned int dataInLength,
83 unsigned char* dataOut, unsigned int* dataOutLength);
84 virtual void AESEncryptFinalize(void* handler, unsigned char* dataOut, unsigned int* dataOutLength);
85
86 virtual void AESDecrypt(CHAINING_MODE chaining,
87 const unsigned char* key, unsigned int keyLength,
88 const unsigned char* iv, unsigned int ivLength,
89 const unsigned char* dataIn, unsigned int dataInLength,
90 unsigned char* dataOut, unsigned int* dataOutLength);
91
92 virtual void* AESDecryptInit(CHAINING_MODE chaining,
93 const unsigned char* key, unsigned int keyLength,
94 const unsigned char* iv=0, unsigned int ivLength=0);
95
96 virtual void AESDecryptUpdate(void* handler, const unsigned char* dataIn, unsigned int dataInLength,
97 unsigned char* dataOut, unsigned int* dataOutLength);
98 virtual void AESDecryptFinalize(void* handler, unsigned char* dataOut, unsigned int* dataOutLength);
99
100 /* ZIP Interface */
101 virtual void* zipOpen(const std::string& path);
102
103 virtual std::string zipReadFile(void* handler, const std::string& path);
104
105 virtual void zipWriteFile(void* handler, const std::string& path, const std::string& content);
106
107 virtual void zipDeleteFile(void* handler, const std::string& path);
108
109 virtual void zipClose(void* handler);
110
111 virtual void inflate(std::string data, gourou::ByteArray& result, int wbits=-15);
112
113 virtual void deflate(std::string data, gourou::ByteArray& result,
114 int wbits=-15, int compressionLevel=8);
115};
116
117#endif

Archive Download this file