70,037
社区成员
发帖
与我相关
我的任务
分享
#ifndef _DES_H
#define _DES_H
#ifndef uint8
#define uint8 unsigned char
#endif
#ifndef uint32
#define uint32 unsigned long int
#endif
typedef struct
{
uint32 esk[32]; /* DES encryption subkeys */
uint32 dsk[32]; /* DES decryption subkeys */
} des_context;
typedef struct
{
uint32 esk[96]; /* Triple-DES encryption subkeys */
uint32 dsk[96]; /* Triple-DES decryption subkeys */
} des3_context;
int des_set_key( des_context *ctx, uint8 key[8] );
void des_encrypt( des_context *ctx, uint8 input[8], uint8 output[8] );
void des_decrypt( des_context *ctx, uint8 input[8], uint8 output[8] );
int des3_set_2keys( des3_context *ctx, uint8 key1[8], uint8 key2[8] );
int des3_set_3keys( des3_context *ctx, uint8 key1[8], uint8 key2[8], uint8 key3[8] );
void des3_encrypt( des3_context *ctx, uint8 input[8], uint8 output[8] );
void des3_decrypt( des3_context *ctx, uint8 input[8], uint8 output[8] );
#endif /* des.h */
/*
* FIPS-46-3 compliant 3DES implementation
*
* Copyright (C) 2001-2003 Christophe Devine
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/