libavutil/des.h
2e9ad69a
 /*
  * DES encryption/decryption
  * Copyright (c) 2007 Reimar Doeffinger
  *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
  * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
98790382
 #ifndef AVUTIL_DES_H
 #define AVUTIL_DES_H
2e9ad69a
 
fe0c188b
 #include <stdint.h>
1a534c7f
 
 struct AVDES {
     uint64_t round_keys[3][16];
     int triple_des;
 };
 
 /**
adbfc605
  * @brief Initializes an AVDES context.
1a534c7f
  *
adbfc605
  * @param key_bits must be 64 or 192
b3e144a7
  * @param decrypt 0 for encryption/CBC-MAC, 1 for decryption
1a534c7f
  */
 int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt);
f0a838e5
 
46fb896b
 /**
adbfc605
  * @brief Encrypts / decrypts using the DES algorithm.
46fb896b
  *
adbfc605
  * @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
  * @param iv initialization vector for CBC mode, if NULL then ECB will be used,
1a534c7f
  *           must be 8-byte aligned
adbfc605
  * @param decrypt 0 for encryption, 1 for decryption
46fb896b
  */
1a534c7f
 void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
2e9ad69a
 
b3e144a7
 /**
  * @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);
 
98790382
 #endif /* AVUTIL_DES_H */