29 #define MAX_BUFFER_BLOCKS 150
60 #define OFFSET(x) offsetof(CryptoContext, x)
61 #define D AV_OPT_FLAG_DECODING_PARAM
62 #define E AV_OPT_FLAG_ENCODING_PARAM
81 uint8_t *default_buf,
int default_buf_len,
85 if (!default_buf_len) {
88 }
else if (default_buf_len !=
BLOCKSIZE) {
90 "invalid %s size (%d bytes, block size is %d)\n",
94 *buf =
av_memdup(default_buf, default_buf_len);
97 *buf_len = default_buf_len;
100 "invalid %s size (%d bytes, block size is %d)\n",
109 const char *nested_url;
122 c->
key, c->
keylen,
"decryption key")) < 0)
125 c->
iv, c->
ivlen,
"decryption IV")) < 0)
131 c->
key, c->
keylen,
"encryption key")) < 0)
135 c->
iv, c->
ivlen,
"encryption IV")) < 0)
146 if (flags & AVIO_FLAG_READ) {
157 if (flags & AVIO_FLAG_WRITE) {
183 memcpy(buf, c->
outptr, size);
228 int total_size, blocks, pad_len,
out_size;
232 total_size = size + c->
pad_len;
234 out_size = total_size - pad_len;
257 memcpy(c->
pad, &buf[size - pad_len], pad_len);
294 .priv_data_class = &crypto_class,
static int crypto_close(URLContext *h)
#define LIBAVUTIL_VERSION_INT
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
int is_streamed
true if streamed (no seek possible), default = false
AVIOInterruptCB interrupt_callback
static int crypto_read(URLContext *h, uint8_t *buf, int size)
#define AVIO_FLAG_READ
read-only
void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context.
#define AVIO_FLAG_WRITE
write-only
static const AVOption options[]
uint8_t inbuffer[BLOCKSIZE *MAX_BUFFER_BLOCKS]
URLProtocol ff_crypto_protocol
uint8_t outbuffer[BLOCKSIZE *MAX_BUFFER_BLOCKS]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AVERROR_EOF
End of file.
static int crypto_open2(URLContext *h, const char *uri, int flags, AVDictionary **options)
#define MAX_BUFFER_BLOCKS
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
struct AVAES * aes_decrypt
const char * protocol_whitelist
#define URL_PROTOCOL_FLAG_NESTED_SCHEME
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
struct AVAES * aes_encrypt
static const AVClass crypto_class
offset must point to a pointer immediately followed by an int for the length
void * av_memdup(const void *p, size_t size)
Duplicate the buffer p.
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
Describe the class of an AVClass context structure.
static int crypto_write(URLContext *h, const unsigned char *buf, int size)
int ffurl_close(URLContext *h)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
static int set_aes_arg(CryptoContext *c, uint8_t **buf, int *buf_len, uint8_t *default_buf, int default_buf_len, const char *desc)
unbuffered private I/O API
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf...