libmobi
C library for handling MOBI format ebook documents
encryption.h
Go to the documentation of this file.
1 
11 #ifndef mobi_encryption_h
12 #define mobi_encryption_h
13 
14 #include "config.h"
15 #include "mobi.h"
16 
20 typedef struct {
21  unsigned char *pid;
22  uint32_t valid_from;
23  uint32_t valid_to;
24 } MOBICookie;
25 
30 typedef struct {
31  unsigned char *key;
32  uint32_t cookies_count;
34 } MOBIDrm;
35 
36 void mobi_free_drm(MOBIData *m);
37 MOBI_RET mobi_buffer_decrypt(unsigned char *out, const unsigned char *in, const size_t length, const MOBIData *m);
38 MOBI_RET mobi_drmkey_set(MOBIData *m, const char *pid);
39 MOBI_RET mobi_drmkey_set_serial(MOBIData *m, const char *serial);
41 MOBI_RET mobi_voucher_add(MOBIData *m, const char *serial, const time_t valid_from, const time_t valid_to,
42  const MOBIExthTag *tamperkeys, const size_t tamperkeys_count);
45 
46 #endif /* defined(mobi_encryption_h) */
MOBI_RET mobi_drm_serialize_v2(MOBIBuffer *buf, const MOBIData *m)
Serialize encryption scheme version 2.
Definition: encryption.c:1375
void mobi_free_drm(MOBIData *m)
Free DRM structure.
Definition: encryption.c:221
MOBI_RET mobi_buffer_decrypt(unsigned char *out, const unsigned char *in, const size_t length, const MOBIData *m)
Decrypt buffer with PK1 algorithm.
Definition: encryption.c:558
MOBI_RET mobi_voucher_add(MOBIData *m, const char *serial, const time_t valid_from, const time_t valid_to, const MOBIExthTag *tamperkeys, const size_t tamperkeys_count)
Add DRM voucher.
Definition: encryption.c:999
MOBI_RET mobi_drmkey_set_serial(MOBIData *m, const char *serial)
Store key for encryption in MOBIData stucture. Pid will be calculated from device serial number.
Definition: encryption.c:845
MOBI_RET mobi_drmkey_set(MOBIData *m, const char *pid)
Store key for encryption in MOBIData stucture.
Definition: encryption.c:1049
MOBI_RET mobi_drmkey_delete(MOBIData *m)
Remove key from MOBIData structure.
Definition: encryption.c:1103
MOBI_RET mobi_drm_serialize_v1(MOBIBuffer *buf, const MOBIData *m)
Serialize encryption scheme version 1.
Definition: encryption.c:1409
MOBI_RET
Error codes returned by functions.
Definition: mobi.h:59
MOBIExthTag
EXTH record tags.
Definition: mobi.h:91
Libmobi main header file.
Buffer to read to/write from.
Definition: buffer.h:20
Drm cookie data.
Definition: encryption.h:20
unsigned char * pid
Definition: encryption.h:21
uint32_t valid_from
Definition: encryption.h:22
uint32_t valid_to
Definition: encryption.h:23
Main structure holding all metadata and unparsed records data.
Definition: mobi.h:381
Drm data.
Definition: encryption.h:30
MOBICookie ** cookies
Definition: encryption.h:33
unsigned char * key
Definition: encryption.h:31
uint32_t cookies_count
Definition: encryption.h:32