aboutsummaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorMichael Niedermayer2011-09-21 21:25:43 +0200
committerMichael Niedermayer2011-09-21 21:25:43 +0200
commit3e1a7ae44a97f20bbc9da0eba000663ef74e1890 (patch)
tree75bfd6ad30f1b24aa7d29c3a3081875c14b5dab5 /libavutil
parent358d837dad4e2fbe010553990383d0ca4d5937cf (diff)
parent05fc9e40a4e4f808d457512420b887f458d216bc (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: swfdec: Add support for sample_rate_code 0 (5512 Hz) dct-test: factor out some common code and do whas was likely intended doc: library versions need to be bumped in version.h Revert "ffmpeg: get rid of useless AVInputStream.nb_streams." Remove some forgotten AVCodecContext.palctrl usage. lavc/utils: move avcodec_init() higher in the file. lavc: replace some deprecated FF_*_TYPE with AV_PICTURE_TYPE_* ac3dec: actually use drc_scale private option lavc: undeprecate AVPALETTE_SIZE and AVPALETTE_COUNT macros alsa: add missing header msmpeg4: remove leftover unused debug variable declaration Fix assert() calls that need updates after FF_COMMON_FRAME macro elimination. Fix av_dlog invocations with wrong or missing logging context. vf_yadif: add support to yuva420p vf_yadif: correct documentation on the parity parameter vf_yadif: copy buffer properties like aspect for second frame as well oma: support for encrypted files id3v2: add support for non-text and GEOB type tag frames des: add possibility to calculate DES-CBC-MAC with small buffer Conflicts: ffmpeg.c libavcodec/dct-test.c libavformat/mpegts.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/des.c13
-rw-r--r--libavutil/des.h11
2 files changed, 21 insertions, 3 deletions
diff --git a/libavutil/des.c b/libavutil/des.c
index f6643696d6..b876dccd53 100644
--- a/libavutil/des.c
+++ b/libavutil/des.c
@@ -298,7 +298,7 @@ int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) {
return 0;
}
-void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt) {
+static void av_des_crypt_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt, int mac) {
uint64_t iv_val = iv ? AV_RB64(iv) : 0;
while (count-- > 0) {
uint64_t dst_val;
@@ -321,12 +321,21 @@ void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t
}
AV_WB64(dst, dst_val);
src += 8;
- dst += 8;
+ if (!mac)
+ dst += 8;
}
if (iv)
AV_WB64(iv, iv_val);
}
+void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt) {
+ av_des_crypt_mac(d, dst, src, count, iv, decrypt, 0);
+}
+
+void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) {
+ av_des_crypt_mac(d, dst, src, count, (uint8_t[8]){0}, 0, 1);
+}
+
#ifdef TEST
#undef printf
#undef rand
diff --git a/libavutil/des.h b/libavutil/des.h
index dd670869b2..2feb0468db 100644
--- a/libavutil/des.h
+++ b/libavutil/des.h
@@ -33,7 +33,7 @@ struct AVDES {
* @brief Initializes an AVDES context.
*
* @param key_bits must be 64 or 192
- * @param decrypt 0 for encryption, 1 for decryption
+ * @param decrypt 0 for encryption/CBC-MAC, 1 for decryption
*/
int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt);
@@ -49,4 +49,13 @@ int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt);
*/
void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
+/**
+ * @brief Calculates CBC-MAC using the DES algorithm.
+ *
+ * @param count number of 8 byte blocks
+ * @param dst destination array, can be equal to src, must be 8-byte aligned
+ * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
+ */
+void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count);
+
#endif /* AVUTIL_DES_H */