1 /*
2 * Decryption protocol handler
3 * Copyright (c) 2011 Martin Storsjo
4 *
5 * This file is part of Libav.
6 *
7 * Libav is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * Libav is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
28
29 #define MAX_BUFFER_BLOCKS 150
31
46
47 #define OFFSET(x) offsetof(CryptoContext, x)
48 #define D AV_OPT_FLAG_DECODING_PARAM
52 { NULL }
53 };
54
60 };
61
63 {
64 const char *nested_url;
67
72 goto err;
73 }
74
78 goto err;
79 }
83 goto err;
84 }
88 goto err;
89 }
93 goto err;
94 }
95
97
99
100 err:
102 }
103
105 {
107 int blocks;
108 retry:
111 memcpy(buf, c->
outptr, size);
115 }
116 // We avoid using the last block until we've found EOF,
117 // since we'll remove PKCS7 padding at the end. So make
118 // sure we've got at least 2 blocks, so we can decrypt
119 // at least one.
123 if (n <= 0) {
125 break;
126 }
128 }
130 if (!blocks)
133 blocks--;
144 }
146 // Remove PKCS7 padding at the end
149 }
150 goto retry;
151 }
152
154 {
159 return 0;
160 }
161
168 .priv_data_class = &crypto_class,
170 };