1 /* des.c --- DES and Triple-DES encryption/decryption Algorithm
2 * Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007
3 * Free Software Foundation, Inc.
5 * This file is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2, or (at your
8 * option) any later version.
10 * This file is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this file; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * ----------------------------------------------------------------------
21 * Functions to compute MD4 message digest of files or memory blocks.
22 * according to the definition of MD4 in RFC 1320 from April 1992. Copyright
23 * (C) 1995,1996,1997,1999,2000,2001,2002,2003,2005,2006 Free Software
26 * This program is free software; you can redistribute it and/or modify it
27 * under the terms of the GNU General Public License as published by the
28 * Free Software Foundation; either version 2, or (at your option) any
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public License
37 * along with this program; if not, write to the Free Software Foundation,
38 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
49 #define MD5_DIGEST_SIZE 16
50 #define MD5_BLOCK_SIZE 64
54 #define gl_des_ecb_encrypt(ctx, from, to) gl_des_ecb_crypt(ctx, from, to, 0)
55 #define gl_des_ecb_decrypt(ctx, from, to) gl_des_ecb_crypt(ctx, from, to, 1)
58 * Encryption/Decryption context of DES
61 uint32_t encrypt_subkeys
[32];
62 uint32_t decrypt_subkeys
[32];
65 /* Structures to save state of computation between the single steps. */
88 extern bool gl_des_is_weak_key(const char * key
);
89 extern void gl_des_setkey(gl_des_ctx
*ctx
, const char * key
);
90 extern bool gl_des_makekey(gl_des_ctx
*ctx
, const char * key
, size_t keylen
);
91 extern void gl_des_ecb_crypt(gl_des_ctx
*ctx
, const char * _from
, char * _to
, int mode
);
93 extern void md4_process_block (const void *buffer
, size_t len
, struct md4_ctx
*ctx
);
94 extern void md4_init_ctx (struct md4_ctx
*ctx
);
95 extern void *md4_read_ctx (const struct md4_ctx
*ctx
, void *resbuf
);
96 extern void *md4_finish_ctx (struct md4_ctx
*ctx
, void *resbuf
);
97 extern void md4_process_bytes (const void *buffer
, size_t len
, struct md4_ctx
*ctx
);
98 extern int md4_stream(FILE * stream
, void *resblock
);
99 extern void *md4_buffer (const char *buffer
, size_t len
, void *resblock
);
101 extern int hmac_md5 (const void *key
, size_t keylen
, const void *in
, size_t inlen
, void *resbuf
);
103 extern void md5_init_ctx (struct md5_ctx
*ctx
);
104 extern void md5_process_block (const void *buffer
, size_t len
, struct md5_ctx
*ctx
);
105 extern void md5_process_bytes (const void *buffer
, size_t len
, struct md5_ctx
*ctx
);
106 extern void *md5_finish_ctx (struct md5_ctx
*ctx
, void *resbuf
);
107 extern void *md5_read_ctx (const struct md5_ctx
*ctx
, void *resbuf
);
108 extern int md5_stream (FILE *stream
, void *resblock
);
109 extern void *md5_buffer (const char *buffer
, size_t len
, void *resblock
);
111 #endif /* _XCRYPT_H */